Toggle Navigation
Hatchery
Eggs
Flash2
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import color, leds, buttons, display def display_off(): with display.open() as disp: disp.clear() disp.print("Flashlight", fg=color.WHITE, bg=color.BLACK, posx=10, posy=10) disp.print("ON", fg=color.WHITE, bg=color.BLACK, posx=10, posy=50) disp.print("OFF", fg=color.WHITE, bg=color.BLACK, posx=110, posy=50) disp.update() disp.close() def display_on(): with display.open() as disp: disp.clear(col=color.WHITE) disp.print("Flashlight", fg=color.BLACK, bg=color.WHITE, posx=10, posy=10) disp.print("ON", fg=color.BLACK, bg=color.WHITE, posx=10, posy=50) disp.print("OFF", fg=color.BLACK, bg=color.WHITE, posx=110, posy=50) disp.update() disp.close() display_off() while True: pressed = buttons.read( buttons.BOTTOM_LEFT | buttons.BOTTOM_RIGHT ) if pressed & buttons.BOTTOM_LEFT != 0: leds.set_all([color.WHITE] * 15) leds.dim_top(8) display_on() if pressed & buttons.BOTTOM_RIGHT != 0: leds.set_all([color.BLACK] * 15) display_off()