Toggle Navigation
Hatchery
Eggs
oldfirmware-starttimer
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import ugfx, time def reset(): # Clear e-ink, display __ : __ ugfx.clear(ugfx.WHITE) ugfx.display_image(0, 0, "/lib/oldfirmware_starttimer/dots.png") def digit(place, num): x = place * 64 # each number is 64px wide if (place > 1): # after first two add aditional 40px for : x += 40 ugfx.display_image(x, 0, "/lib/oldfirmware_starttimer/"+str(num)+".png") def display(num): # takes num in seconds minutes = num // 60 seconds = num % 60 digit(0, minutes//10) digit(1, minutes%10) digit(2, seconds//10) digit(3, num%10) ugfx.flush() def loop(): duration = 10 * 60 * 1000 # 10 minutes # microcontroller is ~2 seconds too fast over 10 minutes duration -= 2 # Fully clear e-ink ugfx.clear(ugfx.WHITE) ugfx.set_lut(ugfx.LUT_FULL) ugfx.flush() ugfx.set_lut(ugfx.LUT_NORMAL) reset() start = time.ticks_ms() while time.ticks_diff(time.ticks_ms(), start) < duration: display((duration - time.ticks_diff(time.ticks_ms(), start))//1000) # finished ugfx.clear(ugfx.BLACK) ugfx.flush() while True: loop()