From ba76e720f78dca141d66964fa71b8ea42bfa5ad7 Mon Sep 17 00:00:00 2001 From: mrbrown8 Date: Thu, 7 Mar 2024 12:04:07 -0700 Subject: [PATCH 01/11] Update movement.h new field to track weekday language preference --- movement/movement.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/movement/movement.h b/movement/movement.h index 1dabfbc5b..69d9dcaa9 100644 --- a/movement/movement.h +++ b/movement/movement.h @@ -62,7 +62,8 @@ typedef union { bool clock_mode_24h : 1; // indicates whether clock should use 12 or 24 hour mode. bool use_imperial_units : 1; // indicates whether to use metric units (the default) or imperial. bool alarm_enabled : 1; // indicates whether there is at least one alarm enabled. - uint8_t reserved : 6; // room for more preferences if needed. + uint8_t lang_preference : 2 ; // which language should weekday names be displayed as, see watch_utility_get_weekday(); 2bits == 4 choices + uint8_t reserved : 4; // room for more preferences if needed. } bit; uint32_t reg; } movement_settings_t; From 989c8e9afa12169a8a9b1645e37ebdfc42251f38 Mon Sep 17 00:00:00 2001 From: mrbrown8 Date: Thu, 7 Mar 2024 12:10:40 -0700 Subject: [PATCH 02/11] Update preferences_face.c adding language preference to settings face --- .../watch_faces/settings/preferences_face.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/movement/watch_faces/settings/preferences_face.c b/movement/watch_faces/settings/preferences_face.c index c96e8d1fd..318a83178 100644 --- a/movement/watch_faces/settings/preferences_face.c +++ b/movement/watch_faces/settings/preferences_face.c @@ -39,6 +39,7 @@ const char preferences_face_titles[PREFERENCES_FACE_NUM_PREFEFENCES][11] = { "LT grn ", // Light: green component #endif "LT red ", // Light: red component + " ", // Language of weekday names, title changes based on selection }; void preferences_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) { @@ -91,6 +92,10 @@ bool preferences_face_loop(movement_event_t event, movement_settings_t *settings case 6: settings->bit.led_red_color = settings->bit.led_red_color + 1; break; + case 7: + settings->bit.lang_preference = settings->bit.lang_preference + 1; + watch_store_backup_data(settings->reg, 0); + break; } break; case EVENT_TIMEOUT: @@ -101,6 +106,11 @@ bool preferences_face_loop(movement_event_t event, movement_settings_t *settings } watch_display_string((char *)preferences_face_titles[current_page], 0); + if (current_page == 7) { // weekday language selection + //date_time = watch_rtc_get_date_time(); + //watch_display_string( watch_utility_get_weekday(date_time), 0 ); // dynamic changing title, but shouldn't blink + watch_display_string( watch_utility_get_weekday(watch_rtc_get_date_time()), 0 ); // dynamic changing title, but shouldn't blink + } // blink active setting on even-numbered quarter-seconds if (event.subsecond % 2) { @@ -174,6 +184,22 @@ bool preferences_face_loop(movement_event_t event, movement_settings_t *settings sprintf(buf, "%2d", settings->bit.led_red_color); watch_display_string(buf, 8); break; + case 7: + switch (settings->bit.lang_preference) { // order of langs should match weekdays_dict in watch_utility.c + case 0: + watch_display_string(" En ", 4); + break; + case 1: + watch_display_string(" dE ", 4); + break; + case 2: + watch_display_string(" ES ", 4); + break; + case 3: + watch_display_string(" Fr ", 4); + break; + } + break; } } From e31e90803955283db45491c67950a38b506f6652 Mon Sep 17 00:00:00 2001 From: mrbrown8 Date: Thu, 7 Mar 2024 12:19:12 -0700 Subject: [PATCH 03/11] Update watch_utility.c add weekday language dictionary --- watch-library/shared/watch/watch_utility.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/watch-library/shared/watch/watch_utility.c b/watch-library/shared/watch/watch_utility.c index 64b3bb791..906b2f759 100644 --- a/watch-library/shared/watch/watch_utility.c +++ b/watch-library/shared/watch/watch_utility.c @@ -24,10 +24,25 @@ #include #include "watch_utility.h" +#include "movement.h" const char * watch_utility_get_weekday(watch_date_time date_time) { - static const char weekdays[7][3] = {"MO", "TU", "WE", "TH", "FR", "SA", "SU"}; - return weekdays[watch_utility_get_iso8601_weekday_number(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day) - 1]; + movement_settings_t movement_settings = (movement_settings_t) watch_get_backup_data(0); + uint8_t weekday_index; + + //static const char weekdays[7][3] = {"MO", "TU", "WE", "TH", "FR", "SA", "SU"}; + static char weekdays_dict[4][7][3] = { {"MO", "TU", "WE", "TH", "FR", "SA", "SU"} , // EN + {"MO", "DI", "MI", "DO", "FR", "SA", "DO"} , // DE + {"LU", "ME", "MI", "JU", "VI", "SA", "DO"} , // ES + {"LU", "MA", "ME", "JE", "VE", "SA", "DI"} }; // FR + char (*p_dict_row)[7][3] = weekdays_dict; // point to the first row; default is English, esp. if there's no config face + + weekday_index = watch_utility_get_iso8601_weekday_number(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day) - 1 ; + + //return weekdays[watch_utility_get_iso8601_weekday_number(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day) - 1]; + //return *( *(p_dict_row + (uint8_t)movement_settings.bit.lang_preference) + weekday_index ); + return *( *(p_dict_row + 3) + weekday_index ); // debug + } // Per ISO8601 week starts on Monday with index 1 From 102a62bd48d6976bbc283cad6f7e1fe841d4a996 Mon Sep 17 00:00:00 2001 From: mrbrown8 Date: Thu, 7 Mar 2024 12:21:21 -0700 Subject: [PATCH 04/11] Update watch_utility.h until I can figure out how to make it const again --- watch-library/shared/watch/watch_utility.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/watch-library/shared/watch/watch_utility.h b/watch-library/shared/watch/watch_utility.h index e2326d131..c7ecf9fb8 100644 --- a/watch-library/shared/watch/watch_utility.h +++ b/watch-library/shared/watch/watch_utility.h @@ -49,7 +49,7 @@ typedef struct { * in positions 0-1 of the watch face * @param date_time The watch_date_time whose weekday you want. */ -const char * watch_utility_get_weekday(watch_date_time date_time); +char * watch_utility_get_weekday(watch_date_time date_time); /** @brief Returns a number between 1-7 representing the weekday according to ISO8601 : week starts on Monday and has index 1, Sunday has index 7 * @param year The year of the date From f0c97ee37a4867be6b80bb9a05cb27e88bf2a060 Mon Sep 17 00:00:00 2001 From: mrbrown8 Date: Fri, 8 Mar 2024 22:39:14 -0700 Subject: [PATCH 05/11] Update watch_utility.c correcting abbreviation for German Sunday --- watch-library/shared/watch/watch_utility.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/watch-library/shared/watch/watch_utility.c b/watch-library/shared/watch/watch_utility.c index 906b2f759..820b8f428 100644 --- a/watch-library/shared/watch/watch_utility.c +++ b/watch-library/shared/watch/watch_utility.c @@ -32,7 +32,7 @@ const char * watch_utility_get_weekday(watch_date_time date_time) { //static const char weekdays[7][3] = {"MO", "TU", "WE", "TH", "FR", "SA", "SU"}; static char weekdays_dict[4][7][3] = { {"MO", "TU", "WE", "TH", "FR", "SA", "SU"} , // EN - {"MO", "DI", "MI", "DO", "FR", "SA", "DO"} , // DE + {"MO", "DI", "MI", "DO", "FR", "SA", "SO"} , // DE {"LU", "ME", "MI", "JU", "VI", "SA", "DO"} , // ES {"LU", "MA", "ME", "JE", "VE", "SA", "DI"} }; // FR char (*p_dict_row)[7][3] = weekdays_dict; // point to the first row; default is English, esp. if there's no config face From 67b0b72cd1582a425102a2970c2d980ba9085f2d Mon Sep 17 00:00:00 2001 From: mrbrown8 Date: Mon, 11 Mar 2024 15:47:41 -0600 Subject: [PATCH 06/11] Update preferences_face.c Ooops, get that extra pref in the array --- movement/watch_faces/settings/preferences_face.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/movement/watch_faces/settings/preferences_face.c b/movement/watch_faces/settings/preferences_face.c index 318a83178..f6f72da9f 100644 --- a/movement/watch_faces/settings/preferences_face.c +++ b/movement/watch_faces/settings/preferences_face.c @@ -26,7 +26,7 @@ #include "preferences_face.h" #include "watch.h" -#define PREFERENCES_FACE_NUM_PREFEFENCES (7) +#define PREFERENCES_FACE_NUM_PREFEFENCES (8) const char preferences_face_titles[PREFERENCES_FACE_NUM_PREFEFENCES][11] = { "CL ", // Clock: 12 or 24 hour "BT Beep ", // Buttons: should they beep? From 7a38d68268e65b4fdb653fc0beadf87194bb8644 Mon Sep 17 00:00:00 2001 From: mrbrown8 Date: Tue, 9 Apr 2024 16:20:47 -0600 Subject: [PATCH 07/11] Update watch_utility.c --- watch-library/shared/watch/watch_utility.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/watch-library/shared/watch/watch_utility.c b/watch-library/shared/watch/watch_utility.c index 820b8f428..0289bf8ca 100644 --- a/watch-library/shared/watch/watch_utility.c +++ b/watch-library/shared/watch/watch_utility.c @@ -27,15 +27,15 @@ #include "movement.h" const char * watch_utility_get_weekday(watch_date_time date_time) { - movement_settings_t movement_settings = (movement_settings_t) watch_get_backup_data(0); + //movement_settings_t movement_settings = (movement_settings_t) watch_get_backup_data(0); uint8_t weekday_index; //static const char weekdays[7][3] = {"MO", "TU", "WE", "TH", "FR", "SA", "SU"}; - static char weekdays_dict[4][7][3] = { {"MO", "TU", "WE", "TH", "FR", "SA", "SU"} , // EN - {"MO", "DI", "MI", "DO", "FR", "SA", "SO"} , // DE - {"LU", "ME", "MI", "JU", "VI", "SA", "DO"} , // ES - {"LU", "MA", "ME", "JE", "VE", "SA", "DI"} }; // FR - char (*p_dict_row)[7][3] = weekdays_dict; // point to the first row; default is English, esp. if there's no config face + static const char weekdays_dict[4][7][3] = { {"MO", "TU", "WE", "TH", "FR", "SA", "SU"} , // EN + {"MO", "DI", "MI", "DO", "FR", "SA", "SO"} , // DE + {"LU", "ME", "MI", "JU", "VI", "SA", "DO"} , // ES + {"LU", "MA", "ME", "JE", "VE", "SA", "DI"} }; // FR + const char (*p_dict_row)[7][3] = weekdays_dict; // point to the first row; default is English, esp. if there's no config face weekday_index = watch_utility_get_iso8601_weekday_number(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day) - 1 ; From f517cf9233c7a47f26f9b405311a117082cd5ea4 Mon Sep 17 00:00:00 2001 From: mrbrown8 Date: Tue, 9 Apr 2024 16:22:21 -0600 Subject: [PATCH 08/11] Update preferences_face.c --- movement/watch_faces/settings/preferences_face.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/movement/watch_faces/settings/preferences_face.c b/movement/watch_faces/settings/preferences_face.c index f6f72da9f..a659dc195 100644 --- a/movement/watch_faces/settings/preferences_face.c +++ b/movement/watch_faces/settings/preferences_face.c @@ -107,9 +107,11 @@ bool preferences_face_loop(movement_event_t event, movement_settings_t *settings watch_display_string((char *)preferences_face_titles[current_page], 0); if (current_page == 7) { // weekday language selection - //date_time = watch_rtc_get_date_time(); + watch_date_time date_time = watch_rtc_get_date_time(); + char *weekday_to_show = watch_utility_get_weekday(date_time); + watch_display_string( weekday_to_show, 0 ); // dynamic changing title, but shouldn't blink //watch_display_string( watch_utility_get_weekday(date_time), 0 ); // dynamic changing title, but shouldn't blink - watch_display_string( watch_utility_get_weekday(watch_rtc_get_date_time()), 0 ); // dynamic changing title, but shouldn't blink + //watch_display_string( watch_utility_get_weekday(watch_rtc_get_date_time()), 0 ); // dynamic changing title, but shouldn't blink } // blink active setting on even-numbered quarter-seconds From 09cf298773754be64adc54cb56fe34fba143a49f Mon Sep 17 00:00:00 2001 From: mrbrown8 Date: Tue, 16 Apr 2024 09:40:50 -0600 Subject: [PATCH 09/11] Update preferences_face.c LED updates only apply to certain pages --- movement/watch_faces/settings/preferences_face.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/movement/watch_faces/settings/preferences_face.c b/movement/watch_faces/settings/preferences_face.c index a659dc195..850e21db9 100644 --- a/movement/watch_faces/settings/preferences_face.c +++ b/movement/watch_faces/settings/preferences_face.c @@ -206,7 +206,7 @@ bool preferences_face_loop(movement_event_t event, movement_settings_t *settings } // on LED color select screns, preview the color. - if (current_page >= 5) { + if (current_page == 5 || current_page == 6) { watch_set_led_color(settings->bit.led_red_color ? (0xF | settings->bit.led_red_color << 4) : 0, settings->bit.led_green_color ? (0xF | settings->bit.led_green_color << 4) : 0); // return false so the watch stays awake (needed for the PWM driver to function). From aaa0f6b637d58a3346eb36abc0479878e72754e8 Mon Sep 17 00:00:00 2001 From: mrbrown8 Date: Tue, 16 Apr 2024 11:30:37 -0600 Subject: [PATCH 10/11] Update preferences_face.c need to use watch_utility_get_weekday() from watch_utility.h --- movement/watch_faces/settings/preferences_face.c | 1 + 1 file changed, 1 insertion(+) diff --git a/movement/watch_faces/settings/preferences_face.c b/movement/watch_faces/settings/preferences_face.c index 850e21db9..d00d6c978 100644 --- a/movement/watch_faces/settings/preferences_face.c +++ b/movement/watch_faces/settings/preferences_face.c @@ -24,6 +24,7 @@ #include #include "preferences_face.h" +#include "watch_utility.h" #include "watch.h" #define PREFERENCES_FACE_NUM_PREFEFENCES (8) From 720561757a18e8e2bd3ce2ec3b4f28e96a663a0b Mon Sep 17 00:00:00 2001 From: mrbrown8 Date: Fri, 19 Apr 2024 13:24:33 -0600 Subject: [PATCH 11/11] Update watch_utility.c take debug back out --- watch-library/shared/watch/watch_utility.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/watch-library/shared/watch/watch_utility.c b/watch-library/shared/watch/watch_utility.c index 0289bf8ca..7e433a9ac 100644 --- a/watch-library/shared/watch/watch_utility.c +++ b/watch-library/shared/watch/watch_utility.c @@ -40,8 +40,8 @@ const char * watch_utility_get_weekday(watch_date_time date_time) { weekday_index = watch_utility_get_iso8601_weekday_number(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day) - 1 ; //return weekdays[watch_utility_get_iso8601_weekday_number(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day) - 1]; - //return *( *(p_dict_row + (uint8_t)movement_settings.bit.lang_preference) + weekday_index ); - return *( *(p_dict_row + 3) + weekday_index ); // debug + return *( *(p_dict_row + (uint8_t)movement_settings.bit.lang_preference) + weekday_index ); + //return *( *(p_dict_row + 3) + weekday_index ); // debug }