]> git.earman.xyz Git - sensor-watch.git/commitdiff
set year to 2024 at boot
authorjoeycastillo <joeycastillo@utexas.edu>
Sun, 22 Sep 2024 18:24:43 +0000 (14:24 -0400)
committerjoeycastillo <joeycastillo@utexas.edu>
Sun, 22 Sep 2024 18:24:43 +0000 (14:24 -0400)
movement.c

index 3f0c1c595df1d96fd86f6432b7096237d9e951c4..0e505b497c109db02ded433da078567c2c76c285 100644 (file)
@@ -391,6 +391,13 @@ uint8_t movement_claim_backup_register(void) {
 void app_init(void) {
     _watch_init();
 
+    watch_date_time date_time = watch_rtc_get_date_time();
+    if (date_time.reg == 0) {
+        // at first boot, set year to 2024
+        date_time.unit.year = 2024 - WATCH_RTC_REFERENCE_YEAR;
+        watch_rtc_set_date_time(date_time);
+    }
+
     // check if we are plugged into USB power.
     HAL_GPIO_VBUS_DET_in();
     HAL_GPIO_VBUS_DET_pulldown();