summaryrefslogtreecommitdiffstats
path: root/movement/movement.c
diff options
context:
space:
mode:
authorWesley Aptekar-Cassels <me@wesleyac.com>2023-11-13 00:48:57 -0500
committerWesley Aptekar-Cassels <me@wesleyac.com>2024-01-09 16:22:21 -0500
commite9fe4aeefe7e56d637f7fbf35772f5bb37aff911 (patch)
treefc47972b343973aab5f8ce57be77a31a1c921d10 /movement/movement.c
parent3ee32c6e57e9a741355251f33fbcc323ded249d8 (diff)
downloadSensor-Watch-e9fe4aeefe7e56d637f7fbf35772f5bb37aff911.tar.gz
Sensor-Watch-e9fe4aeefe7e56d637f7fbf35772f5bb37aff911.tar.bz2
Sensor-Watch-e9fe4aeefe7e56d637f7fbf35772f5bb37aff911.zip
Enable custom signal tones in LE mode.
This makes movement_play_signal synchronous when in LE mode, despite using the underlying asynchronous API. It's a bit of a hack, but it should work well enough for now. This also moves the enabling/disabling of the buzzer into the movement_play_signal function, so that watch faces no longer have to do it.
Diffstat (limited to 'movement/movement.c')
-rw-r--r--movement/movement.c33
1 files changed, 25 insertions, 8 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) {