Toggle Navigation
Hatchery
Eggs
R-rainbow
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import badge import ugfx import deepsleep import time def draw_text(): ugfx.clear(ugfx.WHITE) ugfx.string(20, 20, "Rainbow color led test", "PermanentMarker22", ugfx.BLACK) ugfx.string(20, 80, "B: back to home", "Roboto_Regular12", ugfx.BLACK) ugfx.flush() def home(pressed): if pressed: badge.leds_disable() deepsleep.reboot() def c(n): n = n % (6 * 256) m = n % 256 p = int(n / 256) if p < 1: return m if p < 3: return 255 if p < 4: return 255 - m if p < 6: return 0 badge.leds_enable() ugfx.init() ugfx.input_init() draw_text() ugfx.input_attach(ugfx.BTN_B, home) i = 0 while True: r = c(i + 2 * 256) g = c(i + 6 * 256) b = c(i + 4 * 256) x = 0 leds_array = bytes([g, r, b, x]) leds_array = leds_array + bytes([g, r, b, x]) leds_array = leds_array + bytes([g, r, b, x]) leds_array = leds_array + bytes([g, r, b, x]) leds_array = leds_array + bytes([g, r, b, x]) leds_array = leds_array + bytes([g, r, b, x]) xx = badge.leds_send_data(leds_array) time.sleep(.1) i = i + 8 if i > 6 * 256: i = 0