From 3003355eb7220dac9e5fd8ee0d0d302849ab8912 Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Fri, 23 Dec 2022 15:47:59 +0100 Subject: [PATCH] fix speaker issues due to api change, fix switch statement, add icon in external folder --- application.fam | 1 + gui_extensions.c | 1 + icons/ButtonUp_7x4.png | Bin 0 -> 102 bytes metronome.c | 20 +++++++++++++++++--- 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 icons/ButtonUp_7x4.png diff --git a/application.fam b/application.fam index 4e8d003..0a9f378 100644 --- a/application.fam +++ b/application.fam @@ -8,6 +8,7 @@ App( "gui", ], fap_icon="metronome_icon.png", + fap_icon_assets="icons", fap_category="Music", stack_size=2 * 1024, order=20, diff --git a/gui_extensions.c b/gui_extensions.c index 7b2aa62..bbda27b 100644 --- a/gui_extensions.c +++ b/gui_extensions.c @@ -1,5 +1,6 @@ #include #include +#include "metronome_icons.h" //lib can only do bottom left/right void elements_button_top_left(Canvas* canvas, const char* str) { diff --git a/icons/ButtonUp_7x4.png b/icons/ButtonUp_7x4.png new file mode 100644 index 0000000000000000000000000000000000000000..1be79328b40a93297a5609756328406565c437c0 GIT binary patch literal 102 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)I!3HFqj;YoHDIHH2#}J8d-yTOk1_O>mFaFD) zeWb+ZHz{mGZZ1QpXe09^4tcYT#4oe=UbmGC^A-KE*|F&zP#=S*tDnm{r-UX30HgpM AM*si- literal 0 HcmV?d00001 diff --git a/metronome.c b/metronome.c index 9b14d4b..a613c0c 100644 --- a/metronome.c +++ b/metronome.c @@ -135,7 +135,9 @@ static void timer_callback(void* ctx) { notification_message(metronome_state->notifications, &sequence_set_only_red_255); switch(metronome_state->output_mode) { case Loud: - furi_hal_speaker_start(440.0f, 1.0f); + if (furi_hal_speaker_acquire(1000)) { + furi_hal_speaker_start(440.0f, 1.0f); + } break; case Vibro: notification_message(metronome_state->notifications, &sequence_set_vibro_on); @@ -148,7 +150,9 @@ static void timer_callback(void* ctx) { notification_message(metronome_state->notifications, &sequence_set_only_green_255); switch(metronome_state->output_mode) { case Loud: - furi_hal_speaker_start(220.0f, 1.0f); + if (furi_hal_speaker_acquire(1000)) { + furi_hal_speaker_start(220.0f, 1.0f); + } break; case Vibro: notification_message(metronome_state->notifications, &sequence_set_vibro_on); @@ -162,7 +166,10 @@ static void timer_callback(void* ctx) { switch(metronome_state->output_mode) { case Loud: furi_delay_ms(BEEP_DELAY_MS); - furi_hal_speaker_stop(); + if (furi_hal_speaker_is_mine()) { + furi_hal_speaker_stop(); + furi_hal_speaker_release(); + } break; case Vibro: if (metronome_state->current_beat == 1) { @@ -269,6 +276,7 @@ int32_t metronome_app() { metronome_state->timer = furi_timer_alloc(timer_callback, FuriTimerTypePeriodic, &state_mutex); // Open GUI and register view_port + // Gui* gui = furi_record_open("gui"); gui_add_view_port(gui, view_port, GuiLayerFullscreen); @@ -306,6 +314,8 @@ int32_t metronome_app() { case InputKeyBack: processing = false; break; + case InputKeyMAX: + break; } } else if (event.input.type == InputTypeLong) { // hold events @@ -326,6 +336,8 @@ int32_t metronome_app() { case InputKeyBack: processing = false; break; + case InputKeyMAX: + break; } } else if (event.input.type == InputTypeRepeat) { // repeat events @@ -345,6 +357,8 @@ int32_t metronome_app() { case InputKeyBack: processing = false; break; + case InputKeyMAX: + break; } } }