"""Script to reset time on CardIO via serial, run on HOST computer

inspired by: https://badge.team/projects/suckless_flash

metadata.json = 
{"name":"set time serial","description":"Script to reset time on Card10 via USB-C using the serial console, run on HOST computer.\r\n\r\nInstructions:\r\n  1. connect watch to computer  via USB C\r\n  2. Run script\r\n  3. That's it \r\n\r\nTested on Python 2.7 and Python 3.7\r\n\r\ninspired by: https:\/\/badge.team\/projects\/suckless_flash\r\n\r\n\r\nContribute: https:\/\/gitlab.com\/olethanh\/card10-set-time-serial","category":"utility","author":"staz","revision":2}
"""

from __future__ import print_function
import sys, time

dev=open("/dev/ttyACM0", "w")
print(chr(0x03), end="", file=dev)
cmd = "import utime; utime.set_unix_time({})\r"
print(cmd.format(int(time.time())), file=dev)
print(chr(0x04), end="", file=dev)
dev.close()
