Toggle Navigation
Hatchery
Eggs
simple flashlight
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import display import leds import buttons import os class Flashlight: def loop(self): try: with display.open() as disp: disp.clear() disp.print(' >>light>> ', posy=30) disp.update() disp.close() button_pressed = False status = False while True: # check for button presses v = buttons.read(buttons.BOTTOM_LEFT | buttons.BOTTOM_RIGHT | buttons.TOP_RIGHT) if v == 0: button_pressed = False if not button_pressed and v != 0: button_pressed = True status = not status leds.set_flashlight(status) except KeyboardInterrupt: leds.set_flashlight(False) return flashlight = Flashlight() flashlight.loop()