diff options
Diffstat (limited to 'Sensor Watch Buzzer Demo/app.c')
-rw-r--r-- | Sensor Watch Buzzer Demo/app.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/Sensor Watch Buzzer Demo/app.c b/Sensor Watch Buzzer Demo/app.c index 5c2dbc7b..74777fcc 100644 --- a/Sensor Watch Buzzer Demo/app.c +++ b/Sensor Watch Buzzer Demo/app.c @@ -4,15 +4,12 @@ typedef struct ApplicationState { bool play; - bool debounce_wait; } ApplicationState; ApplicationState application_state; void cb_alarm_pressed() { - if (application_state.debounce_wait) return; - application_state.debounce_wait = true; application_state.play = true; } @@ -24,7 +21,7 @@ void app_wake_from_deep_sleep() { } void app_setup() { - watch_register_button_callback(BTN_ALARM, cb_alarm_pressed); + watch_register_extwake_callback(BTN_ALARM, cb_alarm_pressed, true); watch_enable_display(); @@ -40,6 +37,7 @@ void app_wake_from_sleep() { bool app_loop() { if (application_state.play) { + printf("Playing song...\n"); const BuzzerNote rains[] = { BUZZER_NOTE_A4, BUZZER_NOTE_F5, @@ -120,18 +118,17 @@ bool app_loop() { for(size_t i = 0; i < sizeof(rains); i++) { char buf[9] = {0}; if (rains[i] == BUZZER_NOTE_REST) { + printf("rest for %d ms\n", durations[i]); sprintf(buf, "%2drESt ", i); } else { + printf("playing note %2d: %3.0f Hz for %d ms\n", i, 1000000.0 / (float)NotePeriods[rains[i]], durations[i]); sprintf(buf, "%2d%6d", i, NotePeriods[rains[i]]); } watch_display_string(buf, 2); watch_buzzer_play_note(rains[i], durations[i]); } + printf("done!\n\n"); } - // Wait a moment to debounce button input - delay_ms(250); - application_state.debounce_wait = false; - return true; } |