Merge pull request #10 from The-Spirit/rotate-left-and-right

Rotate left and right
main
benevpi 2021-02-08 13:34:18 +00:00 zatwierdzone przez GitHub
commit 8bd95c7fbc
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 14 dodań i 1 usunięć

Wyświetl plik

@ -66,7 +66,20 @@ class ws2812b:
green = round(green * (self.brightness() / 255))
self.pixels[pixel_num] = blue | red << 8 | green << 16
# rotate x pixels to the left
def rotate_left(self, num_of_pixels):
if num_of_pixels == None:
num_of_pixels = 1
self.pixels = self.pixels[num_of_pixels:] + self.pixels[:num_of_pixels]
# rotate x pixels to the right
def rotate_right(self, num_of_pixels):
if num_of_pixels == None:
num_of_pixels = 1
num_of_pixels = -1 * num_of_pixels
self.pixels = self.pixels[num_of_pixels:] + self.pixels[:num_of_pixels]
def show(self):
for i in range(self.num_leds):
self.sm.put(self.pixels[i],8)