diff --git a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h index 0c999d5e5..0e0ab94ef 100644 --- a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h +++ b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h @@ -17,7 +17,6 @@ typedef enum { SubRemCustomEventViewRemoteStartRIGHT, SubRemCustomEventViewRemoteStartOK, SubRemCustomEventViewRemoteStop, - SubRemCustomEventViewRemoteForceStop, // SubRemCustomEventSceneDeleteSuccess = 100, // SubRemCustomEventSceneDelete, diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c b/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c index f7da910ab..58e253d1c 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c @@ -1,8 +1,6 @@ #include "../subghz_remote_app_i.h" #include "../views/transmitter.h" -#include - // TODO: // #include // #include @@ -15,12 +13,6 @@ void subrem_scene_remote_callback(SubRemCustomEvent event, void* context) { view_dispatcher_send_custom_event(app->view_dispatcher, event); } -void subrem_scene_remote_raw_callback_end_tx(void* context) { - furi_assert(context); - SubGhzRemoteApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, SubRemCustomEventViewRemoteForceStop); -} - bool subrem_scene_remote_update_data_show(void* context) { SubGhzRemoteApp* app = context; //UNUSED(app); @@ -121,65 +113,12 @@ bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { app->scene_manager, SubRemSceneStart); return true; } else if(event.event == SubRemCustomEventViewRemoteStartUP) { - if(subghz_tx_start_sub( - app, app->subs_preset[0], subrem_scene_remote_raw_callback_end_tx)) { - app->chusen_sub = 0; - subrem_view_remote_set_state(app->subrem_remote_view, 1); + if(subghz_tx_start_sub(app, app->subs_preset[0])) { notification_message(app->notifications, &sequence_blink_start_magenta); } - return true; - } else if(event.event == SubRemCustomEventViewRemoteStartDOWN) { - if(subghz_tx_start_sub( - app, app->subs_preset[1], subrem_scene_remote_raw_callback_end_tx)) { - app->chusen_sub = 1; - subrem_view_remote_set_state(app->subrem_remote_view, 2); - notification_message(app->notifications, &sequence_blink_start_magenta); - } - return true; - } else if(event.event == SubRemCustomEventViewRemoteStartLEFT) { - if(subghz_tx_start_sub( - app, app->subs_preset[2], subrem_scene_remote_raw_callback_end_tx)) { - app->chusen_sub = 2; - subrem_view_remote_set_state(app->subrem_remote_view, 3); - notification_message(app->notifications, &sequence_blink_start_magenta); - } - return true; - } else if(event.event == SubRemCustomEventViewRemoteStartRIGHT) { - if(subghz_tx_start_sub( - app, app->subs_preset[3], subrem_scene_remote_raw_callback_end_tx)) { - app->chusen_sub = 3; - subrem_view_remote_set_state(app->subrem_remote_view, 4); - notification_message(app->notifications, &sequence_blink_start_magenta); - } - return true; - } else if(event.event == SubRemCustomEventViewRemoteStartOK) { - if(subghz_tx_start_sub( - app, app->subs_preset[4], subrem_scene_remote_raw_callback_end_tx)) { - app->chusen_sub = 4; - subrem_view_remote_set_state(app->subrem_remote_view, 5); - notification_message(app->notifications, &sequence_blink_start_magenta); - } - return true; - } else if(event.event == SubRemCustomEventViewRemoteForceStop) { - if(app->tx_running) { - subghz_tx_stop_sub(app); - subrem_view_remote_set_state(app->subrem_remote_view, 0); - } - notification_message(app->notifications, &sequence_blink_stop); - return true; } else if(event.event == SubRemCustomEventViewRemoteStop) { - // if(app->tx_running && - // (app->subs_preset[app->chusen_sub]->type == SubRemSubKeyTypeRawKey)) { - // subghz_tx_stop_sub(app); - // subrem_view_remote_set_state(app->subrem_remote_view, 0); - // } - // notification_message(app->notifications, &sequence_blink_stop); - if(app->tx_running) { - subghz_tx_stop_sub(app); - subrem_view_remote_set_state(app->subrem_remote_view, 0); - } + subghz_tx_stop_sub(app, app->subs_preset[0]); notification_message(app->notifications, &sequence_blink_stop); - return true; } // notification_message(app->notification, &sequence_blink_stop); diff --git a/applications/external/subghz_remote_new/subghz_remote_app.c b/applications/external/subghz_remote_new/subghz_remote_app.c index 17a559da8..1bfa3a1b3 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app.c +++ b/applications/external/subghz_remote_new/subghz_remote_app.c @@ -137,8 +137,6 @@ SubGhzRemoteApp* subghz_remote_app_alloc() { app->receiver = subghz_receiver_alloc_init(app->environment); - app->tx_running = false; - scene_manager_next_scene(app->scene_manager, SubRemSceneStart); return app; diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.c b/applications/external/subghz_remote_new/subghz_remote_app_i.c index ef22a9e6d..7ebad702f 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.c +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.c @@ -115,10 +115,7 @@ static bool subrem_sub_file_presets_load(SubGhzRemoteApp* app, FlipperFormat* ff return ret; } -bool subghz_tx_start_sub( - SubGhzRemoteApp* app, - SubRemSubFilePreset* sub_preset, - SubGhzProtocolEncoderRAWCallbackEnd callback) { +bool subghz_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) { furi_assert(app); furi_assert(sub_preset); bool ret = false; @@ -155,26 +152,19 @@ bool subghz_tx_start_sub( break; } - if(sub_preset->type == SubRemSubKeyTypeRawKey) { - subghz_protocol_raw_file_encoder_worker_set_callback_end( - (SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance( - app->transmitter), - callback, - app); - } - furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->transmitter); ret = true; } } while(false); - app->tx_running = ret; // TODO: + // ret = false; // TODO: return ret; } -void subghz_tx_stop_sub(SubGhzRemoteApp* app) { +void subghz_tx_stop_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset) { furi_assert(app); + furi_assert(sub_preset); //Stop TX furi_hal_subghz_stop_async_tx(); @@ -183,10 +173,7 @@ void subghz_tx_stop_sub(SubGhzRemoteApp* app) { subghz_transmitter_free(app->transmitter); furi_hal_subghz_idle(); - // SubRemSubFilePreset* sub_preset = app->subs_preset[app->chusen_sub]; - // TODO: need saving logic - app->tx_running = false; } static bool subrem_sub_presets_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.h b/applications/external/subghz_remote_new/subghz_remote_app_i.h index 13f3d63c5..d954eca02 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.h +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.h @@ -18,8 +18,6 @@ #include #include -#include - #include #include #include @@ -77,10 +75,6 @@ typedef struct { SubGhzReceiver* receiver; SubGhzTransmitter* transmitter; - bool tx_running; - - uint8_t chusen_sub; - // AvrIspProgrammerView* subghz_remote_programmer_view; // AvrIspReaderView* subghz_remote_reader_view; // AvrIspWriterView* subghz_remote_writer_view; @@ -91,8 +85,5 @@ typedef struct { bool subrem_load_from_file(SubGhzRemoteApp* app); -bool subghz_tx_start_sub( - SubGhzRemoteApp* app, - SubRemSubFilePreset* sub_preset, - SubGhzProtocolEncoderRAWCallbackEnd callback); -void subghz_tx_stop_sub(SubGhzRemoteApp* app); \ No newline at end of file +bool subghz_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset); +void subghz_tx_stop_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset); \ No newline at end of file diff --git a/applications/external/subghz_remote_new/views/transmitter.c b/applications/external/subghz_remote_new/views/transmitter.c index a814880f9..6f43a1406 100644 --- a/applications/external/subghz_remote_new/views/transmitter.c +++ b/applications/external/subghz_remote_new/views/transmitter.c @@ -85,15 +85,6 @@ void subrem_view_remote_add_data_to_show( true); } -void subrem_view_remote_set_state(SubRemViewRemote* subrem_view_remote, uint8_t state) { - furi_assert(subrem_view_remote); - with_view_model( - subrem_view_remote->view, - SubRemViewRemoteModel * model, - { model->pressed_btn = state; }, - true); -} - void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { canvas_clear(canvas); canvas_set_color(canvas, ColorBlack); @@ -148,10 +139,10 @@ void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) { canvas_draw_icon_ex(canvas, 116, 17, &I_Pin_arrow_up_7x9, IconRotation180); break; case 3: - canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation270); + canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation90); break; case 4: - canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation90); + canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation270); break; case 5: canvas_draw_icon(canvas, 116, 18, &I_Pin_star_7x7); @@ -186,51 +177,28 @@ bool subrem_view_remote_input(InputEvent* event, void* context) { // furi_string_reset(model->ok_label); }, false); - return false; // TODO: check - } else if(event->key == InputKeyBack && event->type == InputTypeShort) { - with_view_model( - subrem_view_remote->view, - SubRemViewRemoteModel * model, - { model->pressed_btn = 0; }, - true); - subrem_view_remote->callback( - SubRemCustomEventViewRemoteForceStop, subrem_view_remote->context); - return true; - } else if(event->key == InputKeyBack) { - return true; + return false; + } else if(event->key == InputKeyUp) { + if(event->type == InputTypePress) { + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { model->pressed_btn = 1; }, + true); + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStartUP, subrem_view_remote->context); + return true; + } else if(event->type == InputTypeRelease) { + with_view_model( + subrem_view_remote->view, + SubRemViewRemoteModel * model, + { model->pressed_btn = 0; }, + true); + subrem_view_remote->callback( + SubRemCustomEventViewRemoteStop, subrem_view_remote->context); + return true; + } } - // BACK button processing end - - if(event->key == InputKeyUp && event->type == InputTypePress) { - subrem_view_remote->callback( - SubRemCustomEventViewRemoteStartUP, subrem_view_remote->context); - return true; - } else if(event->key == InputKeyDown && event->type == InputTypePress) { - subrem_view_remote->callback( - SubRemCustomEventViewRemoteStartDOWN, subrem_view_remote->context); - return true; - } else if(event->key == InputKeyLeft && event->type == InputTypePress) { - subrem_view_remote->callback( - SubRemCustomEventViewRemoteStartLEFT, subrem_view_remote->context); - return true; - } else if(event->key == InputKeyRight && event->type == InputTypePress) { - subrem_view_remote->callback( - SubRemCustomEventViewRemoteStartRIGHT, subrem_view_remote->context); - return true; - } else if(event->key == InputKeyOk && event->type == InputTypePress) { - subrem_view_remote->callback( - SubRemCustomEventViewRemoteStartOK, subrem_view_remote->context); - return true; - } else if(event->type == InputTypeRelease) { - with_view_model( - subrem_view_remote->view, - SubRemViewRemoteModel * model, - { model->pressed_btn = 0; }, - true); - subrem_view_remote->callback(SubRemCustomEventViewRemoteStop, subrem_view_remote->context); - return true; - } - return true; } diff --git a/applications/external/subghz_remote_new/views/transmitter.h b/applications/external/subghz_remote_new/views/transmitter.h index 64985ff12..a324d09ec 100644 --- a/applications/external/subghz_remote_new/views/transmitter.h +++ b/applications/external/subghz_remote_new/views/transmitter.h @@ -24,6 +24,4 @@ void subrem_view_remote_add_data_to_show( const char* down_label, const char* left_label, const char* right_label, - const char* ok_label); - -void subrem_view_remote_set_state(SubRemViewRemote* subrem_view_remote, uint8_t state); \ No newline at end of file + const char* ok_label); \ No newline at end of file