tlc59116 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5028c7d08b9f116c964fe4343bf5ee2c6c76ea6f
4
- data.tar.gz: fb9ce21127d492001e5e3c4e9af6b023e0b04ca1
3
+ metadata.gz: 9c3be9aa2000fe69646651f1c09f2713513a3cba
4
+ data.tar.gz: f8152c7da1fbca636294c18a2ec0671ce2121dea
5
5
  SHA512:
6
- metadata.gz: b23d0f02832fa7fa06a8502477eab284f2ae2e2c41602ce10e54b9b76079e52c328223868b5a4f137e2e115e3a65db9eaef17ed26567dbfe0742431501de6904
7
- data.tar.gz: ed920efc0412481324dabc267e916db3df48775dfb9679c285f1f2be265b60a9ec8de564f3301b0daf5580e6d2b85db52de8251c83872ae7f298f0f54cc1f86b
6
+ metadata.gz: 91957d75ac1a0337b981dc0342d9dff1e9035bf27a7f5c6db576da33e860af5b82f203696a0d82440aa403ec7a1f45eb03d683019135103cb72c8de2f93515ce
7
+ data.tar.gz: a02cfccdcc9b57ec88d8949d339e17e8677fcfadcf0bcf2902f29ff7b3babd85b651e46295c5687928a67716129196ad604a338a1e5a3e6eed03e46bb3d25fb9
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.swp
@@ -3,37 +3,54 @@ require "i2c"
3
3
 
4
4
  module Tlc59116
5
5
  class Tlc59116
6
- I2C_ADDRESS = 0x1B
7
-
8
- module Register
9
- MODE1 = 0x00,
10
- MODE2 = 0x01,
11
- PWM = 0x02,
12
- LED_OUT_0 = 0x14,
13
- ERROR_FLAGS1 = 0x1D,
6
+ I2C_ADDRESS = 0x68
7
+
8
+ module Registers
9
+ MODE1 = 0x00
10
+ MODE2 = 0x01
11
+ PWM = 0x02
12
+ GROUPBRIGHTNESS = 0x12
13
+ LED_OUT_0 = 0x14
14
+ ERROR_FLAGS1 = 0x1D
14
15
  ERROR_FLAGS2 = 0x1E
15
16
  end
16
17
 
17
18
  AUTO_INCREMENT = 0x80;
18
19
 
19
- def initialize i2c
20
- @i2c = i2c
21
- end
20
+ def initialize i2c
21
+ @i2c = i2c
22
+ end
23
+
24
+ def mode1 value
25
+ write Registers::MODE1, value
26
+ end
27
+
28
+ def mode2 value
29
+ write Registers::MODE2, value
30
+ end
22
31
 
23
32
  def enable
24
- write Register::MODE1, 0x00;
33
+ value = read_byte Registers::MODE1
34
+ write Registers::MODE1, value & 0xEF
35
+ sleep 0.001
25
36
  end
26
37
 
27
38
  def disable
28
- write Register::MODE1, 0x10;
39
+ value = read_byte Registers::MODE1
40
+ write Registers::MODE1, value | 0x10
41
+ end
42
+
43
+ def pwm_control *value
44
+ write Registers::LED_OUT_0 | AUTO_INCREMENT, *value
29
45
  end
30
46
 
31
- def pwm_control value
32
- write Register::LED_OUT_0 | AUTO_INCREMENT, *value
47
+ def pwm *value, offset: offset = 0
48
+ raise "Offset must be smaller than 16" if offset >= 16
49
+ write (Registers::PWM + offset) | AUTO_INCREMENT, *value
33
50
  end
34
51
 
35
- def pwm address, value
36
- write Register::PWM | AUTO_INCREMENT, *value
52
+ def group_brightness value
53
+ write Registers::GROUPBRIGHTNESS, value
37
54
  end
38
55
 
39
56
  private
@@ -51,8 +68,8 @@ module Tlc59116
51
68
  data.unpack("S_").first
52
69
  end
53
70
 
54
- def write register, value
55
- @i2c.write I2C_ADDRESS, *value
71
+ def write register, *values
72
+ @i2c.write I2C_ADDRESS, register, *values
56
73
  end
57
74
 
58
75
  end
@@ -1,3 +1,3 @@
1
1
  module Tlc59116
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tlc59116
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sille Van Landschoot