Fix bug that was causing notes in a sequence to play too long
This commit is contained in:
@@ -139,7 +139,7 @@ void cb_watch_buzzer_seq(void) {
|
||||
watch_set_buzzer_on();
|
||||
} else watch_set_buzzer_off();
|
||||
// set duration ticks and move to next tone
|
||||
_tone_ticks = _sequence[_seq_position + 1];
|
||||
_tone_ticks = _sequence[_seq_position + 1] - 1;
|
||||
_seq_position += 2;
|
||||
} else {
|
||||
// end the sequence
|
||||
@@ -187,7 +187,7 @@ void cb_watch_buzzer_raw_source(void) {
|
||||
if (_tone_ticks == 0) {
|
||||
done = _raw_source(_seq_position, _userdata, &period, &duration);
|
||||
|
||||
if (done) {
|
||||
if (done || duration == 0) {
|
||||
// end the sequence
|
||||
watch_buzzer_abort_sequence();
|
||||
} else {
|
||||
@@ -199,7 +199,7 @@ void cb_watch_buzzer_raw_source(void) {
|
||||
}
|
||||
|
||||
// set duration ticks and move to next tone
|
||||
_tone_ticks = duration;
|
||||
_tone_ticks = duration - 1;
|
||||
_seq_position += 1;
|
||||
}
|
||||
} 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];
|
||||
|
||||
single_note_sequence[0] = note;
|
||||
// 48 ticks per second for the tc0?
|
||||
// Each tick is approximately 20ms
|
||||
uint16_t duration = duration_ms / 20;
|
||||
// 64 ticks per second for the tc0
|
||||
// Each tick is approximately 15ms
|
||||
uint16_t duration = duration_ms / 15;
|
||||
if (duration > 127) duration = 127;
|
||||
single_note_sequence[1] = (int8_t)duration;
|
||||
single_note_sequence[2] = 0;
|
||||
|
||||
Reference in New Issue
Block a user