adding set_pixel_line which fills a particular section of pixels

main
benevpi 2021-01-27 14:37:57 +00:00
rodzic 6eef0e54d0
commit acff06b57d
1 zmienionych plików z 5 dodań i 2 usunięć

Wyświetl plik

@ -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)