From cf3c8fd89ee86afbf2910266a27c53d9efaf5901 Mon Sep 17 00:00:00 2001 From: Abhijeet Surakanti Date: Wed, 12 Mar 2025 15:18:25 -0400 Subject: [PATCH] feature merge commit and PR cleanup/documentation --- .../watch_faces/complication/alarm_face.c | 55 ++++++++++++++++++- .../watch_faces/complication/alarm_face.h | 17 +++++- 2 files changed, 69 insertions(+), 3 deletions(-) diff --git a/movement/watch_faces/complication/alarm_face.c b/movement/watch_faces/complication/alarm_face.c index d71ea2036..fa80e29b2 100644 --- a/movement/watch_faces/complication/alarm_face.c +++ b/movement/watch_faces/complication/alarm_face.c @@ -32,6 +32,9 @@ typedef enum { alarm_setting_idx_alarm, + #ifdef TOMATO + alarm_setting_idx_tomato, + #endif alarm_setting_idx_day, alarm_setting_idx_hour, alarm_setting_idx_minute, @@ -40,8 +43,15 @@ typedef enum { } alarm_setting_idx_t; static const char _dow_strings[ALARM_DAY_STATES + 1][2] ={"AL", "MO", "TU", "WE", "TH", "FR", "SA", "SO", "ED", "1t", "MF", "WN"}; + +#ifdef TOMATO +static const uint8_t _blink_idx[ALARM_SETTING_STATES] = {2, 2, 0, 4, 6, 8, 9}; +static const uint8_t _blink_idx2[ALARM_SETTING_STATES] = {3, 2, 1, 5, 7, 8, 9}; +#else static const uint8_t _blink_idx[ALARM_SETTING_STATES] = {2, 0, 4, 6, 8, 9}; static const uint8_t _blink_idx2[ALARM_SETTING_STATES] = {3, 1, 5, 7, 8, 9}; +#endif + static const BuzzerNote _buzzer_notes[3] = {BUZZER_NOTE_B6, BUZZER_NOTE_C8, BUZZER_NOTE_A8}; static const uint8_t _buzzer_segdata[3][2] = {{0, 3}, {1, 3}, {2, 2}}; @@ -67,10 +77,24 @@ static void _alarm_face_draw(movement_settings_t *settings, alarm_state_t *state char buf[12]; uint8_t i = 0; + bool t = false; if (state->is_setting) { // display the actual day indicating string for the current alarm i = state->alarm[state->alarm_idx].day + 1; + // the state of tomato setting for the current alarm + #ifdef TOMATO + t = state->alarm[state->alarm_idx].tomato; + #endif + } + + // enable/disable tomato indicator(LAP) only in settings mode since the true value is only set above in setting mode + // and is false by default + if (t) { + watch_set_indicator(WATCH_INDICATOR_LAP); + } else { + watch_clear_indicator(WATCH_INDICATOR_LAP); } + //handle am/pm for hour display bool set_leading_zero = false; uint8_t h = state->alarm[state->alarm_idx].hour; @@ -97,8 +121,12 @@ static void _alarm_face_draw(movement_settings_t *settings, alarm_state_t *state (state->alarm_idx + 1), h, state->alarm[state->alarm_idx].minute); - // blink items if in settings mode + // blink items if in settings mode, before pitch, and not in tomato setting(custom blink logic for this) + #ifdef TOMATO + if (state->is_setting && subsecond % 2 && state->setting_state < alarm_setting_idx_pitch && !state->alarm_quick_ticks && (state->setting_state != alarm_setting_idx_tomato)) { + #else if (state->is_setting && subsecond % 2 && state->setting_state < alarm_setting_idx_pitch && !state->alarm_quick_ticks) { + #endif buf[_blink_idx[state->setting_state]] = buf[_blink_idx2[state->setting_state]] = ' '; } watch_display_string(buf, 0); @@ -120,6 +148,17 @@ static void _alarm_face_draw(movement_settings_t *settings, alarm_state_t *state watch_display_character(state->alarm[state->alarm_idx].beeps + 48, _blink_idx[alarm_setting_idx_beeps]); } } + + // blink tomato indicator if disabled in tomato setting mode + #ifdef TOMATO + if (state->setting_state == alarm_setting_idx_tomato && !state->alarm[state->alarm_idx].tomato) { + if ((subsecond % 2) == 0) { + watch_set_indicator(WATCH_INDICATOR_LAP); + } else { + watch_clear_indicator(WATCH_INDICATOR_LAP); + } + } + #endif } // set alarm indicator @@ -294,7 +333,7 @@ bool alarm_face_loop(movement_event_t event, movement_settings_t *settings, void delay_ms(275); state->alarm_idx = 0; } - } else break; // no need to do anything when we are not in settings mode and no quick ticks are running + } else break; // no need to do anything when we are in settings mode and no quick ticks are running } // fall through case EVENT_ACTIVATE: @@ -332,6 +371,12 @@ bool alarm_face_loop(movement_event_t event, movement_settings_t *settings, void // alarm selection state->alarm_idx = (state->alarm_idx + 1) % (ALARM_ALARMS); break; + #ifdef TOMATO + case alarm_setting_idx_tomato: + // tomato toggle + state->alarm[state->alarm_idx].tomato ^= 1; + break; + #endif case alarm_setting_idx_day: // day selection state->alarm[state->alarm_idx].day = (state->alarm[state->alarm_idx].day + 1) % (ALARM_DAY_STATES); @@ -398,6 +443,12 @@ bool alarm_face_loop(movement_event_t event, movement_settings_t *settings, void } else _wait_ticks = -1; break; case EVENT_BACKGROUND_TASK: + // open tomato timer if enabled + #ifdef TOMATO + if (state->alarm[state->alarm_playing_idx].tomato) { + movement_move_to_face(TOMATO); // provided as a macro at compile time + } + #endif // play alarm if (state->alarm[state->alarm_playing_idx].beeps == 0) { // short beep diff --git a/movement/watch_faces/complication/alarm_face.h b/movement/watch_faces/complication/alarm_face.h index 1c22948e7..eb40e642d 100644 --- a/movement/watch_faces/complication/alarm_face.h +++ b/movement/watch_faces/complication/alarm_face.h @@ -52,8 +52,17 @@ * long ('L') and extra short ('o') alarms. * - The simple watch face indicates if any alarm is set within the next 24h by showing the signal * indicator. + * + * TOMATO SETTING (OPTIONAL) + * - Tomato is an additional setting(set with LAP indicator) that when enabled will open the + * tomato_face on the corresponding alarm trigger. This allows you to start your focus session. + * - Requires the tomato_face to be selected as a watch face in movement_config.h and its + * index provided in alarm_face.h(line 65) as a macro. */ +// uncomment this line and replace value with tomato watch face index(zero-indexed) +// #define TOMATO 1 + #include "movement.h" #define ALARM_ALARMS 16 // no of available alarm slots (be aware: only 4 bits reserved for this value in struct below) @@ -63,7 +72,12 @@ #define ALARM_DAY_WORKDAY 9 #define ALARM_DAY_WEEKEND 10 #define ALARM_MAX_BEEP_ROUNDS 11 // maximum number of beeping rounds for an alarm slot (including short and long alarms) -#define ALARM_SETTING_STATES 6 + +#ifdef TOMATO + #define ALARM_SETTING_STATES 7 +#else + #define ALARM_SETTING_STATES 6 +#endif typedef struct { uint8_t day : 4; // day of week: 0=MO, 1=TU, 2=WE, 3=TH, 4=FR, 5=SA, 6=SU, 7=each day, 8=one time alarm, 9=Weekdays, 10=Weekend @@ -71,6 +85,7 @@ typedef struct { uint8_t minute : 6; uint8_t beeps : 4; uint8_t pitch :2; + bool tomato: 1; bool enabled : 1; } alarm_setting_t;