pimoroni-pico/micropython/examples/pico_scroll/demo.py

35 lines
1.0 KiB
Python
Raw Normal View History

import time
2023-03-13 19:39:33 +00:00
from picoscroll import PicoScroll, WIDTH, HEIGHT
scroll = PicoScroll()
i = 0
loop = 18
br_mult = 1
br_pressed = 32
tail = 12
while True:
2021-04-15 09:21:27 +01:00
scroll.clear()
2023-03-13 19:39:33 +00:00
for y in range(0, HEIGHT):
for x in range(0, WIDTH):
if x < 3 and y < 3 and scroll.is_pressed(scroll.BUTTON_A):
scroll.set_pixel(x, y, br_pressed)
elif x < 3 and y > 3 and scroll.is_pressed(scroll.BUTTON_B):
scroll.set_pixel(x, y, br_pressed)
2023-03-13 19:39:33 +00:00
elif x > WIDTH - 4 and y < 3 and scroll.is_pressed(scroll.BUTTON_X):
scroll.set_pixel(x, y, br_pressed)
2023-03-13 19:39:33 +00:00
elif x > WIDTH - 4 and y > 3 and scroll.is_pressed(scroll.BUTTON_Y):
scroll.set_pixel(x, y, br_pressed)
else:
2023-03-13 19:39:33 +00:00
m = (x + (y * WIDTH)) % loop
for b in range(0, loop):
if m == (i + (loop - b)) % loop and b < tail:
scroll.set_pixel(x, y, br_mult * (tail - b))
2023-03-21 14:24:03 +00:00
scroll.show()
i += 1
if i >= loop:
i = 0
time.sleep(0.02)