rpi_rgb 0.1.3 → 0.1.4

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: 1848ed1d1f9292e366c714efa43c29634415c467
4
- data.tar.gz: dee076a5fae50d6500de3546e1d9cae2f5e406df
3
+ metadata.gz: 0bd0403a7952d84e4ec168cac35765d0fae28f39
4
+ data.tar.gz: a2f8ddde8c891a0f32830729f272dace34e98279
5
5
  SHA512:
6
- metadata.gz: 1df4ef4cbc8b46ff1b5a63f24997088d965b76cdd057a2598a4ad34857c0d295ff384811693533a530c6a1f982d13e9902cc40c762f51f815e34aab8239327c7
7
- data.tar.gz: 1c6fcd6d69c1109e58c08be9f84ebb21c159f6933477baa1f84fc0266fe849f2e5e8688755f339a8e37e17781f5663e5a5affe91286e32ea87e95e7407406c70
6
+ metadata.gz: 4e751d8d7979bbbbdaef1bfe634252279f0211fa0bf668401f342fced7fd941dfdb3da00522ee5f6f1f30debd447b9b5454a7aea96eff4d95994fa0944a99587
7
+ data.tar.gz: b7ff5fff9f3627d9bd1202b5bddff6a52294dad1de8ce2824c98f3713165215d047f1a6184356d63303f2b63f0044eba6e1fc1d4691a65eb777697cb12155385
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rpi_rgb.rb CHANGED
@@ -9,12 +9,24 @@ require 'rpi_led'
9
9
 
10
10
  =begin
11
11
 
12
- rgb = RPiRGB.new(%w(4 17 27), presets: {purple: [100,100,0]})
12
+ presets = {
13
+ purple: [100,0,100],
14
+ yellow: [75, 40, 5, 100],
15
+ orange: [20, 3, 0],
16
+ lilac: [20, 3, 60],
17
+ turquoise: [1, 10, 10]
18
+ }
19
+
20
+ rgb = RPiRGB.new(%w(27 17 4), presets: presets, smooth: true)
13
21
  rgb.color = 'white'
14
22
  sleep 2
15
23
  rgb.color = 'purple'
16
24
  sleep 2
17
25
  rgb.color = 'green'
26
+ sleep 2
27
+ rgb.brightness = 4
28
+ sleep 2
29
+ rgb.color = 'yellow'
18
30
 
19
31
  =end
20
32
 
@@ -23,13 +35,17 @@ class RPiRGB
23
35
  attr_accessor :brightness
24
36
  attr_reader :red, :green, :blue
25
37
 
26
- def initialize(pins, brightness: 100, smooth: false, presets: nil)
38
+ def initialize(pins, brightness: 100, smooth: false, presets: nil, \
39
+ transition_time: 1.5)
27
40
 
28
41
  @red, @green, @blue = pins.map do |x|
29
- RPiLed.new(x, brightness: brightness, smooth: smooth)
42
+ RPiLed.new(x, brightness: brightness, smooth: smooth, \
43
+ transition_time: transition_time)
30
44
  end
31
45
 
32
- @brightness, @presets = brightness, presets
46
+ @brightness, @presets = brightness, presets
47
+ @transition_time = transition_time
48
+ @old_brightness = @brightness
33
49
 
34
50
  end
35
51
 
@@ -81,7 +97,21 @@ class RPiRGB
81
97
 
82
98
  def mix(*values)
83
99
 
84
- r, g, b = values.flatten.map {|v| v / (100 / @brightness ) }
100
+ values.flatten!
101
+
102
+ r, g, b = if values.length < 4 then
103
+
104
+ self.brightness = @old_brightness
105
+ values.map {|v| v / (100.0 / @brightness ) }
106
+
107
+ else
108
+
109
+ @old_brightness = @brightness
110
+ self.brightness = values.pop
111
+ sleep @transition_time if @smooth
112
+ values
113
+
114
+ end
85
115
 
86
116
  [@red, @green, @blue].each(&:on)
87
117
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rpi_rgb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  GIg4vO7u6V4Oc+4pgKLE/xBs2aBPYOzwugWzJxx1+iXcQGW7yUxDK11cRyh37ZGB
32
32
  fFrcZUe/iDfywA==
33
33
  -----END CERTIFICATE-----
34
- date: 2016-04-14 00:00:00.000000000 Z
34
+ date: 2016-04-15 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rpi_led
@@ -42,7 +42,7 @@ dependencies:
42
42
  version: '0.1'
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: 0.1.2
45
+ version: 0.1.3
46
46
  type: :runtime
47
47
  prerelease: false
48
48
  version_requirements: !ruby/object:Gem::Requirement
@@ -52,7 +52,7 @@ dependencies:
52
52
  version: '0.1'
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 0.1.2
55
+ version: 0.1.3
56
56
  description:
57
57
  email: james@r0bertson.co.uk
58
58
  executables: []
metadata.gz.sig CHANGED
@@ -1 +1,2 @@
1
- ^6S��u@D5O2Y})nۤ�p�<��~�N�?D�:ZX��Das��M�5�Ԇk�f1��\��|~��^Ņ�Q���F8{�+]�0B��#��O��h��B�h+�F^68�Ӥ��mx�9�3��k��`f|�֥�^�lHi��S��P�G_c%�
1
+ �*݂���T�lpVﰸop�4]��F����oy~?�6��4�-��u�6w��ntp\�THS`x�%�,��UApEڕ�g�v���n�1����tdAo�:f���'aV���Ѹ�Θ�ꨧMI��1��;��q;g���@�m�]���_€����Dy��J
2
+ 0���ͳ��9�4��6p�7�;�>�(r"|�W<�)�H�'�$��v��0�H�ӠP�ے�R-�)�R���}i�l�g~'����t��zV'ʅ��b��