kopia lustrzana https://github.com/blaz-r/pico_python_ws2812b
adding set_pixel_line which fills a particular section of pixels
rodzic
6eef0e54d0
commit
acff06b57d
|
@ -26,6 +26,11 @@ class ws2812b:
|
|||
self.sm.active(1)
|
||||
self.num_leds = num_leds
|
||||
self.delay = delay
|
||||
|
||||
# Set an array of pixels starting from "pixel1" to "pixel2" to the desired color.
|
||||
def set_pixel_line(self, pixel1, pixel2, red, green, blue):
|
||||
for i in range(pixel1, pixel2+1):
|
||||
self.set_pixel(i, red, green, blue)
|
||||
|
||||
def set_pixel(self, pixel_num, red, green, blue):
|
||||
self.pixels[pixel_num] = blue | red << 8 | green << 16
|
||||
|
@ -39,5 +44,3 @@ class ws2812b:
|
|||
for i in range(self.num_leds):
|
||||
self.set_pixel(i, red, green, blue)
|
||||
time.sleep(self.delay)
|
||||
|
||||
|
Ładowanie…
Reference in New Issue