Toggle Navigation
Hatchery
Eggs
Pystyy vetää?
pystyy_vetaa.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
pystyy_vetaa.py
raw
Content
""" Personal State Script =========== With this script you can """ import buttons import color import display import os import personal_state import leds def button_events(): """Iterate over button presses (event-loop).""" yield 0 button_pressed = False while True: v = buttons.read(buttons.BOTTOM_LEFT | buttons.BOTTOM_RIGHT | buttons.TOP_RIGHT) if v == 0: button_pressed = False if not button_pressed and v & buttons.BOTTOM_LEFT != 0: button_pressed = True yield buttons.BOTTOM_LEFT if not button_pressed and v & buttons.BOTTOM_RIGHT != 0: button_pressed = True yield buttons.BOTTOM_RIGHT if not button_pressed and v & buttons.TOP_RIGHT != 0: button_pressed = True yield buttons.TOP_RIGHT def main(): disp = display.open() color_white = [255,255,255] color_red = [255,0,0] color_green = [102, 128, 0] leds.gay() prev_btn = -1 for ev in button_events(): prev_btn = -1 if ev == buttons.BOTTOM_RIGHT: disp.clear() disp.print("KIKKELIS", posy=20, fg=color_red) disp.print("KOKKELIS", posy=40, posx=50, fg=color_red) disp.update() elif ev == buttons.BOTTOM_LEFT: disp.clear() disp.print("KYRVAT", posy=20, fg=color_green) disp.print("RYTTYYN", posy=40, posx=60, fg=color_green) disp.update() elif ev == buttons.TOP_RIGHT and ev == prev_btn: # Select & start disp.clear().update() disp.close() os.exit(0) else: disp.clear() disp.print("Pystyy", posy=10, fg=color_white) disp.print("vetaa?", posy=30, posx=55, fg=color_white) disp.print("YaY", posy=60, fg=color_green) disp.print("NaY", posy=60, posx=113, fg=color_red) disp.update() if __name__ == "__main__": main()