diff --git a/applications/main/subghz/helpers/subghz_custom_event.h b/applications/main/subghz/helpers/subghz_custom_event.h index 97b0a7284..11e77741f 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 5d939363e..f03aed0e5 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 d311559f3..9f7f34170 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 b8b839cdd..e6baf8242 100644 --- a/applications/main/subghz/views/receiver.c +++ b/applications/main/subghz/views/receiver.c @@ -532,18 +532,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) {