Toggle Navigation
Hatchery
Eggs
card10 Flashlight with red mode
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import color import leds import buttons import display with display.open() as disp: disp.clear() disp.print("Flashlight", fg=color.WHITE, bg=color.BLACK, posx=10, posy=2) disp.print("Red Mode ON", fg=color.RED, bg=color.BLACK, posx=1, posy=50) disp.print("ON", fg=color.WHITE, bg=color.BLACK, posx=10, posy=65) disp.print("OFF", fg=color.WHITE, bg=color.BLACK, posx=110, posy=65) disp.update() disp.close() while True: pressed = buttons.read( buttons.BOTTOM_LEFT | buttons.BOTTOM_RIGHT | buttons.TOP_RIGHT ) if pressed & buttons.TOP_RIGHT != 0: leds.set_all([color.RED] * 11) leds.dim_top(8) if pressed & buttons.BOTTOM_LEFT != 0: leds.set_all([color.WHITE] * 11) leds.dim_top(8) if pressed & buttons.BOTTOM_RIGHT != 0: leds.clear() leds.set_powersave(eco=True)