From ee7ae2d3450307196ed68e87ad83cb2498bfbbe9 Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Sat, 18 Sep 2021 14:00:45 -0400 Subject: move buzzer demo to apps folder --- Sensor Watch Buzzer Demo/app.c | 134 -------------------------- Sensor Watch Buzzer Demo/make/.gitignore | 1 - Sensor Watch Buzzer Demo/make/Makefile | 9 -- apps/Sensor Watch Buzzer Demo/app.c | 134 ++++++++++++++++++++++++++ apps/Sensor Watch Buzzer Demo/make/.gitignore | 1 + apps/Sensor Watch Buzzer Demo/make/Makefile | 10 ++ 6 files changed, 145 insertions(+), 144 deletions(-) delete mode 100644 Sensor Watch Buzzer Demo/app.c delete mode 100755 Sensor Watch Buzzer Demo/make/.gitignore delete mode 100755 Sensor Watch Buzzer Demo/make/Makefile create mode 100644 apps/Sensor Watch Buzzer Demo/app.c create mode 100755 apps/Sensor Watch Buzzer Demo/make/.gitignore create mode 100755 apps/Sensor Watch Buzzer Demo/make/Makefile diff --git a/Sensor Watch Buzzer Demo/app.c b/Sensor Watch Buzzer Demo/app.c deleted file mode 100644 index 74777fcc..00000000 --- a/Sensor Watch Buzzer Demo/app.c +++ /dev/null @@ -1,134 +0,0 @@ -#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_deep_sleep() { -} - -void app_setup() { - watch_register_extwake_callback(BTN_ALARM, cb_alarm_pressed, true); - - watch_enable_display(); - - watch_enable_buzzer(); -} - -void app_prepare_for_sleep() { - watch_display_string(" rains ", 2); -} - -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, - 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/Sensor Watch Buzzer Demo/make/.gitignore b/Sensor Watch Buzzer Demo/make/.gitignore deleted file mode 100755 index 3722ac63..00000000 --- a/Sensor Watch Buzzer Demo/make/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build/ diff --git a/Sensor Watch Buzzer Demo/make/Makefile b/Sensor Watch Buzzer Demo/make/Makefile deleted file mode 100755 index 358bb860..00000000 --- a/Sensor Watch Buzzer Demo/make/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -include ../../make.mk - -INCLUDES += \ - -I../ - -SRCS += \ - ../app.c - -include ../../rules.mk diff --git a/apps/Sensor Watch Buzzer Demo/app.c b/apps/Sensor Watch Buzzer Demo/app.c new file mode 100644 index 00000000..74777fcc --- /dev/null +++ b/apps/Sensor Watch Buzzer Demo/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_deep_sleep() { +} + +void app_setup() { + watch_register_extwake_callback(BTN_ALARM, cb_alarm_pressed, true); + + watch_enable_display(); + + watch_enable_buzzer(); +} + +void app_prepare_for_sleep() { + watch_display_string(" rains ", 2); +} + +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, + 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/Sensor Watch Buzzer Demo/make/.gitignore b/apps/Sensor Watch Buzzer Demo/make/.gitignore new file mode 100755 index 00000000..3722ac63 --- /dev/null +++ b/apps/Sensor Watch Buzzer Demo/make/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/apps/Sensor Watch Buzzer Demo/make/Makefile b/apps/Sensor Watch Buzzer Demo/make/Makefile new file mode 100755 index 00000000..c66ad20c --- /dev/null +++ b/apps/Sensor Watch Buzzer Demo/make/Makefile @@ -0,0 +1,10 @@ +TOP = ../../.. +include $(TOP)/make.mk + +INCLUDES += \ + -I../ + +SRCS += \ + ../app.c + +include $(TOP)/rules.mk -- cgit v1.2.3