diff options
-rw-r--r-- | movement/movement.c | 33 | ||||
-rw-r--r-- | movement/movement_config.h | 3 | ||||
-rw-r--r-- | movement/watch_faces/clock/repetition_minute_face.c | 12 | ||||
-rw-r--r-- | movement/watch_faces/clock/simple_clock_bin_led_face.c | 12 | ||||
-rw-r--r-- | movement/watch_faces/clock/simple_clock_face.c | 12 | ||||
-rw-r--r-- | movement/watch_faces/clock/weeknumber_clock_face.c | 12 | ||||
-rw-r--r-- | watch-library/hardware/watch/watch_buzzer.c | 9 | ||||
-rw-r--r-- | watch-library/shared/watch/watch_buzzer.h | 2 |
8 files changed, 41 insertions, 54 deletions
diff --git a/movement/movement.c b/movement/movement.c index 235716c8..0e40d462 100644 --- a/movement/movement.c +++ b/movement/movement.c @@ -294,14 +294,31 @@ void movement_request_wake() { } void movement_play_signal(void) { -#ifdef SIGNAL_TUNE_DEFAULT - watch_buzzer_play_note(BUZZER_NOTE_C8, 75); - watch_buzzer_play_note(BUZZER_NOTE_REST, 100); - watch_buzzer_play_note(BUZZER_NOTE_C8, 100); -#else - // Does not work in LE mode. - watch_buzzer_play_sequence(signal_tune, NULL); -#endif // SIGNAL_TUNE_DEFAULT + watch_enable_buzzer(); + watch_buzzer_play_sequence(signal_tune, watch_disable_buzzer); + if (movement_state.le_mode_ticks == -1) { + // This is somewhat of a hack. In order to play a sequence, we need to + // be awake. We should ideally be able to tell movement that we need to + // be awake for a given amount of time, but there's no good way to do + // this, so we block instead. This might be bad in the case that a + // watch face has housekeeping to do after calling this, since it could + // in theory do that housekeeping concurrently, but alas. + // + // You might wonder, why not just put the instruction to go back to + // sleep in the callback? It's a good idea, but I can't figure out how + // to get it to work - you're basically kicking the can down the road, + // since at some point movement will be done doing what it's doing and + // have to wait. At that point, you're delaying anyways, but it's + // harder to figure out how much time to delay for, since you don't + // know how much time has elapsed since starting the sequence. I'd + // rather this block than have to read from the RTC to figure that + // out. + // + // Don't ask me what the +50ms is doing. The sequence gets cut short + // with the exact time, I have no idea why. 50 extra millisecons seems + // like a safe value. + delay_ms(sequence_length(signal_tune) * 1000 / 64 + 50); + } } void movement_play_alarm(void) { diff --git a/movement/movement_config.h b/movement/movement_config.h index bafbc5e5..067ca44b 100644 --- a/movement/movement_config.h +++ b/movement/movement_config.h @@ -49,8 +49,7 @@ const watch_face_t watch_faces[] = { */ #define MOVEMENT_SECONDARY_FACE_INDEX (MOVEMENT_NUM_FACES - 2) // or (0) -/* Custom hourly chime tune. Check movement_custom_signal_tunes.h for options. - * Custom tunes do not currently work in LE mode. */ +/* Custom hourly chime tune. Check movement_custom_signal_tunes.h for options. */ #define SIGNAL_TUNE_DEFAULT #endif // MOVEMENT_CONFIG_H_ diff --git a/movement/watch_faces/clock/repetition_minute_face.c b/movement/watch_faces/clock/repetition_minute_face.c index a0fbe077..e9e5e319 100644 --- a/movement/watch_faces/clock/repetition_minute_face.c +++ b/movement/watch_faces/clock/repetition_minute_face.c @@ -153,17 +153,7 @@ bool repetition_minute_face_loop(movement_event_t event, movement_settings_t *se case EVENT_BACKGROUND_TASK: // uncomment this line to snap back to the clock face when the hour signal sounds: // movement_move_to_face(state->watch_face_index); - if (watch_is_buzzer_or_led_enabled()) { - // if we are in the foreground, we can just beep. - movement_play_signal(); - } else { - // if we were in the background, we need to enable the buzzer peripheral first, - watch_enable_buzzer(); - // beep quickly (this call blocks for 275 ms), - movement_play_signal(); - // and then turn the buzzer peripheral off again. - watch_disable_buzzer(); - } + movement_play_signal(); break; case EVENT_LIGHT_LONG_UP: /* diff --git a/movement/watch_faces/clock/simple_clock_bin_led_face.c b/movement/watch_faces/clock/simple_clock_bin_led_face.c index 640f0d77..cf39c188 100644 --- a/movement/watch_faces/clock/simple_clock_bin_led_face.c +++ b/movement/watch_faces/clock/simple_clock_bin_led_face.c @@ -180,17 +180,7 @@ bool simple_clock_bin_led_face_loop(movement_event_t event, movement_settings_t case EVENT_BACKGROUND_TASK: // uncomment this line to snap back to the clock face when the hour signal sounds: // movement_move_to_face(state->watch_face_index); - if (watch_is_buzzer_or_led_enabled()) { - // if we are in the foreground, we can just beep. - movement_play_signal(); - } else { - // if we were in the background, we need to enable the buzzer peripheral first, - watch_enable_buzzer(); - // beep quickly (this call blocks for 275 ms), - movement_play_signal(); - // and then turn the buzzer peripheral off again. - watch_disable_buzzer(); - } + movement_play_signal(); break; case EVENT_LIGHT_LONG_PRESS: if (state->flashing_state == 0) { diff --git a/movement/watch_faces/clock/simple_clock_face.c b/movement/watch_faces/clock/simple_clock_face.c index 91400b6c..fbc2c4b3 100644 --- a/movement/watch_faces/clock/simple_clock_face.c +++ b/movement/watch_faces/clock/simple_clock_face.c @@ -136,17 +136,7 @@ bool simple_clock_face_loop(movement_event_t event, movement_settings_t *setting case EVENT_BACKGROUND_TASK: // uncomment this line to snap back to the clock face when the hour signal sounds: // movement_move_to_face(state->watch_face_index); - if (watch_is_buzzer_or_led_enabled()) { - // if we are in the foreground, we can just beep. - movement_play_signal(); - } else { - // if we were in the background, we need to enable the buzzer peripheral first, - watch_enable_buzzer(); - // beep quickly (this call blocks for 275 ms), - movement_play_signal(); - // and then turn the buzzer peripheral off again. - watch_disable_buzzer(); - } + movement_play_signal(); break; default: return movement_default_loop_handler(event, settings); diff --git a/movement/watch_faces/clock/weeknumber_clock_face.c b/movement/watch_faces/clock/weeknumber_clock_face.c index 4e40ebdc..81df5847 100644 --- a/movement/watch_faces/clock/weeknumber_clock_face.c +++ b/movement/watch_faces/clock/weeknumber_clock_face.c @@ -130,17 +130,7 @@ bool weeknumber_clock_face_loop(movement_event_t event, movement_settings_t *set case EVENT_BACKGROUND_TASK: // uncomment this line to snap back to the clock face when the hour signal sounds: // movement_move_to_face(state->watch_face_index); - if (watch_is_buzzer_or_led_enabled()) { - // if we are in the foreground, we can just beep. - movement_play_signal(); - } else { - // if we were in the background, we need to enable the buzzer peripheral first, - watch_enable_buzzer(); - // beep quickly (this call blocks for 275 ms), - movement_play_signal(); - // and then turn the buzzer peripheral off again. - watch_disable_buzzer(); - } + movement_play_signal(); break; default: movement_default_loop_handler(event, settings); diff --git a/watch-library/hardware/watch/watch_buzzer.c b/watch-library/hardware/watch/watch_buzzer.c index 18fb4db0..63506a51 100644 --- a/watch-library/hardware/watch/watch_buzzer.c +++ b/watch-library/hardware/watch/watch_buzzer.c @@ -90,6 +90,15 @@ void watch_buzzer_play_sequence(int8_t *note_sequence, void (*callback_on_end)(v _tc3_start(); } +uint16_t sequence_length(int8_t *sequence) { + uint16_t result = 0; + int i = 0; + while (sequence[i++]) { + result += sequence[i++]; + } + return result; +} + void cb_watch_buzzer_seq(void) { // callback for reading the note sequence if (_tone_ticks == 0) { diff --git a/watch-library/shared/watch/watch_buzzer.h b/watch-library/shared/watch/watch_buzzer.h index 7ba9a52e..4c39475c 100644 --- a/watch-library/shared/watch/watch_buzzer.h +++ b/watch-library/shared/watch/watch_buzzer.h @@ -175,6 +175,8 @@ extern const uint16_t NotePeriods[108]; */ void watch_buzzer_play_sequence(int8_t *note_sequence, void (*callback_on_end)(void)); +uint16_t sequence_length(int8_t *sequence); + /** @brief Aborts a playing sequence. */ void watch_buzzer_abort_sequence(void); |