mirror of
https://github.com/joeycastillo/second-movement.git
synced 2026-02-04 15:35:49 +00:00
Fix faces that relied on watch_buzzer_play_note being blocking
This commit is contained in:
@ -202,9 +202,16 @@ static void _alarm_update_alarm_enabled(alarm_state_t *state) {
|
|||||||
|
|
||||||
static void _alarm_play_short_beep(uint8_t pitch_idx) {
|
static void _alarm_play_short_beep(uint8_t pitch_idx) {
|
||||||
// play a short double beep
|
// play a short double beep
|
||||||
watch_buzzer_play_note(_buzzer_notes[pitch_idx], 50);
|
static int8_t beep_sequence[] = {
|
||||||
watch_buzzer_play_note(BUZZER_NOTE_REST, 50);
|
0, 4,
|
||||||
watch_buzzer_play_note(_buzzer_notes[pitch_idx], 70);
|
BUZZER_NOTE_REST, 4,
|
||||||
|
0, 6,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
beep_sequence[0] = _buzzer_notes[pitch_idx];
|
||||||
|
beep_sequence[4] = _buzzer_notes[pitch_idx];
|
||||||
|
|
||||||
|
movement_play_sequence(beep_sequence, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _alarm_indicate_beep(alarm_state_t *state) {
|
static void _alarm_indicate_beep(alarm_state_t *state) {
|
||||||
@ -437,14 +444,7 @@ bool advanced_alarm_face_loop(movement_event_t event, void *context) {
|
|||||||
// play alarm
|
// play alarm
|
||||||
if (state->alarm[state->alarm_playing_idx].beeps == 0) {
|
if (state->alarm[state->alarm_playing_idx].beeps == 0) {
|
||||||
// short beep
|
// short beep
|
||||||
if (watch_is_buzzer_or_led_enabled()) {
|
_alarm_play_short_beep(state->alarm[state->alarm_playing_idx].pitch);
|
||||||
_alarm_play_short_beep(state->alarm[state->alarm_playing_idx].pitch);
|
|
||||||
} else {
|
|
||||||
// enable, play beep and disable buzzer again
|
|
||||||
watch_enable_buzzer();
|
|
||||||
_alarm_play_short_beep(state->alarm[state->alarm_playing_idx].pitch);
|
|
||||||
watch_disable_buzzer();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// regular alarm beeps
|
// regular alarm beeps
|
||||||
movement_play_alarm_beeps((state->alarm[state->alarm_playing_idx].beeps == (ALARM_MAX_BEEP_ROUNDS - 1) ? 20 : state->alarm[state->alarm_playing_idx].beeps),
|
movement_play_alarm_beeps((state->alarm[state->alarm_playing_idx].beeps == (ALARM_MAX_BEEP_ROUNDS - 1) ? 20 : state->alarm[state->alarm_playing_idx].beeps),
|
||||||
|
|||||||
@ -82,26 +82,36 @@ static inline int _days_in_month(int16_t month, int16_t year)
|
|||||||
/* Play beep sound based on type */
|
/* Play beep sound based on type */
|
||||||
static inline void _beep(beep_type_t beep_type)
|
static inline void _beep(beep_type_t beep_type)
|
||||||
{
|
{
|
||||||
|
static int8_t beep_sequence[] = {
|
||||||
|
0, 4,
|
||||||
|
0, 6,
|
||||||
|
0, 6,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
if (!movement_button_should_sound())
|
if (!movement_button_should_sound())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (beep_type) {
|
switch (beep_type) {
|
||||||
case BEEP_BUTTON:
|
case BEEP_BUTTON:
|
||||||
watch_buzzer_play_note_with_volume(BUZZER_NOTE_C7, 50, movement_button_volume());
|
beep_sequence[0] = BUZZER_NOTE_C7;
|
||||||
|
beep_sequence[2] = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BEEP_ENABLE:
|
case BEEP_ENABLE:
|
||||||
watch_buzzer_play_note_with_volume(BUZZER_NOTE_G7, 50, movement_button_volume());
|
beep_sequence[0] = BUZZER_NOTE_G7;
|
||||||
watch_buzzer_play_note(BUZZER_NOTE_REST, 75);
|
beep_sequence[2] = BUZZER_NOTE_REST;
|
||||||
watch_buzzer_play_note_with_volume(BUZZER_NOTE_C8, 50, movement_button_volume());
|
beep_sequence[4] = BUZZER_NOTE_C8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BEEP_DISABLE:
|
case BEEP_DISABLE:
|
||||||
watch_buzzer_play_note_with_volume(BUZZER_NOTE_C8, 50, movement_button_volume());
|
beep_sequence[0] = BUZZER_NOTE_C8;
|
||||||
watch_buzzer_play_note(BUZZER_NOTE_REST, 75);
|
beep_sequence[2] = BUZZER_NOTE_REST;
|
||||||
watch_buzzer_play_note_with_volume(BUZZER_NOTE_G7, 50, movement_button_volume());
|
beep_sequence[4] = BUZZER_NOTE_G7;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
movement_play_sequence(beep_sequence, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Change tick frequency */
|
/* Change tick frequency */
|
||||||
|
|||||||
@ -119,30 +119,22 @@ static void _simon_play_note(SimonNote note, simon_state_t *state, bool skip_res
|
|||||||
switch (note) {
|
switch (note) {
|
||||||
case SIMON_LED_NOTE:
|
case SIMON_LED_NOTE:
|
||||||
if (!state->lightOff) watch_set_led_yellow();
|
if (!state->lightOff) watch_set_led_yellow();
|
||||||
if (state->soundOff)
|
if (!state->soundOff) watch_buzzer_play_note(BUZZER_NOTE_D3, _delay_beep);
|
||||||
delay_ms(_delay_beep);
|
delay_ms(_delay_beep);
|
||||||
else
|
|
||||||
watch_buzzer_play_note(BUZZER_NOTE_D3, _delay_beep);
|
|
||||||
break;
|
break;
|
||||||
case SIMON_MODE_NOTE:
|
case SIMON_MODE_NOTE:
|
||||||
if (!state->lightOff) watch_set_led_red();
|
if (!state->lightOff) watch_set_led_red();
|
||||||
if (state->soundOff)
|
if (!state->soundOff) watch_buzzer_play_note(BUZZER_NOTE_E4, _delay_beep);
|
||||||
delay_ms(_delay_beep);
|
delay_ms(_delay_beep);
|
||||||
else
|
|
||||||
watch_buzzer_play_note(BUZZER_NOTE_E4, _delay_beep);
|
|
||||||
break;
|
break;
|
||||||
case SIMON_ALARM_NOTE:
|
case SIMON_ALARM_NOTE:
|
||||||
if (!state->lightOff) watch_set_led_green();
|
if (!state->lightOff) watch_set_led_green();
|
||||||
if (state->soundOff)
|
if (!state->soundOff) watch_buzzer_play_note(BUZZER_NOTE_C3, _delay_beep);
|
||||||
delay_ms(_delay_beep);
|
delay_ms(_delay_beep);
|
||||||
else
|
|
||||||
watch_buzzer_play_note(BUZZER_NOTE_C3, _delay_beep);
|
|
||||||
break;
|
break;
|
||||||
case SIMON_WRONG_NOTE:
|
case SIMON_WRONG_NOTE:
|
||||||
if (state->soundOff)
|
if (!state->soundOff) watch_buzzer_play_note(BUZZER_NOTE_A1, 800);
|
||||||
delay_ms(800);
|
delay_ms(800);
|
||||||
else
|
|
||||||
watch_buzzer_play_note(BUZZER_NOTE_A1, 800);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
watch_set_led_off();
|
watch_set_led_off();
|
||||||
@ -150,7 +142,7 @@ static void _simon_play_note(SimonNote note, simon_state_t *state, bool skip_res
|
|||||||
if (note != SIMON_WRONG_NOTE) {
|
if (note != SIMON_WRONG_NOTE) {
|
||||||
_simon_clear_display(state);
|
_simon_clear_display(state);
|
||||||
if (!skip_rest) {
|
if (!skip_rest) {
|
||||||
watch_buzzer_play_note(BUZZER_NOTE_REST, (_delay_beep * 2)/3);
|
delay_ms((_delay_beep * 2)/3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,6 +110,12 @@ static bool tally_face_should_move_back(tally_state_t *state) {
|
|||||||
bool tally_face_loop(movement_event_t event, void *context) {
|
bool tally_face_loop(movement_event_t event, void *context) {
|
||||||
tally_state_t *state = (tally_state_t *)context;
|
tally_state_t *state = (tally_state_t *)context;
|
||||||
static bool using_led = false;
|
static bool using_led = false;
|
||||||
|
static int8_t beep_sequence[] = {
|
||||||
|
0, 2,
|
||||||
|
BUZZER_NOTE_REST, 3,
|
||||||
|
0, 2,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
if (using_led) {
|
if (using_led) {
|
||||||
if(!HAL_GPIO_BTN_MODE_read() && !HAL_GPIO_BTN_LIGHT_read() && !HAL_GPIO_BTN_ALARM_read())
|
if(!HAL_GPIO_BTN_MODE_read() && !HAL_GPIO_BTN_LIGHT_read() && !HAL_GPIO_BTN_ALARM_read())
|
||||||
@ -148,9 +154,11 @@ bool tally_face_loop(movement_event_t event, void *context) {
|
|||||||
state->tally_idx = _tally_default[state->tally_default_idx]; // reset tally index
|
state->tally_idx = _tally_default[state->tally_default_idx]; // reset tally index
|
||||||
_init_val = true;
|
_init_val = true;
|
||||||
//play a reset tune
|
//play a reset tune
|
||||||
if (movement_button_should_sound()) watch_buzzer_play_note(BUZZER_NOTE_G6, 30);
|
if (movement_button_should_sound()) {
|
||||||
if (movement_button_should_sound()) watch_buzzer_play_note(BUZZER_NOTE_REST, 30);
|
beep_sequence[0] = BUZZER_NOTE_G6;
|
||||||
if (movement_button_should_sound()) watch_buzzer_play_note(BUZZER_NOTE_E6, 30);
|
beep_sequence[4] = BUZZER_NOTE_E6;
|
||||||
|
movement_play_sequence(beep_sequence, 0);
|
||||||
|
}
|
||||||
print_tally(state, movement_button_should_sound());
|
print_tally(state, movement_button_should_sound());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -168,9 +176,11 @@ bool tally_face_loop(movement_event_t event, void *context) {
|
|||||||
if (TALLY_FACE_PRESETS_SIZE() > 1 && _init_val){
|
if (TALLY_FACE_PRESETS_SIZE() > 1 && _init_val){
|
||||||
state->tally_default_idx = (state->tally_default_idx + 1) % TALLY_FACE_PRESETS_SIZE();
|
state->tally_default_idx = (state->tally_default_idx + 1) % TALLY_FACE_PRESETS_SIZE();
|
||||||
state->tally_idx = _tally_default[state->tally_default_idx];
|
state->tally_idx = _tally_default[state->tally_default_idx];
|
||||||
if (movement_button_should_sound()) watch_buzzer_play_note(BUZZER_NOTE_E6, 30);
|
if (movement_button_should_sound()) {
|
||||||
if (movement_button_should_sound()) watch_buzzer_play_note(BUZZER_NOTE_REST, 30);
|
beep_sequence[0] = BUZZER_NOTE_E6;
|
||||||
if (movement_button_should_sound()) watch_buzzer_play_note(BUZZER_NOTE_G6, 30);
|
beep_sequence[4] = BUZZER_NOTE_G6;
|
||||||
|
movement_play_sequence(beep_sequence, 0);
|
||||||
|
}
|
||||||
print_tally(state, movement_button_should_sound());
|
print_tally(state, movement_button_should_sound());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|||||||
Reference in New Issue
Block a user