rpi_rgb 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/rpi_rgb.rb +43 -35
- metadata +41 -21
- metadata.gz.sig +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0851e15300976c05106da84ef3333447d15dc4aa'
|
4
|
+
data.tar.gz: cdb7e9a721459598d73d0700d0695cde22b8e565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27d538145b1aa5ff801d17bac311c201863fec094b63523fcabadc1fa8599e4752949d81e9074abe910df13e5717bac6d0958e503172748b594140975b7c5335
|
7
|
+
data.tar.gz: 5d7fe8e3c3a05f4127b5bf1414f6b43b270984784f3f69f5469b301e327481bfb18ccd18e1b45441ae4f09f243b6d4ba3b2d3ded5710ae1de276180d0c4f6350
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rpi_rgb.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
# file: rpi_rgb.rb
|
4
4
|
|
5
|
+
require 'rgb'
|
5
6
|
require 'rpi_led'
|
6
7
|
|
7
8
|
|
@@ -10,14 +11,14 @@ require 'rpi_led'
|
|
10
11
|
=begin
|
11
12
|
|
12
13
|
presets = {
|
13
|
-
purple:
|
14
|
-
yellow:
|
15
|
-
orange:
|
16
|
-
|
17
|
-
|
18
|
-
}
|
19
|
-
|
20
|
-
rgb = RPiRGB.new(%w(27 17
|
14
|
+
purple: '#800080',
|
15
|
+
yellow: '#FFFF00',
|
16
|
+
orange: '#FFA500',
|
17
|
+
turquoise: '#40E0D0',
|
18
|
+
steelblue: '#4682B4'
|
19
|
+
}
|
20
|
+
|
21
|
+
rgb = RPiRGB.new(%w(27 17 22), presets: presets, smooth: true)
|
21
22
|
rgb.color = 'white'
|
22
23
|
sleep 2
|
23
24
|
rgb.color = 'purple'
|
@@ -30,12 +31,14 @@ rgb.color = 'yellow'
|
|
30
31
|
|
31
32
|
=end
|
32
33
|
|
34
|
+
# see also: 500+ Named Colours with rgb and hex values http://www.cloford.com/resources/colours/500col.htm
|
35
|
+
|
33
36
|
class RPiRGB
|
34
37
|
|
35
38
|
attr_accessor :brightness
|
36
39
|
attr_reader :red, :green, :blue
|
37
40
|
|
38
|
-
def initialize(pins, brightness: 100, smooth: false, presets:
|
41
|
+
def initialize(pins, brightness: 100, smooth: false, presets: {}, \
|
39
42
|
transition_time: 1.5)
|
40
43
|
|
41
44
|
@red, @green, @blue = pins.map do |x|
|
@@ -62,29 +65,26 @@ class RPiRGB
|
|
62
65
|
def colour=(val)
|
63
66
|
|
64
67
|
@colour = val
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
when 'red'
|
69
|
-
mix 100, 0, 0
|
70
|
-
|
71
|
-
when 'green'
|
72
|
-
mix 0, 100, 0
|
73
|
-
|
74
|
-
when 'blue'
|
75
|
-
mix 0, 0, 100
|
76
|
-
|
77
|
-
when 'white'
|
78
|
-
mix 100, 100, 100
|
79
|
-
|
80
|
-
else
|
68
|
+
|
69
|
+
if val.is_a? String then
|
81
70
|
|
82
|
-
return
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
71
|
+
return mix( RGB::Color.from_rgb_hex(val).to_rgb) if val =~ /^#/
|
72
|
+
|
73
|
+
h = {red: '#FF0000', green: '#00FF00', blue: '#0000FF', white: '#FFFFFF'}
|
74
|
+
|
75
|
+
color = h.merge(@presets)[val.to_sym]
|
76
|
+
|
77
|
+
if color then
|
78
|
+
|
79
|
+
if color =~ /^#/ then
|
80
|
+
mix( RGB::Color.from_rgb_hex(color).to_rgb)
|
81
|
+
else
|
82
|
+
mix color
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
elsif val.is_a? Array
|
87
|
+
mix val
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -95,9 +95,9 @@ class RPiRGB
|
|
95
95
|
alias color= colour=
|
96
96
|
alias color colour
|
97
97
|
|
98
|
-
def mix(*
|
98
|
+
def mix(*rgb_values)
|
99
99
|
|
100
|
-
values.flatten
|
100
|
+
values = rgb_values.flatten.map {|x| (x * 0.392).round }
|
101
101
|
|
102
102
|
r, g, b = if values.length < 4 then
|
103
103
|
|
@@ -118,9 +118,17 @@ class RPiRGB
|
|
118
118
|
red.brightness, green.brightness, blue.brightness = r, g, b
|
119
119
|
end
|
120
120
|
|
121
|
-
def
|
122
|
-
[@red, @green, @blue].each(
|
121
|
+
def blink(seconds=0.5, duration: nil)
|
122
|
+
[@red, @green, @blue].each{|x| x.blink(seconds, duration: duration) }
|
123
|
+
end
|
124
|
+
|
125
|
+
def off(durationx=nil, duration: nil)
|
126
|
+
[@red, @green, @blue].each{|x| x.off(durationx, duration: duration) }
|
123
127
|
end
|
124
128
|
|
129
|
+
def on(durationx=nil, duration: nil)
|
130
|
+
[@red, @green, @blue].each{|x| x.on(durationx, duration: duration) }
|
131
|
+
end
|
132
|
+
|
125
133
|
|
126
134
|
end
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -12,27 +12,47 @@ cert_chain:
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
14
|
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
-
|
15
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3SsmwZPyA+hkPo0mZT5KkjrqqWVl6awCbJrZc3WpQqjnQn9cQer/CT+t6vxLBg/f
|
29
|
+
q19FbyT1jaldiAyeFtn233gVzAllSkgw9YjVq3QVmAqsl228QKRNoj6OIzmhtXxZ
|
30
|
+
Uol43hZ0cvKAxKmo8nsYFQCeUzoHcYbAQMoS1yEUzmH3NNVDXFJJfQ0IAhCGeGOF
|
31
|
+
t96szHrE8Lac4gfN1AUQIHL1JPpSWSK+o4wHx/weelx2J/YLpj90AwU1xnojMr4u
|
32
|
+
HfpdQuYif0P1gg==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
34
|
+
date: 2017-07-28 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rgb
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.1'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.1.0
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.1'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.1.0
|
36
56
|
- !ruby/object:Gem::Dependency
|
37
57
|
name: rpi_led
|
38
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,7 +62,7 @@ dependencies:
|
|
42
62
|
version: '0.1'
|
43
63
|
- - ">="
|
44
64
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.1.
|
65
|
+
version: 0.1.4
|
46
66
|
type: :runtime
|
47
67
|
prerelease: false
|
48
68
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,9 +72,9 @@ dependencies:
|
|
52
72
|
version: '0.1'
|
53
73
|
- - ">="
|
54
74
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.1.
|
75
|
+
version: 0.1.4
|
56
76
|
description:
|
57
|
-
email: james@
|
77
|
+
email: james@jamesrobertson.eu
|
58
78
|
executables: []
|
59
79
|
extensions: []
|
60
80
|
extra_rdoc_files: []
|
@@ -80,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
100
|
version: '0'
|
81
101
|
requirements: []
|
82
102
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.
|
103
|
+
rubygems_version: 2.6.8
|
84
104
|
signing_key:
|
85
105
|
specification_version: 4
|
86
106
|
summary: Changes the colour of an RGB LED connected via GPIO to a Raspberry Pi
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
0
|
1
|
+
+X��$�)��A�i�����t3���2l�R1֣
|
2
|
+
�+BR���'���0>5�,�R����`�&;�AG��ϗ#Iܔ���������*�v+kMS'$$�%z�� �3R�iGWG�]�87K�X����r�'�Wp�f����mE$�����C���(��5�ʳ����i"��%l��v8#L�O��0��/�1���-����k��_?Yj���#�ȏ �F�~�&K����M�?o�:6
|