Toggle Navigation
Hatchery
Eggs
Dumb Pad
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import keypad, display display.drawFill(0x000000) display.flush() def on_key(key_index, pressed): global selectedX, selectedY, selectedKeys, singleMode x, y = key_index % 4, int(key_index / 4) currentKeySelected = False if (singleMode): if (x == selectedX and y == selectedY): currentKeySelected = True else: if (key_index in selectedKeys): currentKeySelected = True if (pressed and currentKeySelected): print('Cleared', key_index) display.flush() if (singleMode): selectedX = -1 selectedY = -1 else: selectedKeys.remove(key_index) display.drawPixel(x, y, 0x000000) display.flush() return if pressed: print('Pressed', key_index) if (singleMode): display.drawFill(0x000000) selectedX = x selectedY = y else: selectedKeys.add(key_index) display.drawPixel(x, y, 0xF8B700) display.flush() elif (currentKeySelected): print('Released', key_index) keypad.add_handler(on_key) selectedX = -1 selectedY = -1 selectedKeys = set() singleMode = True