Stopwatch and countdown timer for card10
If variables.json is present, you can switch the app or shutdown your card10 without loosing your timer data, but the app needs to be running to execute the alarm. If variables.json is deleted, the app won't write data to flash and runs a little smoother (if the file is empty, the app will fill it, so you can recreate it easily).
The counters are based on the system time, so changing it will result in also changing the timers. So be sure to start your timer after setting the correct system time (or don't change it until your $pizza is done).
Picture of Card10 running the app: https://twitter.com/Pixtxa/status/1196956950958952458
If alarm is active, you can set the clock back to 00:00 with one of the bottom buttons, START/STOP will reuse the time displayed in bottom right corner.
If you want to switch automatically to your Timer, include the following lines to your app's startup:
import os import ujson import utime SWITCHTOTIMER = 0 if 'timer' in os.listdir('/apps'): if 'variables.json' in os.listdir('/apps/timer'): f = open('/apps/timer/variables.json', 'r') try: variables = ujson.loads(f.read()) if "mode" and "runstamp" in variables: if variables["mode"] == 1: SWITCHTOTIMER = variables["runstamp"] except: pass f.close()
And also include this two lines somwhere in the main while-loop:
if SWITCHTOTIMER > 0 and SWITCHTOTIMER <= utime.time_ms()+3000: os.exec("apps/timer/__init__.py")
The +3000 mean switching 3 seconds (=3000 ms) before alarm goes off, so you can see the countdown.
Project is based on https://badge.team/projects/watch which was based on https://github.com/Ferdi265/card10-digiclk and somebody named lortas made the battery rendering code or so. And some other projects and https://firmware.card10.badge.events.ccc.de/ helped also.
Thanks to the card10 and hatchery team and all others for making this possible and all the nice people I've met at CCCamp2019.
Pixtxa is not good at programming, so the code isn't nice and bugs may be included. Testing before release was done in under 5 minutes, so, yeah, I hope it works...
|No votes yet :(|