Toggle Navigation
Hatchery
Eggs
Kirbydance
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import leds import display import color import light_sensor import buttons import utime pink = color.from_hex(0xff1493) led_on = True led_switch = 0 led_pattern = [[0, 2, 4, 6, 8, 10, 12], [1, 3, 5, 7, 9, 11, 13]] kirby_moves = ["(>'-')>", "<('-'<)", "^('-')^", "v('-')v", "(>'-')>", " (^-^) "] light_sensor.start() while True: # press button to disable LEDs pressed = buttons.read(buttons.BOTTOM_LEFT | buttons.BOTTOM_RIGHT) if pressed: led_on = not led_on # get ambient light to decide which colors to draw reading = light_sensor.get_reading() with display.open() as disp: for dancemove in kirby_moves: # dark background and LEDs for dark ambient light if reading <= 100: disp.clear(col=color.BLACK) disp.print(dancemove, fg=pink, bg=color.BLACK, posx=80 - round(7/2 * 14), posy=30) leds.dim_top(2) leds.dim_bottom(2) # brighter background and LEDs for bright ambient light else: disp.clear(col=pink) disp.print(dancemove, fg=color.WHITE, bg=pink, posx=80 - round(7/2 * 14), posy=30) leds.dim_top(8) leds.dim_bottom(8) # draw stuff disp.update() # disable last pattern for led in led_pattern[led_switch]: leds.set(led, color.BLACK) # enable LEDs if led_on: led_switch = (led_switch + 1) % 2 for led in led_pattern[led_switch]: leds.set(led, color.MAGENTA) # sleep, because Kirby is tired at this point utime.sleep(0.5) disp.close()