Toggle Navigation
Hatchery
Eggs
Flashlight CZ
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
### Sebastius ### Left/Right: Brightness ### Up/Down: Red or White (Red saves your eyesight at night) ### Todo: alert lights (blinking) import rgb import buttons, defines # colors colors = [ # white (255, 255, 255), (255, 0, 0), ] color = 0 direction = 0 brightness = rgb.getbrightness() rgb.clear() UP, DOWN, LEFT, RIGHT = defines.BTN_UP, defines.BTN_DOWN, defines.BTN_LEFT, defines.BTN_RIGHT A, B = defines.BTN_A, defines.BTN_B def input_up(pressed): global color if pressed: color = (color + 1) % (len(colors)) rgb.background(colors[color]) def input_down(pressed): global color if pressed: color = (color - 1) % (len(colors)) rgb.background(colors[color]) def input_left(pressed): global brightness if pressed and brightness > 3: brightness=brightness-1 rgb.brightness(brightness) print(brightness) def input_right(pressed): global brightness if pressed and brightness < 32: brightness=brightness+1 rgb.brightness(brightness) print(brightness) def input_A(pressed): pass buttons.register(UP, input_up) buttons.register(DOWN, input_down) buttons.register(LEFT, input_left) buttons.register(RIGHT, input_right) buttons.register(A, input_A) rgb.brightness(brightness) rgb.background(colors[color])