Added Hold OK to TX, dont have to view key for rollbacks.

This commit is contained in:
Leeroy
2023-12-13 18:47:04 +11:00
parent 6610be054a
commit 46576047a2
4 changed files with 61 additions and 15 deletions

View File

@@ -95,6 +95,8 @@ typedef enum {
SubGhzCustomEventSceneRpcSessionClose,
SubGhzCustomEventViewReceiverOK,
SubGhzCustomEventViewReceiverOKLong,
SubGhzCustomEventViewReceiverOKRelease,
SubGhzCustomEventViewReceiverConfig,
SubGhzCustomEventViewReceiverBack,
SubGhzCustomEventViewReceiverOffDisplay,

View File

@@ -53,7 +53,7 @@ typedef enum {
SubGhzRxKeyStateExit,
SubGhzRxKeyStateRAWLoad,
SubGhzRxKeyStateRAWSave,
SubGhzRxKeyStateRepeating,
SubGhzRxKeyStateTX,
} SubGhzRxKeyState;
/** SubGhzLoadKeyState state */

View File

@@ -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);

View File

@@ -550,19 +550,37 @@ bool subghz_view_receiver_input(InputEvent* event, void* context) {
},
false);
consumed = true;
} else if(event->key == InputKeyOk && event->type == InputTypeShort) {
} 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(
SubGhzCustomEventViewReceiverOK, subghz_receiver->context);
subghz_receiver->callback(new_event, subghz_receiver->context);
}
},
false);
consumed = true;
}
}
if(consumed) {
subghz_view_receiver_update_offset(subghz_receiver);