MCH2022 badge?
go to mch2022.badge.team

Timer rev. 1 (by Pixtxa)

Timer

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

Display

  • Top: MIN:SEC
  • Left: clock time
  • Right: DAYS+HOURS (Stopwatch) or the countdown time that you have set
  • Bottom: Bar from start-time to 00:00 (only in timer mode) + battery info
  • Colors:
    • Blue: Stopwatch mode
    • Green: Timer mode
    • Yellow: Alarm mode (blinking stopwatch when timer reached 00:00, automatically deactivates after 99:59 minutes)

Controls

  • BOTTOM_LEFT: MIN+1
  • BOTTOM_RIGHT: SEC+1
  • TOP_RIGHT: START/STOP (long press to switch back to your main app)
  • BOTTOM_LEFT + BOTTOM_RIGHT: RESET

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.

Auto switch app

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...

Category: utility
Status: working
Vote Comment Date
No votes yet :(
Compatibility
  • card10: working
Dependencies
  • No dependencies found
Dependants Author: Pixtxa

File Last edited Size
__init__.py 2019-11-20 01:46:05 14.39 KiB
README.md 2019-11-20 14:34:25 2.82 KiB
variables.json 2019-11-20 01:46:05 75 B
icon.py 2019-11-20 14:25:31 780 B