Fix bug that was causing notes in a sequence to play too long

This commit is contained in:
Alessandro Genova
2025-08-19 00:00:51 -04:00
parent cb05585c15
commit f534e7c202
3 changed files with 18 additions and 18 deletions
+8 -8
View File
@@ -103,13 +103,13 @@ static int8_t *_pending_sequence;
// The note sequence of the default alarm // The note sequence of the default alarm
int8_t alarm_tune[] = { int8_t alarm_tune[] = {
BUZZER_NOTE_C8, 4, BUZZER_NOTE_C8, 4,
BUZZER_NOTE_REST, 4, BUZZER_NOTE_REST, 7,
BUZZER_NOTE_C8, 4, BUZZER_NOTE_C8, 4,
BUZZER_NOTE_REST, 4, BUZZER_NOTE_REST, 7,
BUZZER_NOTE_C8, 4, BUZZER_NOTE_C8, 4,
BUZZER_NOTE_REST, 4, BUZZER_NOTE_REST, 7,
BUZZER_NOTE_C8, 6, BUZZER_NOTE_C8, 4,
BUZZER_NOTE_REST, 18, BUZZER_NOTE_REST, 27,
-8, 9, -8, 9,
0 0
}; };
@@ -505,9 +505,9 @@ void movement_play_note(watch_buzzer_note_t note, uint16_t duration_ms) {
static int8_t single_note_sequence[3]; static int8_t single_note_sequence[3];
single_note_sequence[0] = note; single_note_sequence[0] = note;
// 48 ticks per second for the tc0? // 64 ticks per second for the tc0
// Each tick is approximately 20ms // Each tick is approximately 15ms
uint16_t duration = duration_ms / 20; uint16_t duration = duration_ms / 15;
if (duration > 127) duration = 127; if (duration > 127) duration = 127;
single_note_sequence[1] = (int8_t)duration; single_note_sequence[1] = (int8_t)duration;
single_note_sequence[2] = 0; single_note_sequence[2] = 0;
+6 -6
View File
@@ -139,7 +139,7 @@ void cb_watch_buzzer_seq(void) {
watch_set_buzzer_on(); watch_set_buzzer_on();
} else watch_set_buzzer_off(); } else watch_set_buzzer_off();
// set duration ticks and move to next tone // set duration ticks and move to next tone
_tone_ticks = _sequence[_seq_position + 1]; _tone_ticks = _sequence[_seq_position + 1] - 1;
_seq_position += 2; _seq_position += 2;
} else { } else {
// end the sequence // end the sequence
@@ -187,7 +187,7 @@ void cb_watch_buzzer_raw_source(void) {
if (_tone_ticks == 0) { if (_tone_ticks == 0) {
done = _raw_source(_seq_position, _userdata, &period, &duration); done = _raw_source(_seq_position, _userdata, &period, &duration);
if (done) { if (done || duration == 0) {
// end the sequence // end the sequence
watch_buzzer_abort_sequence(); watch_buzzer_abort_sequence();
} else { } else {
@@ -199,7 +199,7 @@ void cb_watch_buzzer_raw_source(void) {
} }
// set duration ticks and move to next tone // set duration ticks and move to next tone
_tone_ticks = duration; _tone_ticks = duration - 1;
_seq_position += 1; _seq_position += 1;
} }
} else { } else {
@@ -305,9 +305,9 @@ void watch_buzzer_play_note_with_volume(watch_buzzer_note_t note, uint16_t durat
static int8_t single_note_sequence[3]; static int8_t single_note_sequence[3];
single_note_sequence[0] = note; single_note_sequence[0] = note;
// 48 ticks per second for the tc0? // 64 ticks per second for the tc0
// Each tick is approximately 20ms // Each tick is approximately 15ms
uint16_t duration = duration_ms / 20; uint16_t duration = duration_ms / 15;
if (duration > 127) duration = 127; if (duration > 127) duration = 127;
single_note_sequence[1] = (int8_t)duration; single_note_sequence[1] = (int8_t)duration;
single_note_sequence[2] = 0; single_note_sequence[2] = 0;
+4 -4
View File
@@ -110,7 +110,7 @@ void cb_watch_buzzer_seq(void *userData) {
watch_set_buzzer_on(); watch_set_buzzer_on();
} }
// set duration ticks and move to next tone // set duration ticks and move to next tone
_tone_ticks = _sequence[_seq_position + 1]; _tone_ticks = _sequence[_seq_position + 1] - 1;
_seq_position += 2; _seq_position += 2;
} else { } else {
// end the sequence // end the sequence
@@ -157,7 +157,7 @@ void cb_watch_buzzer_raw_source(void *userData) {
if (_tone_ticks == 0) { if (_tone_ticks == 0) {
done = _raw_source(_seq_position, _userdata, &period, &duration); done = _raw_source(_seq_position, _userdata, &period, &duration);
if (done) { if (done || duration == 0) {
// end the sequence // end the sequence
watch_buzzer_abort_sequence(); watch_buzzer_abort_sequence();
} else { } else {
@@ -169,7 +169,7 @@ void cb_watch_buzzer_raw_source(void *userData) {
} }
// set duration ticks and move to next tone // set duration ticks and move to next tone
_tone_ticks = duration; _tone_ticks = duration - 1;
_seq_position += 1; _seq_position += 1;
} }
} else { } else {
@@ -272,7 +272,7 @@ void watch_buzzer_play_note_with_volume(watch_buzzer_note_t note, uint16_t durat
static int8_t single_note_sequence[3]; static int8_t single_note_sequence[3];
single_note_sequence[0] = note; single_note_sequence[0] = note;
// 64 ticks per second for the tc0? // 64 ticks per second for the tc0
// Each tick is approximately 15ms // Each tick is approximately 15ms
uint16_t duration = duration_ms / 15; uint16_t duration = duration_ms / 15;
if (duration > 127) duration = 127; if (duration > 127) duration = 127;