@@ -174,77 +174,77 @@ def show(self):
174
174
raise RuntimeError ('ws2811_render failed with code {0} ({1})' .format (resp , str_resp ))
175
175
176
176
177
- class PixelSubStrip :
178
- """A PixelSubStrip handles a subset of the pixels in a PixelStrip
177
+ class PixelSubStrip :
178
+ """A PixelSubStrip handles a subset of the pixels in a PixelStrip
179
179
180
- strip = PixelStrip(...)
181
- strip1 = strip.createPixelSubStrip(0, num=10) # controls first 10 pixels
182
- strip2 = strip.createPixelSubStrip(10, num=10) # controls next 10 pixels
180
+ strip = PixelStrip(...)
181
+ strip1 = strip.createPixelSubStrip(0, num=10) # controls first 10 pixels
182
+ strip2 = strip.createPixelSubStrip(10, num=10) # controls next 10 pixels
183
183
184
- strip2[5] will access the 15th pixel
185
- """
186
- def __init__ (self , strip , first , last = None , num = None ):
187
- self .strip = strip
188
- self .first = first
189
- if last :
190
- self .last = last
191
- self .num = last - first
192
- elif num :
193
- self .last = first + num
194
- self .num = num
195
- else :
196
- raise self .InvalidStrip ("Must specify number or last pixel to "
197
- "create a PixelSubStrip" )
198
-
199
- def __len__ (self ):
200
- return self .num
201
-
202
- def setPixelColor (self , n , color ):
203
- """Set LED at position n to the provided 24-bit color value (in RGB order).
204
- """
205
- self .strip [self .first + n ] = color
206
-
207
- def setPixelColorRGB (self , n , red , green , blue , white = 0 ):
208
- """Set LED at position n to the provided red, green, and blue color.
209
- Each color component should be a value from 0 to 255 (where 0 is the
210
- lowest intensity and 255 is the highest intensity).
211
- """
212
- # Translation to n done in setPixelColor
213
- self .setPixelColor (n , Color (red , green , blue , white ))
214
-
215
- def getBrightness (self ):
216
- return ws .ws2811_channel_t_brightness_get (self .strip ._channel )
217
-
218
- def setBrightness (self , brightness ):
219
- """Scale each LED in the buffer by the provided brightness. A brightness
220
- of 0 is the darkest and 255 is the brightest.
221
-
222
- This method affects all pixels in all PixelSubStrips.
184
+ strip2[5] will access the 15th pixel
223
185
"""
224
- ws .ws2811_channel_t_brightness_set (self .strip ._channel , brightness )
225
-
226
- def getPixels (self ):
227
- """Return an object which allows access to the LED display data as if
228
- it were a sequence of 24-bit RGB values.
229
- """
230
- return self .strip [self .first :self .last ]
231
-
232
- def numPixels (self ):
233
- """Return the number of pixels in the strip."""
234
- return self .num
235
-
236
- def getPixelColor (self , n ):
237
- """Get the 24-bit RGB color value for the LED at position n."""
238
- return self .strip [self .first + n ]
239
-
240
- def getPixelColorRGB (self , n ):
241
- return RGBW (self .strip [self .first + n ])
242
-
243
- def getPixelColorRGBW (self , n ):
244
- return RGBW (self .strip [self .first + n ])
245
-
246
- def show (self ):
247
- self .strip .show ()
186
+ def __init__ (self , strip , first , last = None , num = None ):
187
+ self .strip = strip
188
+ self .first = first
189
+ if last :
190
+ self .last = last
191
+ self .num = last - first
192
+ elif num :
193
+ self .last = first + num
194
+ self .num = num
195
+ else :
196
+ raise self .InvalidStrip ("Must specify number or last pixel to "
197
+ "create a PixelSubStrip" )
198
+
199
+ def __len__ (self ):
200
+ return self .num
201
+
202
+ def setPixelColor (self , n , color ):
203
+ """Set LED at position n to the provided 24-bit color value (in RGB order).
204
+ """
205
+ self .strip [self .first + n ] = color
206
+
207
+ def setPixelColorRGB (self , n , red , green , blue , white = 0 ):
208
+ """Set LED at position n to the provided red, green, and blue color.
209
+ Each color component should be a value from 0 to 255 (where 0 is the
210
+ lowest intensity and 255 is the highest intensity).
211
+ """
212
+ # Translation to n done in setPixelColor
213
+ self .setPixelColor (n , Color (red , green , blue , white ))
214
+
215
+ def getBrightness (self ):
216
+ return ws .ws2811_channel_t_brightness_get (self .strip ._channel )
217
+
218
+ def setBrightness (self , brightness ):
219
+ """Scale each LED in the buffer by the provided brightness. A brightness
220
+ of 0 is the darkest and 255 is the brightest.
221
+
222
+ This method affects all pixels in all PixelSubStrips.
223
+ """
224
+ ws .ws2811_channel_t_brightness_set (self .strip ._channel , brightness )
225
+
226
+ def getPixels (self ):
227
+ """Return an object which allows access to the LED display data as if
228
+ it were a sequence of 24-bit RGB values.
229
+ """
230
+ return self .strip [self .first :self .last ]
231
+
232
+ def numPixels (self ):
233
+ """Return the number of pixels in the strip."""
234
+ return self .num
235
+
236
+ def getPixelColor (self , n ):
237
+ """Get the 24-bit RGB color value for the LED at position n."""
238
+ return self .strip [self .first + n ]
239
+
240
+ def getPixelColorRGB (self , n ):
241
+ return RGBW (self .strip [self .first + n ])
242
+
243
+ def getPixelColorRGBW (self , n ):
244
+ return RGBW (self .strip [self .first + n ])
245
+
246
+ def show (self ):
247
+ self .strip .show ()
248
248
249
249
# Shim for back-compatibility
250
250
class Adafruit_NeoPixel (PixelStrip ):
0 commit comments