movement: add loudness setting for button press

This commit is contained in:
Joey Castillo 2025-05-20 17:27:32 -04:00
parent 616bb08720
commit acdc32ffb4
7 changed files with 45 additions and 9 deletions

View File

@ -434,6 +434,14 @@ void movement_set_button_should_sound(bool value) {
movement_state.settings.bit.button_should_sound = 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) { 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; 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; movement_state.settings.bit.led_blue_color = MOVEMENT_DEFAULT_BLUE_COLOR;
#endif #endif
movement_state.settings.bit.button_should_sound = MOVEMENT_DEFAULT_BUTTON_SOUND; 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.to_interval = MOVEMENT_DEFAULT_TIMEOUT_INTERVAL;
movement_state.settings.bit.le_interval = MOVEMENT_DEFAULT_LOW_ENERGY_INTERVAL; movement_state.settings.bit.le_interval = MOVEMENT_DEFAULT_LOW_ENERGY_INTERVAL;
movement_state.settings.bit.led_duration = MOVEMENT_DEFAULT_LED_DURATION; 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.watch_face_changed) {
if (movement_state.settings.bit.button_should_sound) { if (movement_state.settings.bit.button_should_sound) {
// low note for nonzero case, high note for return to watch_face 0 // 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]); wf->resign(watch_face_contexts[movement_state.current_face_idx]);
movement_state.current_face_idx = movement_state.next_face_idx; movement_state.current_face_idx = movement_state.next_face_idx;

View File

@ -83,8 +83,7 @@ typedef union {
bool clock_mode_24h : 1; // indicates whether clock should use 12 or 24 hour mode. 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 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. bool button_volume : 1; // 0 for soft beep, 1 for loud beep. If button_should_sound (above) is false, this is ignored.
uint8_t reserved : 1;
} bit; } bit;
uint32_t reg; uint32_t reg;
} movement_settings_t; } 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); bool movement_button_should_sound(void);
void movement_set_button_should_sound(bool value); 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); movement_clock_mode_t movement_clock_mode_24h(void);
void movement_set_clock_mode_24h(movement_clock_mode_t value); void movement_set_clock_mode_24h(movement_clock_mode_t value);

View File

@ -66,6 +66,8 @@ const watch_face_t watch_faces[] = {
/* Enable or disable the sound on mode button press */ /* Enable or disable the sound on mode button press */
#define MOVEMENT_DEFAULT_BUTTON_SOUND true #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 /* Set the timeout before switching back to the main watch face
* Valid values are: * Valid values are:
* 0: 60 seconds * 0: 60 seconds

View File

@ -67,7 +67,7 @@ static inline void load_countdown(countdown_state_t *state) {
static inline void button_beep() { static inline void button_beep() {
// play a beep as confirmation for a button press (if applicable) // 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) { static void schedule_countdown(countdown_state_t *state) {

View File

@ -121,7 +121,7 @@ void irq_handler_tc1(void) {
static inline void _button_beep() { static inline void _button_beep() {
// play a beep as confirmation for a button press (if applicable) // 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 /// @brief Display minutes, seconds and fractions derived from 128 Hz tick counter

View File

@ -118,7 +118,7 @@ bool stopwatch_face_loop(movement_event_t event, void *context) {
break; break;
case EVENT_ALARM_BUTTON_DOWN: case EVENT_ALARM_BUTTON_DOWN:
if (movement_button_should_sound()) { 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; stopwatch_state->running = !stopwatch_state->running;
if (stopwatch_state->running) { if (stopwatch_state->running) {

View File

@ -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_TOP_LEFT, "BTN", "BT");
watch_display_text_with_fallback(WATCH_POSITION_BOTTOM, "beep ", " beep "); watch_display_text_with_fallback(WATCH_POSITION_BOTTOM, "beep ", " beep ");
if (subsecond % 2) { if (subsecond % 2) {
if (movement_button_should_sound()) { if (movement_button_should_sound()) {
watch_display_text(WATCH_POSITION_TOP_RIGHT, " Y"); 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 { } else {
// N for NONE
watch_display_text(WATCH_POSITION_TOP_RIGHT, " N"); watch_display_text(WATCH_POSITION_TOP_RIGHT, " N");
} }
} }
} }
static void beep_setting_advance(void) { 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) { static void timeout_setting_display(uint8_t subsecond) {