From 9a413f4933bde2931c0d1d0c0bd289feb9e4a471 Mon Sep 17 00:00:00 2001 From: Leeroy <135471162+LeeroysHub@users.noreply.github.com> Date: Wed, 13 Dec 2023 18:47:04 +1100 Subject: [PATCH] Added Hold OK to TX, dont have to view key for rollbacks. --- .../main/subghz/helpers/subghz_custom_event.h | 2 + .../main/subghz/helpers/subghz_types.h | 2 +- .../subghz/scenes/subghz_scene_receiver.c | 30 ++++++++++++- applications/main/subghz/views/receiver.c | 42 +++++++++++++------ 4 files changed, 61 insertions(+), 15 deletions(-) diff --git a/applications/main/subghz/helpers/subghz_custom_event.h b/applications/main/subghz/helpers/subghz_custom_event.h index 97b0a7284d..11e77741fc 100644 --- a/applications/main/subghz/helpers/subghz_custom_event.h +++ b/applications/main/subghz/helpers/subghz_custom_event.h @@ -95,6 +95,8 @@ typedef enum { SubGhzCustomEventSceneRpcSessionClose, SubGhzCustomEventViewReceiverOK, + SubGhzCustomEventViewReceiverOKLong, + SubGhzCustomEventViewReceiverOKRelease, SubGhzCustomEventViewReceiverConfig, SubGhzCustomEventViewReceiverBack, SubGhzCustomEventViewReceiverOffDisplay, diff --git a/applications/main/subghz/helpers/subghz_types.h b/applications/main/subghz/helpers/subghz_types.h index 5d939363ef..f03aed0e52 100644 --- a/applications/main/subghz/helpers/subghz_types.h +++ b/applications/main/subghz/helpers/subghz_types.h @@ -53,7 +53,7 @@ typedef enum { SubGhzRxKeyStateExit, SubGhzRxKeyStateRAWLoad, SubGhzRxKeyStateRAWSave, - SubGhzRxKeyStateRepeating, + SubGhzRxKeyStateTX, } SubGhzRxKeyState; /** SubGhzLoadKeyState state */ diff --git a/applications/main/subghz/scenes/subghz_scene_receiver.c b/applications/main/subghz/scenes/subghz_scene_receiver.c index d311559f36..9f7f34170b 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver.c @@ -391,7 +391,7 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) { repeatnormal * tmpTe; furi_timer_start(subghz->fav_timer, repeat_time); } - subghz_rx_key_state_set(subghz, SubGhzRxKeyStateRepeating); + subghz_rx_key_state_set(subghz, SubGhzRxKeyStateTX); break; case SubGhzCustomEventViewRepeaterStop: subghz_txrx_stop(subghz->txrx); @@ -402,11 +402,37 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) { subghz_rx_key_state_set(subghz, SubGhzRxKeyStateStart); subghz->state_notifications = SubGhzNotificationStateRx; break; + case SubGhzCustomEventViewReceiverOKLong: + subghz_txrx_stop(subghz->txrx); + subghz_txrx_hopper_pause(subghz->txrx); + if(!subghz_tx_start( + subghz, + subghz_history_get_raw_data( + subghz->history, + subghz_view_receiver_get_idx_menu(subghz->subghz_receiver)))) { + view_dispatcher_send_custom_event( + subghz->view_dispatcher, SubGhzCustomEventViewReceiverOKRelease); + } else { + subghz->state_notifications = SubGhzNotificationStateTx; + notification_message(subghz->notifications, &subghz_sequence_tx_beep); + } + subghz_rx_key_state_set(subghz, SubGhzRxKeyStateTX); + break; + case SubGhzCustomEventViewReceiverOKRelease: + if(subghz_rx_key_state_get(subghz) == SubGhzRxKeyStateTX) { + subghz_txrx_stop(subghz->txrx); + subghz_txrx_rx_start(subghz->txrx); + subghz_txrx_hopper_unpause(subghz->txrx); + subghz_rx_key_state_set(subghz, SubGhzRxKeyStateStart); + subghz->state_notifications = SubGhzNotificationStateRx; + break; + } + break; default: break; } } else if(event.type == SceneManagerEventTypeTick) { - if(subghz_rx_key_state_get(subghz) != SubGhzRxKeyStateRepeating) { + if(subghz_rx_key_state_get(subghz) != SubGhzRxKeyStateTX) { if(subghz_txrx_hopper_get_state(subghz->txrx) != SubGhzHopperStateOFF) { subghz_txrx_hopper_update(subghz->txrx); subghz_scene_receiver_update_statusbar(subghz); diff --git a/applications/main/subghz/views/receiver.c b/applications/main/subghz/views/receiver.c index 11dbae2d03..e2b3a1a467 100644 --- a/applications/main/subghz/views/receiver.c +++ b/applications/main/subghz/views/receiver.c @@ -550,18 +550,36 @@ bool subghz_view_receiver_input(InputEvent* event, void* context) { }, false); consumed = true; - } else if(event->key == InputKeyOk && event->type == InputTypeShort) { - with_view_model( - subghz_receiver->view, - SubGhzViewReceiverModel * model, - { - if(model->history_item != 0) { - subghz_receiver->callback( - SubGhzCustomEventViewReceiverOK, subghz_receiver->context); - } - }, - false); - consumed = true; + } else if(event->key == InputKeyOk) { + SubGhzCustomEvent new_event; + + switch(event->type) { + case InputTypeShort: + new_event = SubGhzCustomEventViewReceiverOK; + break; + case InputTypeLong: + new_event = SubGhzCustomEventViewReceiverOKLong; + break; + case InputTypeRelease: + new_event = SubGhzCustomEventViewReceiverOKRelease; + break; + default: + new_event = 0; + break; + } + + if(new_event) { + with_view_model( + subghz_receiver->view, + SubGhzViewReceiverModel * model, + { + if(model->history_item != 0) { + subghz_receiver->callback(new_event, subghz_receiver->context); + } + }, + false); + consumed = true; + } } if(consumed) {