]> git.earman.xyz Git - sensor-watch.git/commitdiff
Daylight offsets now references the timezone of the destination; but it does cause...
authorDavid Volovskiy <devolov@gmail.com>
Sun, 8 Sep 2024 11:07:44 +0000 (07:07 -0400)
committerDavid Volovskiy <devolov@gmail.com>
Sun, 8 Sep 2024 22:13:17 +0000 (18:13 -0400)
movement/watch_faces/complication/sunrise_sunset_face.c
movement/watch_faces/complication/sunrise_sunset_face.h

index 4a3c88433b83dff0f0ba362a8fc85695bcd641f6..29e6404eb943f64d3e6706b2e0d99dc55bcdeef6 100644 (file)
@@ -49,20 +49,26 @@ static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_s
     double rise, set, minutes, seconds;
     bool show_next_match = false;
     movement_location_t movement_location;
-    if (state->longLatToUse == 0 || _location_count <= 1)
+    int16_t tz;
+    if (state->longLatToUse == 0 || _location_count <= 1) {
         movement_location = (movement_location_t) watch_get_backup_data(1);
+        tz = movement_timezone_offsets[settings->bit.time_zone];
+    }
     else{
         movement_location.bit.latitude = longLatPresets[state->longLatToUse].latitude;
         movement_location.bit.longitude = longLatPresets[state->longLatToUse].longitude;
+        tz = movement_timezone_offsets[longLatPresets[state->longLatToUse].timezone];
     }
 
     if (movement_location.reg == 0) {
+        watch_clear_all_indicators();
+        watch_clear_colon();
         watch_display_string("RI  no Loc", 0);
         return;
     }
 
     watch_date_time date_time = watch_rtc_get_date_time(); // the current local date / time
-    watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, state->tz * 60, 0); // the current date / time in UTC
+    watch_date_time utc_now = watch_utility_date_time_convert_zone(date_time, tz * 60, 0); // the current date / time in UTC
     watch_date_time scratch_time; // scratchpad, contains different values at different times
     scratch_time.reg = utc_now.reg;
 
@@ -77,7 +83,7 @@ static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_s
     // sunriset returns the rise/set times as signed decimal hours in UTC.
     // this can mean hours below 0 or above 31, which won't fit into a watch_date_time struct.
     // to deal with this, we set aside the offset in hours, and add it back before converting it to a watch_date_time.
-    double hours_from_utc = ((double)state->tz) / 60.0;
+    double hours_from_utc = ((double)tz) / 60.0;
 
     // we loop twice because if it's after sunset today, we need to recalculate to display values for tomorrow.
     for(int i = 0; i < 2; i++) {
index f216a2ffd6019dd0419a03c3d4f0f87c168fddd0..429253ee53d9951a7e623ad424446aaa71dda47e 100644 (file)
@@ -76,14 +76,15 @@ typedef struct {
     char name[2];
     int16_t latitude;
     int16_t longitude;
+    int16_t timezone;  // References element in movement_timezone_offsets
 } long_lat_presets_t;
 
 static const long_lat_presets_t longLatPresets[] =
 {
     { .name = "  "},  // Default, the long and lat get replaced by what's set in the watch
-//    { .name = "Ny", .latitude = 4072, .longitude = -7401 },  // New York City, NY
-//    { .name = "LA", .latitude = 3405, .longitude = -11824 },  // Los Angeles, CA
-//    { .name = "dE", .latitude = 4221, .longitude = -8305 },  // Detroit, MI
+    { .name = "Ny", .latitude = 4072, .longitude = -7401, .timezone = 35 },  // New York City, NY
+    { .name = "LA", .latitude = 3405, .longitude = -11824, .timezone = 30 },  // Los Angeles, CA
+    { .name = "dE", .latitude = 4221, .longitude = -8305, .timezone = 35 },  // Detroit, MI
 };
 
 #endif // SUNRISE_SUNSET_FACE_H_