summaryrefslogtreecommitdiffstats
path: root/main/day-night-percent.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/day-night-percent.patch')
-rw-r--r--main/day-night-percent.patch73
1 files changed, 73 insertions, 0 deletions
diff --git a/main/day-night-percent.patch b/main/day-night-percent.patch
new file mode 100644
index 0000000..5593cd6
--- /dev/null
+++ b/main/day-night-percent.patch
@@ -0,0 +1,73 @@
+diff --git a/movement/watch_faces/clock/day_night_percentage_face.c b/movement/watch_faces/clock/day_night_percentage_face.c
+index 86f07f9..76265ff 100644
+--- a/movement/watch_faces/clock/day_night_percentage_face.c
++++ b/movement/watch_faces/clock/day_night_percentage_face.c
+@@ -53,6 +53,7 @@ static void recalculate(watch_date_time utc_now, day_night_percentage_state_t *s
+ state->daylen = day_length(utc_now.unit.year + WATCH_RTC_REFERENCE_YEAR, utc_now.unit.month, utc_now.unit.day, lon, lat);
+
+ state->result = sun_rise_set(utc_now.unit.year + WATCH_RTC_REFERENCE_YEAR, utc_now.unit.month, utc_now.unit.day, lon, lat, &state->rise, &state->set);
++ state->last_min = utc_now.unit.minute;
+ }
+
+ void day_night_percentage_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
+@@ -68,8 +69,10 @@ void day_night_percentage_face_setup(movement_settings_t *settings, uint8_t watc
+ }
+
+ void day_night_percentage_face_activate(movement_settings_t *settings, void *context) {
++ day_night_percentage_state_t *state = (day_night_percentage_state_t *)context;
+ (void) settings;
+- (void) context;
++
++ state->last_min=-1;
+ }
+
+ bool day_night_percentage_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
+@@ -83,7 +86,8 @@ bool day_night_percentage_face_loop(movement_event_t event, movement_settings_t
+ case EVENT_ACTIVATE:
+ case EVENT_TICK:
+ case EVENT_LOW_ENERGY_UPDATE:
+- if ((utc_now.unit.hour == 0 && utc_now.unit.minute == 0 && utc_now.unit.second == 0) || state->result == -2) {
++ if ((utc_now.unit.hour == 0 && utc_now.unit.minute == 0 && utc_now.unit.second == 0) || (state->result == -2) || (state->last_min
++!= utc_now.unit.minute)) {
+ recalculate(utc_now, state);
+ }
+
+@@ -106,6 +110,7 @@ bool day_night_percentage_face_loop(movement_event_t event, movement_settings_t
+
+ double day_percentage = (24.0 - better_fmod(state->rise - day_hours_decimal, 24.0)) / state->daylen;
+ double night_percentage = (24.0 - better_fmod(state->set - day_hours_decimal, 24.0)) / (24 - state->daylen);
++ bool day = true;
+
+ uint16_t percentage;
+ if (day_percentage > 0.0 && day_percentage < 1.0) {
+@@ -113,13 +118,15 @@ bool day_night_percentage_face_loop(movement_event_t event, movement_settings_t
+ watch_clear_indicator(WATCH_INDICATOR_PM);
+ } else {
+ percentage = night_percentage * 10000;
+- watch_set_indicator(WATCH_INDICATOR_PM);
++ //watch_set_indicator(WATCH_INDICATOR_PM);
++ watch_clear_indicator(WATCH_INDICATOR_PM);
++ day = false;
+ }
+ if (event.event_type == EVENT_LOW_ENERGY_UPDATE) {
+ if (!watch_tick_animation_is_running()) watch_start_tick_animation(500);
+- sprintf(buf, "%s%2d %02d ", weekday, date_time.unit.day, percentage / 100);
++ sprintf(buf, "%s%2d%s%02d ", weekday, date_time.unit.day, day ? " d":"ni", percentage / 100);
+ } else {
+- sprintf(buf, "%s%2d %04d", weekday, date_time.unit.day, percentage);
++ sprintf(buf, "%s%2d%s%04d", weekday, date_time.unit.day, day ? " d":"ni", percentage);
+ }
+ watch_display_string(buf, 0);
+ }
+diff --git a/movement/watch_faces/clock/day_night_percentage_face.h b/movement/watch_faces/clock/day_night_percentage_face.h
+index d172c74..f6d9a54 100644
+--- a/movement/watch_faces/clock/day_night_percentage_face.h
++++ b/movement/watch_faces/clock/day_night_percentage_face.h
+@@ -44,6 +44,7 @@
+
+ typedef struct {
+ int result; // -1, 0, 1: result from sun_rise_set, -2: no location set
++ int8_t last_min;
+ double rise;
+ double set;
+ double daylen;