From 316e1f292c603885f2af3dcd69ce797d64776425 Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Sun, 5 Dec 2021 23:06:25 -0600 Subject: rename project files --- apps/buzzer-test/app.c | 134 +++++++++++++++++++++++++++++++++++++++ apps/buzzer-test/make/.gitignore | 1 + apps/buzzer-test/make/Makefile | 10 +++ 3 files changed, 145 insertions(+) create mode 100644 apps/buzzer-test/app.c create mode 100755 apps/buzzer-test/make/.gitignore create mode 100755 apps/buzzer-test/make/Makefile (limited to 'apps/buzzer-test') diff --git a/apps/buzzer-test/app.c b/apps/buzzer-test/app.c new file mode 100644 index 00000000..58158dff --- /dev/null +++ b/apps/buzzer-test/app.c @@ -0,0 +1,134 @@ +#include +#include +#include "watch.h" + +typedef struct ApplicationState { + bool play; +} ApplicationState; + +ApplicationState application_state; + + +void cb_alarm_pressed() { + application_state.play = true; +} + +void app_init() { + memset(&application_state, 0, sizeof(application_state)); +} + +void app_wake_from_backup() { +} + +void app_setup() { + watch_register_extwake_callback(BTN_ALARM, cb_alarm_pressed, true); + + watch_enable_display(); + + watch_enable_buzzer(); +} + +void app_prepare_for_standby() { + watch_display_string(" rains ", 2); +} + +void app_wake_from_standby() { +} + +bool app_loop() { + if (application_state.play) { + printf("Playing song...\n"); + const BuzzerNote rains[] = { + BUZZER_NOTE_A4, + BUZZER_NOTE_F5, + BUZZER_NOTE_REST, + BUZZER_NOTE_A4, + BUZZER_NOTE_E5, + BUZZER_NOTE_REST, + BUZZER_NOTE_A4, + BUZZER_NOTE_F5, + BUZZER_NOTE_G5, + BUZZER_NOTE_E5, + BUZZER_NOTE_REST, + BUZZER_NOTE_A4, + BUZZER_NOTE_G5, + BUZZER_NOTE_F5, + BUZZER_NOTE_E5, + BUZZER_NOTE_D5, + BUZZER_NOTE_E5, + BUZZER_NOTE_REST, + + BUZZER_NOTE_A5, + BUZZER_NOTE_REST, + BUZZER_NOTE_A5, + BUZZER_NOTE_A5SHARP_B5FLAT, + BUZZER_NOTE_G5, + BUZZER_NOTE_REST, + BUZZER_NOTE_C5, + BUZZER_NOTE_A5, + BUZZER_NOTE_A5SHARP_B5FLAT, + BUZZER_NOTE_G5, + BUZZER_NOTE_REST, + BUZZER_NOTE_D5, + BUZZER_NOTE_A5SHARP_B5FLAT, + BUZZER_NOTE_A5, + BUZZER_NOTE_G5, + BUZZER_NOTE_F5, + BUZZER_NOTE_E5, + }; + const uint16_t durations[] = { + 200, + 600, + 100, + 200, + 600, + 100, + 200, + 400, + 400, + 600, + 100, + 200, + 400, + 400, + 400, + 400, + 800, + 600, + + 200, + 50, + 400, + 200, + 400, + 100, + 200, + 400, + 400, + 400, + 200, + 200, + 400, + 400, + 400, + 400, + 900, + }; + application_state.play = false; + 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"); + } + + return true; +} diff --git a/apps/buzzer-test/make/.gitignore b/apps/buzzer-test/make/.gitignore new file mode 100755 index 00000000..3722ac63 --- /dev/null +++ b/apps/buzzer-test/make/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/apps/buzzer-test/make/Makefile b/apps/buzzer-test/make/Makefile new file mode 100755 index 00000000..c66ad20c --- /dev/null +++ b/apps/buzzer-test/make/Makefile @@ -0,0 +1,10 @@ +TOP = ../../.. +include $(TOP)/make.mk + +INCLUDES += \ + -I../ + +SRCS += \ + ../app.c + +include $(TOP)/rules.mk -- cgit v1.2.3 From 762af872d2f2c977e51d6e51b8c3ad622485cc05 Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Sun, 5 Dec 2021 23:49:26 -0600 Subject: fix missing prototype warnings --- apps/buzzer-test/app.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'apps/buzzer-test') diff --git a/apps/buzzer-test/app.c b/apps/buzzer-test/app.c index 58158dff..65d2356c 100644 --- a/apps/buzzer-test/app.c +++ b/apps/buzzer-test/app.c @@ -9,18 +9,18 @@ typedef struct ApplicationState { ApplicationState application_state; -void cb_alarm_pressed() { +void cb_alarm_pressed(void) { application_state.play = true; } -void app_init() { +void app_init(void) { memset(&application_state, 0, sizeof(application_state)); } -void app_wake_from_backup() { +void app_wake_from_backup(void) { } -void app_setup() { +void app_setup(void) { watch_register_extwake_callback(BTN_ALARM, cb_alarm_pressed, true); watch_enable_display(); @@ -28,14 +28,14 @@ void app_setup() { watch_enable_buzzer(); } -void app_prepare_for_standby() { +void app_prepare_for_standby(void) { watch_display_string(" rains ", 2); } -void app_wake_from_standby() { +void app_wake_from_standby(void) { } -bool app_loop() { +bool app_loop(void) { if (application_state.play) { printf("Playing song...\n"); const BuzzerNote rains[] = { -- cgit v1.2.3