From b48103196fcab783d236c82b4b6be6cd88d887c2 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sat, 30 Dec 2023 02:43:15 +0300 Subject: [PATCH] subghz revert previous "fix" and do proper fix and thanks to Willy-JL ! --- .../subghz/scenes/subghz_scene_receiver.c | 3 +- applications/main/subghz/views/receiver.c | 40 +++++++++---------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_receiver.c b/applications/main/subghz/scenes/subghz_scene_receiver.c index 51063c999..118a8bc1c 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver.c @@ -180,7 +180,6 @@ void subghz_scene_receiver_on_enter(void* context) { subghz->idx_menu_chosen = 0; } - subghz_view_receiver_set_lock(subghz->subghz_receiver, subghz_is_locked(subghz)); subghz_view_receiver_set_mode(subghz->subghz_receiver, SubGhzViewReceiverModeLive); // Load history to receiver @@ -224,6 +223,8 @@ void subghz_scene_receiver_on_enter(void* context) { subghz_scene_receiver_update_statusbar(subghz); + subghz_view_receiver_set_lock(subghz->subghz_receiver, subghz_is_locked(subghz)); + view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdReceiver); } diff --git a/applications/main/subghz/views/receiver.c b/applications/main/subghz/views/receiver.c index 1eb4d0460..88e3c31e4 100644 --- a/applications/main/subghz/views/receiver.c +++ b/applications/main/subghz/views/receiver.c @@ -101,24 +101,6 @@ void subghz_receiver_rssi(SubGhzViewReceiver* instance, float rssi) { true); } -static void subghz_view_receiver_timer_callback(void* context) { - furi_assert(context); - SubGhzViewReceiver* subghz_receiver = context; - with_view_model( - subghz_receiver->view, - SubGhzViewReceiverModel * model, - { model->bar_show = SubGhzViewReceiverBarShowDefault; }, - true); - if(subghz_receiver->lock_count < UNLOCK_CNT) { - subghz_receiver->callback( - SubGhzCustomEventViewReceiverOffDisplay, subghz_receiver->context); - } else { - subghz_receiver->lock = false; - subghz_receiver->callback(SubGhzCustomEventViewReceiverUnlock, subghz_receiver->context); - } - subghz_receiver->lock_count = 0; -} - void subghz_view_receiver_set_lock(SubGhzViewReceiver* subghz_receiver, bool lock) { furi_assert(subghz_receiver); subghz_receiver->lock_count = 0; @@ -130,7 +112,6 @@ void subghz_view_receiver_set_lock(SubGhzViewReceiver* subghz_receiver, bool loc { model->bar_show = SubGhzViewReceiverBarShowLock; }, true); furi_timer_start(subghz_receiver->timer, 1000); - subghz_view_receiver_timer_callback(subghz_receiver); } else { with_view_model( subghz_receiver->view, @@ -443,6 +424,21 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) { } } +static void subghz_view_receiver_timer_callback(void* context) { + furi_assert(context); + SubGhzViewReceiver* subghz_receiver = context; + with_view_model( + subghz_receiver->view, + SubGhzViewReceiverModel * model, + { model->bar_show = SubGhzViewReceiverBarShowDefault; }, + true); + if(subghz_receiver->lock_count < UNLOCK_CNT) { + subghz_receiver->callback( + SubGhzCustomEventViewReceiverOffDisplay, subghz_receiver->context); + } + subghz_receiver->lock_count = 0; +} + bool subghz_view_receiver_input(InputEvent* event, void* context) { furi_assert(context); SubGhzViewReceiver* subghz_receiver = context; @@ -460,14 +456,14 @@ bool subghz_view_receiver_input(InputEvent* event, void* context) { subghz_receiver->lock_count++; } if(subghz_receiver->lock_count >= UNLOCK_CNT) { - // subghz_receiver->callback( - // SubGhzCustomEventViewReceiverUnlock, subghz_receiver->context); + subghz_receiver->callback( + SubGhzCustomEventViewReceiverUnlock, subghz_receiver->context); with_view_model( subghz_receiver->view, SubGhzViewReceiverModel * model, { model->bar_show = SubGhzViewReceiverBarShowUnlock; }, true); - //subghz_receiver->lock = false; + subghz_receiver->lock = false; furi_timer_start(subghz_receiver->timer, 650); }