kopia lustrzana https://github.com/blaz-r/pi_pico_neopixel
Porównaj commity
7 Commity
093b30ea17
...
15f27b80cc
Autor | SHA1 | Data |
---|---|---|
Blaž Rolih | 15f27b80cc | |
Blaž Rolih | 7c97c8b15a | |
blaz-r | 89b06f4383 | |
Blaž Rolih | 8f158e6390 | |
Blaž Rolih | 30f8314330 | |
Max Carlson | 9e956e518d | |
blaz-r | aef5b0db81 |
27
neopixel.py
27
neopixel.py
|
@ -229,14 +229,29 @@ class Neopixel:
|
||||||
npix[15:21] = (255,0,0) # <- sets 16,17 .. 20 to red
|
npix[15:21] = (255,0,0) # <- sets 16,17 .. 20 to red
|
||||||
npix[21:29:2] = (0,0,255) # <- sets 21,23,25,27 to blue
|
npix[21:29:2] = (0,0,255) # <- sets 21,23,25,27 to blue
|
||||||
npix[1::2] = (0,0,0) # <- sets all odd pixels to 'off'
|
npix[1::2] = (0,0,0) # <- sets all odd pixels to 'off'
|
||||||
|
npix[:] = [(0,5,0),(0,5,0)] # <- replaces all pixels with those from the array
|
||||||
(the 'slice' cases pass idx as a 'slice' object, and
|
(the 'slice' cases pass idx as a 'slice' object, and
|
||||||
set_pixel processes the slice)
|
set_pixel processes the slice)
|
||||||
|
|
||||||
:param idx: Index can either be indexing number or slice
|
:param idx: Index can either be indexing number or slice
|
||||||
:param rgb_w: Tuple of form (r, g, b) or (r, g, b, w) representing color to be used
|
:param rgb_w: Tuple (or list of tuples) of form (r, g, b) or (r, g, b, w) representing color to be used
|
||||||
:return:
|
:return: None
|
||||||
"""
|
"""
|
||||||
self.set_pixel(idx, rgb_w)
|
if type(rgb_w) is list:
|
||||||
|
# set some subset, if idx is a slice:
|
||||||
|
if type(idx) is slice:
|
||||||
|
for rgb_i, pixel_i in enumerate(range(*idx.indices(self.num_leds))):
|
||||||
|
self.set_pixel(pixel_i, rgb_w[rgb_i])
|
||||||
|
else:
|
||||||
|
raise ValueError("Index must be a slice when setting multiple pixels as list")
|
||||||
|
else:
|
||||||
|
self.set_pixel(idx, rgb_w)
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return self.num_leds
|
||||||
|
|
||||||
|
def __getitem__(self, idx):
|
||||||
|
return self.get_pixel(idx)
|
||||||
|
|
||||||
def colorHSV(self, hue, sat, val):
|
def colorHSV(self, hue, sat, val):
|
||||||
"""
|
"""
|
||||||
|
@ -326,9 +341,9 @@ class Neopixel:
|
||||||
cut = 8
|
cut = 8
|
||||||
if self.W_in_mode:
|
if self.W_in_mode:
|
||||||
cut = 0
|
cut = 0
|
||||||
sm_put = self.sm.put
|
|
||||||
for pixval in self.pixels:
|
self.sm.put(self.pixels, cut)
|
||||||
sm_put(pixval, cut)
|
|
||||||
time.sleep(self.delay)
|
time.sleep(self.delay)
|
||||||
|
|
||||||
def fill(self, rgb_w, how_bright=None):
|
def fill(self, rgb_w, how_bright=None):
|
||||||
|
|
Ładowanie…
Reference in New Issue