From ec7e6a0ac13598532878f484855a8f0ecbfc77cc Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Thu, 11 May 2023 13:22:02 +0300 Subject: [PATCH] Using scene manager functions in DecodeRAW --- applications/main/subghz/helpers/subghz_types.h | 6 ++++++ .../subghz/scenes/subghz_scene_decode_raw.c | 17 +++++++++-------- .../subghz/scenes/subghz_scene_receiver_info.c | 9 ++------- .../main/subghz/scenes/subghz_scene_save_name.c | 2 +- .../subghz/scenes/subghz_scene_save_success.c | 11 ++++------- applications/main/subghz/subghz.c | 3 --- applications/main/subghz/subghz_i.h | 10 ---------- 7 files changed, 22 insertions(+), 36 deletions(-) diff --git a/applications/main/subghz/helpers/subghz_types.h b/applications/main/subghz/helpers/subghz_types.h index 700049237..1cddfc8d5 100644 --- a/applications/main/subghz/helpers/subghz_types.h +++ b/applications/main/subghz/helpers/subghz_types.h @@ -91,3 +91,9 @@ typedef enum { SubGhzViewReceiverModeLive, SubGhzViewReceiverModeFile, } SubGhzViewReceiverMode; + +typedef enum { + SubGhzDecodeRawStateStart, + SubGhzDecodeRawStateLoading, + SubGhzDecodeRawStateLoaded, +} SubGhzDecodeRawState; \ No newline at end of file diff --git a/applications/main/subghz/scenes/subghz_scene_decode_raw.c b/applications/main/subghz/scenes/subghz_scene_decode_raw.c index 54c729cc3..e88da3749 100644 --- a/applications/main/subghz/scenes/subghz_scene_decode_raw.c +++ b/applications/main/subghz/scenes/subghz_scene_decode_raw.c @@ -120,7 +120,8 @@ bool subghz_scene_decode_raw_next(SubGhz* subghz) { uint32_t duration = level_duration_get_duration(level_duration); subghz_receiver_decode(receiver, level, duration); } else { - subghz->decode_raw_state = SubGhzDecodeRawStateLoaded; + scene_manager_set_scene_state( + subghz->scene_manager, SubGhzSceneDecodeRAW, SubGhzDecodeRawStateLoaded); subghz->state_notifications = SubGhzNotificationStateIDLE; subghz_view_receiver_add_data_progress(subghz->subghz_receiver, "Done!"); @@ -155,11 +156,13 @@ void subghz_scene_decode_raw_on_enter(void* context) { subghz_txrx_receiver_set_filter(subghz->txrx, SubGhzProtocolFlag_Decodable); - if(subghz->decode_raw_state == SubGhzDecodeRawStateStart) { + if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneDecodeRAW) == + SubGhzDecodeRawStateStart) { //Decode RAW to history subghz_history_reset(subghz->history); if(subghz_scene_decode_raw_start(subghz)) { - subghz->decode_raw_state = SubGhzDecodeRawStateLoading; + scene_manager_set_scene_state( + subghz->scene_manager, SubGhzSceneDecodeRAW, SubGhzDecodeRawStateLoading); subghz->state_notifications = SubGhzNotificationStateRx; } } else { @@ -192,10 +195,9 @@ bool subghz_scene_decode_raw_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { case SubGhzCustomEventViewReceiverBack: - subghz->decode_raw_state = SubGhzDecodeRawStateStart; + scene_manager_set_scene_state( + subghz->scene_manager, SubGhzSceneDecodeRAW, SubGhzDecodeRawStateStart); subghz->idx_menu_chosen = 0; - subghz->in_decoder_scene = false; - subghz->in_decoder_scene_skip = false; subghz_txrx_set_rx_calback(subghz->txrx, NULL, subghz); @@ -214,7 +216,6 @@ bool subghz_scene_decode_raw_on_event(void* context, SceneManagerEvent event) { case SubGhzCustomEventViewReceiverOK: subghz->idx_menu_chosen = subghz_view_receiver_get_idx_menu(subghz->subghz_receiver); subghz->state_notifications = SubGhzNotificationStateIDLE; - subghz->in_decoder_scene = true; scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverInfo); consumed = true; break; @@ -242,7 +243,7 @@ bool subghz_scene_decode_raw_on_event(void* context, SceneManagerEvent event) { break; } - switch(subghz->decode_raw_state) { + switch(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneDecodeRAW)) { case SubGhzDecodeRawStateLoading: subghz_scene_decode_raw_next(subghz); break; diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_info.c b/applications/main/subghz/scenes/subghz_scene_receiver_info.c index 370638931..2d89de731 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_info.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_info.c @@ -141,7 +141,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) subghz_scene_receiver_info_draw_widget(subghz); subghz_txrx_stop(subghz->txrx); - if(!subghz->in_decoder_scene) { + if(!scene_manager_has_previous_scene(subghz->scene_manager, SubGhzSceneDecodeRAW)) { subghz_txrx_rx_start(subghz->txrx); subghz_txrx_hopper_unpause(subghz->txrx); @@ -161,9 +161,6 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) if(subghz_txrx_protocol_is_serializable(subghz->txrx)) { subghz_file_name_clear(subghz); - if(subghz->in_decoder_scene) { - subghz->in_decoder_scene_skip = true; - } scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName); } return true; @@ -192,9 +189,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) void subghz_scene_receiver_info_on_exit(void* context) { SubGhz* subghz = context; - if(subghz->in_decoder_scene && !subghz->in_decoder_scene_skip) { - subghz->in_decoder_scene = false; - } + widget_reset(subghz->widget); keeloq_reset_mfname(); keeloq_reset_kl_type(); diff --git a/applications/main/subghz/scenes/subghz_scene_save_name.c b/applications/main/subghz/scenes/subghz_scene_save_name.c index b0c3a1b12..74a861efb 100644 --- a/applications/main/subghz/scenes/subghz_scene_save_name.c +++ b/applications/main/subghz/scenes/subghz_scene_save_name.c @@ -127,7 +127,7 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) { if(!(strcmp(subghz->file_name_tmp, "") == 0) || scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) != SubGhzCustomEventManagerNoSet) { - if(!subghz->in_decoder_scene) { + if(!scene_manager_has_previous_scene(subghz->scene_manager, SubGhzSceneDecodeRAW)) { furi_string_set(subghz->file_path, subghz->file_path_tmp); } } diff --git a/applications/main/subghz/scenes/subghz_scene_save_success.c b/applications/main/subghz/scenes/subghz_scene_save_success.c index 0d0f9059e..6a5346492 100644 --- a/applications/main/subghz/scenes/subghz_scene_save_success.c +++ b/applications/main/subghz/scenes/subghz_scene_save_success.c @@ -24,7 +24,7 @@ bool subghz_scene_save_success_on_event(void* context, SceneManagerEvent event) SubGhz* subghz = context; if(event.type == SceneManagerEventTypeCustom) { if(event.event == SubGhzCustomEventSceneSaveSuccess) { - if(!subghz->in_decoder_scene) { + if(!scene_manager_has_previous_scene(subghz->scene_manager, SubGhzSceneDecodeRAW)) { if(!scene_manager_search_and_switch_to_previous_scene( subghz->scene_manager, SubGhzSceneReceiver)) { subghz_rx_key_state_set(subghz, SubGhzRxKeyStateRAWSave); @@ -38,7 +38,9 @@ bool subghz_scene_save_success_on_event(void* context, SceneManagerEvent event) } } } else { - subghz->decode_raw_state = SubGhzDecodeRawStateStart; + scene_manager_set_scene_state( + subghz->scene_manager, SubGhzSceneDecodeRAW, SubGhzDecodeRawStateStart); + subghz->idx_menu_chosen = 0; subghz_txrx_set_rx_calback(subghz->txrx, NULL, subghz); @@ -64,11 +66,6 @@ bool subghz_scene_save_success_on_event(void* context, SceneManagerEvent event) void subghz_scene_save_success_on_exit(void* context) { SubGhz* subghz = context; - if(subghz->in_decoder_scene) { - subghz->in_decoder_scene = false; - subghz->in_decoder_scene_skip = false; - } - // Clear view Popup* popup = subghz->popup; diff --git a/applications/main/subghz/subghz.c b/applications/main/subghz/subghz.c index 4f4393efb..d30bd79f2 100644 --- a/applications/main/subghz/subghz.c +++ b/applications/main/subghz/subghz.c @@ -60,9 +60,6 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) { // GUI subghz->gui = furi_record_open(RECORD_GUI); - subghz->in_decoder_scene = false; - subghz->in_decoder_scene_skip = false; - // View Dispatcher subghz->view_dispatcher = view_dispatcher_alloc(); view_dispatcher_enable_queue(subghz->view_dispatcher); diff --git a/applications/main/subghz/subghz_i.h b/applications/main/subghz/subghz_i.h index 785a6708f..3d1c2db9c 100644 --- a/applications/main/subghz/subghz_i.h +++ b/applications/main/subghz/subghz_i.h @@ -54,12 +54,6 @@ typedef struct { uint8_t seed[4]; } SecureData; -typedef enum { - SubGhzDecodeRawStateStart, - SubGhzDecodeRawStateLoading, - SubGhzDecodeRawStateLoaded, -} SubGhzDecodeRawState; - struct SubGhz { Gui* gui; NotificationApp* notifications; @@ -98,16 +92,12 @@ struct SubGhz { FuriString* error_str; SubGhzLock lock; - bool in_decoder_scene; - bool in_decoder_scene_skip; - bool ignore_starline; bool ignore_auto_alarms; bool ignore_magellan; SecureData* secure_data; - SubGhzDecodeRawState decode_raw_state; SubGhzFileEncoderWorker* decode_raw_file_worker_encoder; SubGhzThresholdRssi* threshold_rssi;