]> vault307.fbx.one Git - m5Atom.git/blob - rainbowm5.py
m5Atom with LED matrix specific code
[m5Atom.git] / rainbowm5.py
1 from machine import Pin
2 from neopixel import NeoPixel
3 import time
4
5 # Definitions for the ATOM Matrix
6 LED_GPIO = const(27)
7 matrix_size_x = const(5)
8 matrix_size_y = const(5)
9 is_atom_matrix = True
10
11 np = NeoPixel(Pin(LED_GPIO), matrix_size_x * matrix_size_y)
12 n=25
13 def wheel(pos):
14 if pos < 0 or pos > 255:
15 return (0, 0, 0)
16 if pos < 85:
17 return (255 - pos * 3, pos * 3, 0)
18 if pos < 170:
19 pos -= 85
20 return (0, 255 - pos * 3, pos * 3)
21 pos -= 170
22 return (pos * 3, 0, 255 - pos * 3)
23
24 def rainbow_cycle(wait):
25 for j in range(255):
26 for i in range(n):
27 rc_index = (i * 256 // n) + j
28 np.fill(wheel(rc_index & 255))
29 np.write()
30 time.sleep_ms(wait)
31
32 while True:
33 rainbow_cycle(30)