Toggle Navigation
Hatchery
Eggs
zzz
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import badge import ugfx import time import appglue import random def quit(pressed): if(pressed): appglue.start_app("") ugfx.flush() badge.init() badge.vibrator_init() ugfx.init() ugfx.input_init() ugfx.input_attach(ugfx.JOY_UP, lambda pressed: quit(pressed)) ugfx.input_attach(ugfx.JOY_DOWN, lambda pressed: quit(pressed)) ugfx.input_attach(ugfx.JOY_LEFT, lambda pressed: quit(pressed)) ugfx.input_attach(ugfx.JOY_RIGHT, lambda pressed: quit(pressed)) ugfx.input_attach(ugfx.BTN_A, lambda pressed: quit(pressed)) ugfx.input_attach(ugfx.BTN_B, lambda pressed: quit(pressed)) #ugfx.input_attach(ugfx.BTN_START, lambda pressed: quit(pressed)) #ugfx.input_attach(ugfx.BTN_SELECT, lambda pressed: quit(pressed)) badge.leds_init() badge.leds_enable() ugfx.set_lut(ugfx.LUT_NORMAL) ugfx.clear(ugfx.WHITE) ugfx.string(50, 50, "popcorn","Roboto_BlackItalic24", ugfx.BLACK) ugfx.flush() ugfx.input_attach(ugfx.BTN_SELECT, lambda pressed: quit(pressed)) leds_array = bytes(24) ps = 0 while True: if ps > 8: ps = 0 arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 99, 255, 255, 255] pos = ps * 4 arr[pos] = 1 r = random.randint(1,3) arr[pos - r] = 255 leds_array = bytes(arr) badge.leds_send_data(leds_array) ps = ps + 1 time.sleep(0.2) #badge.vibrator_activate(pattern)