File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -173,6 +173,29 @@ def show(self):
173173 str_resp = ws .ws2811_get_return_t_str (resp )
174174 raise RuntimeError ('ws2811_render failed with code {0} ({1})' .format (resp , str_resp ))
175175
176+ def createPixelSubStrip (self , first , last = None , num = None ):
177+ """Create a PixelSubStrip starting with pixel `first`
178+ Either specify the `num` of pixels or the `last` pixel.
179+
180+ All the methods of a PixelSubStrip are available on PixelStrip
181+ objects.
182+
183+ Note: PixelSubStrips are not prevented from overlappping
184+ """
185+ if last :
186+ if last > len (self ):
187+ raise self .InvalidStrip (f"Too many pixels ({ last } )."
188+ f"Strip only has { len (self )} ." )
189+ return self .PixelSubStrip (self , first , last = last )
190+ if num :
191+ if first + num > len (self ):
192+ raise self .InvalidStrip (f"Too many pixels ({ first + num } )."
193+ f"Strip only has { len (self )} ." )
194+ return self .PixelSubStrip (self , first , num = num )
195+ raise self .InvalidStrip ("Need num or last to create a PixelSubStrip" )
196+
197+ class InvalidStrip (Exception ):
198+ pass
176199
177200 class PixelSubStrip :
178201 """A PixelSubStrip handles a subset of the pixels in a PixelStrip
You can’t perform that action at this time.
0 commit comments