diff options
author | joeycastillo <joeycastillo@utexas.edu> | 2021-08-30 14:42:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-30 14:42:11 -0400 |
commit | eb3d9b26cbda2d2612f11eb39843b221224f1fa7 (patch) | |
tree | 7a514b4d21dd0d2a324a5e1313a144f26bf20799 /Sensor Watch Buzzer Demo/app.c | |
parent | ee9cc322d301631c9ff0751d9bed717c6492b6a5 (diff) | |
parent | b0845cc3f1a8234a30c980eccf10e44765e4e105 (diff) | |
download | Sensor-Watch-eb3d9b26cbda2d2612f11eb39843b221224f1fa7.tar.gz Sensor-Watch-eb3d9b26cbda2d2612f11eb39843b221224f1fa7.tar.bz2 Sensor-Watch-eb3d9b26cbda2d2612f11eb39843b221224f1fa7.zip |
Merge pull request #9 from joeycastillo/usb-refactor
USB refactor / Makefile simplification
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; } |