diff --git a/movement/watch_faces/complication/tuning_tones_face.c b/movement/watch_faces/complication/tuning_tones_face.c index a139427..525b3eb 100644 --- a/movement/watch_faces/complication/tuning_tones_face.c +++ b/movement/watch_faces/complication/tuning_tones_face.c @@ -38,23 +38,23 @@ */ typedef struct Note { - BuzzerNote note; + int8_t notes[3]; char * name; } Note; static Note notes[] = { - { .note = BUZZER_NOTE_C5, .name = "C " }, - { .note = BUZZER_NOTE_C5SHARP_D5FLAT, .name = "Db" }, - { .note = BUZZER_NOTE_D5, .name = "D " }, - { .note = BUZZER_NOTE_D5SHARP_E5FLAT, .name = "Eb" }, - { .note = BUZZER_NOTE_E5, .name = "E " }, - { .note = BUZZER_NOTE_F5, .name = "F " }, - { .note = BUZZER_NOTE_F5SHARP_G5FLAT, .name = "Gb" }, - { .note = BUZZER_NOTE_G5, .name = "G " }, - { .note = BUZZER_NOTE_G5SHARP_A5FLAT, .name = "Ab" }, - { .note = BUZZER_NOTE_A5, .name = "A " }, - { .note = BUZZER_NOTE_A5SHARP_B5FLAT, .name = "Bb" }, - { .note = BUZZER_NOTE_B5, .name = "B " }, + { .notes = { BUZZER_NOTE_C5, 64 , 0 }, .name = "C " }, + { .notes = { BUZZER_NOTE_C5SHARP_D5FLAT, 64 , 0 }, .name = "Db" }, + { .notes = { BUZZER_NOTE_D5, 64 , 0 }, .name = "D " }, + { .notes = { BUZZER_NOTE_D5SHARP_E5FLAT, 64 , 0 }, .name = "Eb" }, + { .notes = { BUZZER_NOTE_E5, 64 , 0 }, .name = "E " }, + { .notes = { BUZZER_NOTE_F5, 64 , 0 }, .name = "F " }, + { .notes = { BUZZER_NOTE_F5SHARP_G5FLAT, 64 , 0 }, .name = "Gb" }, + { .notes = { BUZZER_NOTE_G5, 64 , 0 }, .name = "G " }, + { .notes = { BUZZER_NOTE_G5SHARP_A5FLAT, 64 , 0 }, .name = "Ab" }, + { .notes = { BUZZER_NOTE_A5, 64 , 0 }, .name = "A " }, + { .notes = { BUZZER_NOTE_A5SHARP_B5FLAT, 64 , 0 }, .name = "Bb" }, + { .notes = { BUZZER_NOTE_B5, 64 , 0 }, .name = "B " }, }; static size_t note_count = sizeof notes / sizeof *notes; @@ -80,12 +80,21 @@ void tuning_tones_face_activate(movement_settings_t *settings, void *context) { (void) context; } +static int8_t note; + +static void go_again(void) { + watch_buzzer_play_sequence(notes[note].notes, go_again); +} + static void update_buzzer(const tuning_tones_state_t *state) { if (state->playing) { + watch_enable_buzzer(); + note = state->note_ind; + go_again(); + } else { + watch_buzzer_abort_sequence(); watch_set_buzzer_off(); - watch_set_buzzer_period(NotePeriods[notes[state->note_ind].note]); - watch_set_buzzer_on(); } } @@ -110,11 +119,8 @@ bool tuning_tones_face_loop(movement_event_t event, movement_settings_t *setting break; case EVENT_ALARM_BUTTON_DOWN: state->playing = !state->playing; - if (!state->playing) { - watch_set_buzzer_off(); - } else { - update_buzzer(state); - } + update_buzzer(state); + break; case EVENT_ALARM_BUTTON_UP: break; case EVENT_TIMEOUT: @@ -135,6 +141,6 @@ void tuning_tones_face_resign(movement_settings_t *settings, void *context) { if (state->playing) { state->playing = false; - watch_set_buzzer_off(); + update_buzzer(state); } }