diff --git a/applications/jukebox/jukebox.c b/applications/jukebox/jukebox.c index 17bfa89d6..d4eb814d5 100644 --- a/applications/jukebox/jukebox.c +++ b/applications/jukebox/jukebox.c @@ -7,6 +7,7 @@ #include #include #include +#include #define TAG "JukeBox" @@ -31,7 +32,7 @@ static char* subString(char* someString, int n) { char* new = malloc(sizeof(char) * n + 1); strncpy(new, someString, n); new[n] = '\0'; - return new; + return(new); } static char* file_stub(const char* file_name) { @@ -40,7 +41,7 @@ static char* file_stub(const char* file_name) { // string_init(file_name); path_extract_filename_no_ext(file_name, filename); - return subString((char*)string_get_cstr(filename), 8); + return(subString((char*)string_get_cstr(filename), 8)); } static void jukebox_send_signal(uint32_t frequency, string_t signal, string_t protocol) { @@ -58,7 +59,7 @@ static void jukebox_send_signal(uint32_t frequency, string_t signal, string_t pr } else { return; } - + NotificationApp* notification = furi_record_open("notification"); FlipperFormat* flipper_format = flipper_format_string_alloc(); Stream* stream = flipper_format_get_raw_stream(flipper_format); stream_clean(stream); @@ -77,6 +78,8 @@ static void jukebox_send_signal(uint32_t frequency, string_t signal, string_t pr TAG, "Transmitting at %lu, repeat %lu. Press CTRL+C to stop\r\n", frequency, repeat); furi_hal_power_suppress_charge_enter(); + notification_message(notification, &sequence_set_vibro_on); + furi_hal_subghz_start_async_tx(subghz_transmitter_yield, transmitter); while(!(furi_hal_subghz_is_async_tx_complete())) { @@ -84,6 +87,9 @@ static void jukebox_send_signal(uint32_t frequency, string_t signal, string_t pr fflush(stdout); osDelay(333); } + notification_message(notification, &sequence_reset_vibro); + + furi_record_close("notification"); furi_hal_subghz_stop_async_tx(); furi_hal_subghz_sleep(); @@ -159,13 +165,15 @@ static void jukebox_render_callback(Canvas* canvas, void* ctx) { } canvas_draw_str(canvas, 10, 63, "[back] - skip, hold to exit"); - + jukebox_reset_state(state); release_mutex((ValueMutex*)ctx, state); } static void jukebox_input_callback(InputEvent* input_event, void* ctx) { - osMessageQueueId_t event_queue = ctx; - osMessageQueuePut(event_queue, input_event, 0, osWaitForever); + if (input_event->type == InputTypeRelease) { + osMessageQueueId_t event_queue = ctx; + osMessageQueuePut(event_queue, input_event, 0, osWaitForever); + } } int32_t jukebox_app(void* p) { @@ -218,7 +226,7 @@ int32_t jukebox_app(void* p) { ValueMutex state_mutex; if(!init_mutex(&state_mutex, &_state, sizeof(RemoteAppState))) { FURI_LOG_D(TAG, "cannot create mutex"); - return 0; + return(0); } ViewPort* view_port = view_port_alloc(); @@ -240,57 +248,22 @@ int32_t jukebox_app(void* p) { input_get_type_name(event.type)); if(event.key == InputKeyRight) { - if(event.type == InputTypePress) { state->press[0] = true; - } else if(event.type == InputTypeRelease) { - state->press[0] = false; - } else if(event.type == InputTypeShort) { - state->press[0] = false; - } } else if(event.key == InputKeyLeft) { - if(event.type == InputTypePress) { state->press[1] = true; - } else if(event.type == InputTypeRelease) { - state->press[1] = false; - } else if(event.type == InputTypeShort) { - state->press[1] = false; - } } else if(event.key == InputKeyUp) { - if(event.type == InputTypePress) { state->press[2] = true; - } else if(event.type == InputTypeRelease) { - state->press[2] = false; - } else if(event.type == InputTypeShort) { - state->press[2] = false; - } } else if(event.key == InputKeyDown) { - if(event.type == InputTypePress) { state->press[3] = true; - } else if(event.type == InputTypeRelease) { - state->press[3] = false; - } else if(event.type == InputTypeShort) { - state->press[3] = false; - } } else if(event.key == InputKeyOk) { - if(event.type == InputTypePress) { state->press[4] = true; - } else if(event.type == InputTypeRelease) { - state->press[4] = false; - } else if(event.type == InputTypeShort) { - state->press[4] = false; - } } else if(event.key == InputKeyBack) { - if(event.type == InputTypeLong) { release_mutex(&state_mutex, state); break; - } else if(event.type == InputTypeShort) { - jukebox_reset_state(state); - } } release_mutex(&state_mutex, state); view_port_update(view_port); } - // remove & free all stuff created by app gui_remove_view_port(gui, view_port); view_port_free(view_port); @@ -299,5 +272,5 @@ int32_t jukebox_app(void* p) { furi_record_close("gui"); - return 0; + return(0); } \ No newline at end of file diff --git a/applications/universal_rf/universal_rf.c b/applications/universal_rf/universal_rf.c index d37c38350..ca21e5162 100644 --- a/applications/universal_rf/universal_rf.c +++ b/applications/universal_rf/universal_rf.c @@ -7,6 +7,7 @@ #include #include #include +#include #define TAG "UniveralRFRemote" @@ -31,16 +32,15 @@ static char* subString(char* someString, int n) { char* new = malloc(sizeof(char) * n + 1); strncpy(new, someString, n); new[n] = '\0'; - return new; + return(new); } static char* file_stub(const char* file_name) { string_t filename; string_init(filename); - // string_init(file_name); path_extract_filename_no_ext(file_name, filename); - return subString((char*)string_get_cstr(filename), 8); + return(subString((char*)string_get_cstr(filename), 8)); } static void remote_send_signal(uint32_t frequency, string_t signal, string_t protocol) { @@ -58,7 +58,7 @@ static void remote_send_signal(uint32_t frequency, string_t signal, string_t pro } else { return; } - + NotificationApp* notification = furi_record_open("notification"); FlipperFormat* flipper_format = flipper_format_string_alloc(); Stream* stream = flipper_format_get_raw_stream(flipper_format); stream_clean(stream); @@ -77,6 +77,8 @@ static void remote_send_signal(uint32_t frequency, string_t signal, string_t pro TAG, "Transmitting at %lu, repeat %lu. Press CTRL+C to stop\r\n", frequency, repeat); furi_hal_power_suppress_charge_enter(); + notification_message(notification, &sequence_set_vibro_on); + furi_hal_subghz_start_async_tx(subghz_transmitter_yield, transmitter); while(!(furi_hal_subghz_is_async_tx_complete())) { @@ -84,6 +86,10 @@ static void remote_send_signal(uint32_t frequency, string_t signal, string_t pro fflush(stdout); osDelay(333); } + notification_message(notification, &sequence_reset_vibro); + + furi_record_close("notification"); + furi_hal_subghz_stop_async_tx(); furi_hal_subghz_sleep(); @@ -115,7 +121,6 @@ static void remote_render_callback(Canvas* canvas, void* ctx) { canvas_draw_str(canvas, 0, 36, strings[3]); canvas_draw_str(canvas, 85, 36, strings[4]); canvas_draw_str(canvas, 0, 48, strings[0]); - // canvas_draw_circle(canvas, 100, 26, 25); if(state->press[0]) { string_cat_printf(signal, "%s", string_get_cstr(right_file)); @@ -159,13 +164,15 @@ static void remote_render_callback(Canvas* canvas, void* ctx) { } canvas_draw_str(canvas, 10, 63, "[back] - skip, hold to exit"); - + remote_reset_state(state); release_mutex((ValueMutex*)ctx, state); } static void remote_input_callback(InputEvent* input_event, void* ctx) { - osMessageQueueId_t event_queue = ctx; - osMessageQueuePut(event_queue, input_event, 0, osWaitForever); + if (input_event->type == InputTypeRelease) { + osMessageQueueId_t event_queue = ctx; + osMessageQueuePut(event_queue, input_event, 0, osWaitForever); + } } int32_t universal_rf_remote_app(void* p) { @@ -218,7 +225,7 @@ int32_t universal_rf_remote_app(void* p) { ValueMutex state_mutex; if(!init_mutex(&state_mutex, &_state, sizeof(RemoteAppState))) { FURI_LOG_D(TAG, "cannot create mutex"); - return 0; + return(0); } ViewPort* view_port = view_port_alloc(); @@ -226,7 +233,6 @@ int32_t universal_rf_remote_app(void* p) { view_port_draw_callback_set(view_port, remote_render_callback, &state_mutex); view_port_input_callback_set(view_port, remote_input_callback, event_queue); - // Open GUI and register view_port Gui* gui = furi_record_open("gui"); gui_add_view_port(gui, view_port, GuiLayerFullscreen); @@ -240,58 +246,23 @@ int32_t universal_rf_remote_app(void* p) { input_get_type_name(event.type)); if(event.key == InputKeyRight) { - if(event.type == InputTypePress) { state->press[0] = true; - } else if(event.type == InputTypeRelease) { - state->press[0] = false; - } else if(event.type == InputTypeShort) { - state->press[0] = false; - } } else if(event.key == InputKeyLeft) { - if(event.type == InputTypePress) { state->press[1] = true; - } else if(event.type == InputTypeRelease) { - state->press[1] = false; - } else if(event.type == InputTypeShort) { - state->press[1] = false; - } } else if(event.key == InputKeyUp) { - if(event.type == InputTypePress) { state->press[2] = true; - } else if(event.type == InputTypeRelease) { - state->press[2] = false; - } else if(event.type == InputTypeShort) { - state->press[2] = false; - } } else if(event.key == InputKeyDown) { - if(event.type == InputTypePress) { state->press[3] = true; - } else if(event.type == InputTypeRelease) { - state->press[3] = false; - } else if(event.type == InputTypeShort) { - state->press[3] = false; - } } else if(event.key == InputKeyOk) { - if(event.type == InputTypePress) { state->press[4] = true; - } else if(event.type == InputTypeRelease) { - state->press[4] = false; - } else if(event.type == InputTypeShort) { - state->press[4] = false; - } } else if(event.key == InputKeyBack) { - if(event.type == InputTypeLong) { release_mutex(&state_mutex, state); break; - } else if(event.type == InputTypeShort) { - remote_reset_state(state); - } } release_mutex(&state_mutex, state); view_port_update(view_port); } - // remove & free all stuff created by app gui_remove_view_port(gui, view_port); view_port_free(view_port); osMessageQueueDelete(event_queue); @@ -299,5 +270,5 @@ int32_t universal_rf_remote_app(void* p) { furi_record_close("gui"); - return 0; -} + return(0); +} \ No newline at end of file