diff --git a/movement.c b/movement.c index a6492c9a..773a3742 100644 --- a/movement.c +++ b/movement.c @@ -434,6 +434,14 @@ void movement_set_button_should_sound(bool value) { movement_state.settings.bit.button_should_sound = value; } +watch_buzzer_volume_t movement_button_volume(void) { + return movement_state.settings.bit.button_volume; +} + +void movement_set_button_volume(watch_buzzer_volume_t value) { + movement_state.settings.bit.button_volume = value; +} + movement_clock_mode_t movement_clock_mode_24h(void) { return movement_state.settings.bit.clock_mode_24h ? MOVEMENT_CLOCK_MODE_24H : MOVEMENT_CLOCK_MODE_12H; } @@ -609,6 +617,7 @@ void app_init(void) { movement_state.settings.bit.led_blue_color = MOVEMENT_DEFAULT_BLUE_COLOR; #endif movement_state.settings.bit.button_should_sound = MOVEMENT_DEFAULT_BUTTON_SOUND; + movement_state.settings.bit.button_volume = MOVEMENT_DEFAULT_BUTTON_VOLUME; movement_state.settings.bit.to_interval = MOVEMENT_DEFAULT_TIMEOUT_INTERVAL; movement_state.settings.bit.le_interval = MOVEMENT_DEFAULT_LOW_ENERGY_INTERVAL; movement_state.settings.bit.led_duration = MOVEMENT_DEFAULT_LED_DURATION; @@ -767,7 +776,7 @@ bool app_loop(void) { if (movement_state.watch_face_changed) { if (movement_state.settings.bit.button_should_sound) { // low note for nonzero case, high note for return to watch_face 0 - watch_buzzer_play_note_with_volume(movement_state.next_face_idx ? BUZZER_NOTE_C7 : BUZZER_NOTE_C8, 50, WATCH_BUZZER_VOLUME_SOFT); + watch_buzzer_play_note_with_volume(movement_state.next_face_idx ? BUZZER_NOTE_C7 : BUZZER_NOTE_C8, 50, movement_state.settings.bit.button_volume); } wf->resign(watch_face_contexts[movement_state.current_face_idx]); movement_state.current_face_idx = movement_state.next_face_idx; diff --git a/movement.h b/movement.h index 817c2841..5626385a 100644 --- a/movement.h +++ b/movement.h @@ -83,8 +83,7 @@ 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. - // That's 31 bits, leaving room for one more toggle if needed. - uint8_t reserved : 1; + bool button_volume : 1; // 0 for soft beep, 1 for loud beep. If button_should_sound (above) is false, this is ignored. } bit; uint32_t reg; } movement_settings_t; @@ -341,6 +340,9 @@ void movement_set_local_date_time(watch_date_time_t date_time); bool movement_button_should_sound(void); void movement_set_button_should_sound(bool value); +watch_buzzer_volume_t movement_button_volume(void); +void movement_set_button_volume(watch_buzzer_volume_t value); + movement_clock_mode_t movement_clock_mode_24h(void); void movement_set_clock_mode_24h(movement_clock_mode_t value); diff --git a/movement_config.h b/movement_config.h index a3578ff1..6a960b82 100644 --- a/movement_config.h +++ b/movement_config.h @@ -66,6 +66,8 @@ const watch_face_t watch_faces[] = { /* Enable or disable the sound on mode button press */ #define MOVEMENT_DEFAULT_BUTTON_SOUND true +#define MOVEMENT_DEFAULT_BUTTON_VOLUME WATCH_BUZZER_VOLUME_SOFT + /* Set the timeout before switching back to the main watch face * Valid values are: * 0: 60 seconds diff --git a/watch-faces/complication/countdown_face.c b/watch-faces/complication/countdown_face.c index 5314acea..19de57e0 100644 --- a/watch-faces/complication/countdown_face.c +++ b/watch-faces/complication/countdown_face.c @@ -67,7 +67,7 @@ static inline void load_countdown(countdown_state_t *state) { static inline void button_beep() { // play a beep as confirmation for a button press (if applicable) - if (movement_button_should_sound()) watch_buzzer_play_note_with_volume(BUZZER_NOTE_C7, 50, WATCH_BUZZER_VOLUME_SOFT); + if (movement_button_should_sound()) watch_buzzer_play_note_with_volume(BUZZER_NOTE_C7, 50, movement_button_volume()); } static void schedule_countdown(countdown_state_t *state) { diff --git a/watch-faces/complication/fast_stopwatch_face.c b/watch-faces/complication/fast_stopwatch_face.c index 4ee8ca65..ce998102 100644 --- a/watch-faces/complication/fast_stopwatch_face.c +++ b/watch-faces/complication/fast_stopwatch_face.c @@ -121,7 +121,7 @@ void irq_handler_tc1(void) { static inline void _button_beep() { // play a beep as confirmation for a button press (if applicable) - if (movement_button_should_sound()) watch_buzzer_play_note_with_volume(BUZZER_NOTE_C7, 50, WATCH_BUZZER_VOLUME_SOFT); + if (movement_button_should_sound()) watch_buzzer_play_note_with_volume(BUZZER_NOTE_C7, 50, movement_button_volume()); } /// @brief Display minutes, seconds and fractions derived from 128 Hz tick counter diff --git a/watch-faces/complication/stopwatch_face.c b/watch-faces/complication/stopwatch_face.c index 4a2bfcf9..e7e5ebb1 100644 --- a/watch-faces/complication/stopwatch_face.c +++ b/watch-faces/complication/stopwatch_face.c @@ -118,7 +118,7 @@ bool stopwatch_face_loop(movement_event_t event, void *context) { break; case EVENT_ALARM_BUTTON_DOWN: if (movement_button_should_sound()) { - watch_buzzer_play_note_with_volume(BUZZER_NOTE_C7, 50, WATCH_BUZZER_VOLUME_SOFT); + watch_buzzer_play_note_with_volume(BUZZER_NOTE_C7, 50, movement_button_volume()); } stopwatch_state->running = !stopwatch_state->running; if (stopwatch_state->running) { diff --git a/watch-faces/settings/settings_face.c b/watch-faces/settings/settings_face.c index c39aec0f..7d1b392c 100644 --- a/watch-faces/settings/settings_face.c +++ b/watch-faces/settings/settings_face.c @@ -42,16 +42,39 @@ static void beep_setting_display(uint8_t subsecond) { watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "BTN", "BT"); watch_display_text_with_fallback(WATCH_POSITION_BOTTOM, "beep ", " beep "); if (subsecond % 2) { - if (movement_button_should_sound()) { - watch_display_text(WATCH_POSITION_TOP_RIGHT, " Y"); + if (movement_button_should_sound()) { + if (movement_button_volume() == WATCH_BUZZER_VOLUME_LOUD) { + // H for HIGH + watch_display_text(WATCH_POSITION_TOP_RIGHT, " H"); + } + else { + // L for LOW + watch_display_text(WATCH_POSITION_TOP_RIGHT, " L"); + } } else { + // N for NONE watch_display_text(WATCH_POSITION_TOP_RIGHT, " N"); } } } static void beep_setting_advance(void) { - movement_set_button_should_sound(!movement_button_should_sound()); + if (!movement_button_should_sound()) { + // was muted. make it soft. + movement_set_button_should_sound(true); + movement_set_button_volume(WATCH_BUZZER_VOLUME_SOFT); + beep_setting_display(1); + watch_buzzer_play_note_with_volume(BUZZER_NOTE_C7, 50, WATCH_BUZZER_VOLUME_SOFT); + } else if (movement_button_volume() == WATCH_BUZZER_VOLUME_SOFT) { + // was soft. make it loud. + movement_set_button_volume(WATCH_BUZZER_VOLUME_LOUD); + beep_setting_display(1); + watch_buzzer_play_note_with_volume(BUZZER_NOTE_C7, 50, WATCH_BUZZER_VOLUME_LOUD); + } else { + // was loud. make it silent. + movement_set_button_should_sound(false); + beep_setting_display(1); + } } static void timeout_setting_display(uint8_t subsecond) {