ws2801 1.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ws2801.rb +31 -8
- metadata +1 -1
data/lib/ws2801.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
#
|
2
3
|
# Controller for: RGB Pixel with WS2801 Chip
|
3
4
|
# build for Diffused Digital RGB LED Pixels from Adafruits on Raspberry Pi
|
@@ -136,14 +137,25 @@ module WS2801
|
|
136
137
|
breakme = 0
|
137
138
|
while true
|
138
139
|
options[:pixel].each do |i|
|
139
|
-
next if @@options[:strip][(i*3+2)] == options[:b] and @@options[:strip][(i*3+1)] == options[:g] and @@options[:strip][(i*3)] == options[:r]
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
140
|
+
#next if @@options[:strip][(i*3+2)] == options[:b] and @@options[:strip][(i*3+1)] == options[:g] and @@options[:strip][(i*3)] == options[:r]
|
141
|
+
if @@options[:strip][(i*3)] > options[:r]
|
142
|
+
@@options[:strip][(i*3)] -= 1
|
143
|
+
elsif @@options[:strip][(i*3)] < options[:r]
|
144
|
+
@@options[:strip][(i*3)] += 1
|
145
|
+
end
|
146
|
+
if @@options[:strip][(i*3+1)] > options[:g]
|
147
|
+
@@options[:strip][(i*3+1)] -= 1
|
148
|
+
elsif @@options[:strip][(i*3+1)] < options[:g]
|
149
|
+
@@options[:strip][(i*3+1)] += 1
|
150
|
+
end
|
151
|
+
if @@options[:strip][(i*3+2)] > options[:b]
|
152
|
+
@@options[:strip][(i*3+2)] -= 1
|
153
|
+
elsif @@options[:strip][(i*3+2)] < options[:b]
|
154
|
+
@@options[:strip][(i*3+2)] -= 1
|
155
|
+
end
|
156
|
+
(breakme += 1; break) if @@options[:strip][(i*3+2)] == options[:b] and @@options[:strip][(i*3+1)] == options[:g] and
|
157
|
+
@@options[:strip][(i*3)] ==
|
158
|
+
options[:r]
|
147
159
|
end
|
148
160
|
self.write if @@options[:autowrite]
|
149
161
|
break if breakme >= @@options[:len]
|
@@ -152,6 +164,17 @@ module WS2801
|
|
152
164
|
end
|
153
165
|
end
|
154
166
|
|
167
|
+
# Get Pixel
|
168
|
+
#
|
169
|
+
# Example:
|
170
|
+
# >> WS2801.get 1
|
171
|
+
# => [255,0,0]
|
172
|
+
#
|
173
|
+
# Arguments:
|
174
|
+
# pixel - Pixel id
|
175
|
+
def self.get pixel
|
176
|
+
[@@options[:strip][pixel*3], @@options[:strip][pixel*3+1], @@options[:strip][pixel*3+2]]
|
177
|
+
end
|
155
178
|
|
156
179
|
# Set off
|
157
180
|
#
|