Toggle Navigation
Hatchery
Eggs
Planet A — The Tragedy of the CO₂mmons
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
""" companion app for Planet A The Tragedy of the CO2mmons https://events.ccc.de/camp/2019/wiki/Projects:Planet_A_%E2%80%94_The_Tragedy_of_the_CO%E2%82%82mmons by Lorphos """ import utime import light_sensor import display import color import leds def render_led(): colr = ( color.from_hsv(40,1,0.7), color.from_hsv(200, 1, 0.7), 600, [ 180, 180, 180 ], [ 0, 0, 0 ], 200, color.from_hsv(200, 1, 0.7), color.from_hsv(40,1,0.7), 600, [ 0, 0, 0 ], [ 180, 180, 180 ], 200); j = 0 while True: # set left half of LEDs for i in range(5): leds.prep(i, colr[j]) j = (j+1) % len(colr) # set right half of LEDs for i in range(5): leds.prep(i+5, colr[j]) j = (j+1) % len(colr) brightness = light_sensor.get_reading() dimness = 1+ int(brightness / 270); if dimness > 8: dimness = 8 leds.dim_top(dimness) leds.update() utime.sleep_ms(colr[j]) j = (j+1) % len(colr) with display.open() as d: d.clear() d.print("Find other traders with this app") d.update() d.close() utime.sleep(2) with display.open() as d: d.clear() d.print("Planet A -") d.print("The tragedy of the CO mmons", posy=22, fg=color.CHAOSBLUE_DARK) d.print("2", posy=(2*22)+3, posx=140, fg=color.CHAOSBLUE) d.update() d.close() render_led() # eof