From c24f69450fd40472c4f6cebb790a56c3f0d69cb6 Mon Sep 17 00:00:00 2001 From: David Volovskiy Date: Sat, 5 Jul 2025 16:20:19 -0400 Subject: [PATCH] Added default location --- movement.c | 16 ++++++++++++++++ movement_config.h | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/movement.c b/movement.c index 55e4d87a..a6f037ff 100644 --- a/movement.c +++ b/movement.c @@ -203,6 +203,15 @@ static void _movement_handle_scheduled_tasks(void) { } } +static void movement_set_location_to_filesystem(movement_location_t new_location) { + movement_location_t maybe_location = {0}; + + filesystem_read_file("location.u32", (char *) &maybe_location.reg, sizeof(movement_location_t)); + if (new_location.reg != maybe_location.reg) { + filesystem_write_file("location.u32", (char *) &new_location.reg, sizeof(movement_location_t)); + } +} + void movement_request_tick_frequency(uint8_t freq) { // Movement uses the 128 Hz tick internally if (freq == 128) return; @@ -661,6 +670,13 @@ void app_init(void) { #endif movement_state.settings.bit.led_duration = MOVEMENT_DEFAULT_LED_DURATION; +#if defined(MOVEMENT_DEFAULT_LATITUDE) && defined(MOVEMENT_DEFAULT_LONGITUDE) + movement_set_location_to_filesystem((movement_location_t){ + .bit.latitude = MOVEMENT_DEFAULT_LATITUDE, + .bit.longitude = MOVEMENT_DEFAULT_LONGITUDE + }); +#endif + movement_store_settings(); } diff --git a/movement_config.h b/movement_config.h index 0da8da43..5f1784c0 100644 --- a/movement_config.h +++ b/movement_config.h @@ -100,4 +100,10 @@ const watch_face_t watch_faces[] = { */ #define MOVEMENT_DEFAULT_LED_DURATION 1 +/* The latitude and longitude used for the wearers location + * Set signed values in 1/100ths of a degree + */ +#define MOVEMENT_DEFAULT_LATITUDE 0 +#define MOVEMENT_DEFAULT_LONGITUDE 0 + #endif // MOVEMENT_CONFIG_H_