ws2801 1.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/ws2801.rb +31 -8
  2. metadata +1 -1
@@ -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
- @@options[:strip][(i*3)] -= 1 if @@options[:strip][(i*3)] > options[:r]
141
- @@options[:strip][(i*3)] += 1 if @@options[:strip][(i*3)] < options[:r]
142
- @@options[:strip][(i*3+1)] -= 1 if @@options[:strip][(i*3+1)] > options[:g]
143
- @@options[:strip][(i*3+1)] += 1 if @@options[:strip][(i*3+1)] < options[:g]
144
- @@options[:strip][(i*3+2)] -= 1 if @@options[:strip][(i*3+2)] > options[:b]
145
- @@options[:strip][(i*3+2)] += 1 if @@options[:strip][(i*3+2)] < options[:b]
146
- breakme += 1 if @@options[:strip][(i*3+2)] == options[:b] and @@options[:strip][(i*3+1)] == options[:g] and @@options[:strip][(i*3)] == options[:r]
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
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ws2801
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: