Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
Added Hold OK to TX, dont have to view key for rollbacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeroysHub committed Dec 13, 2023
1 parent 6610be0 commit 4657604
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 15 deletions.
2 changes: 2 additions & 0 deletions applications/main/subghz/helpers/subghz_custom_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ typedef enum {
SubGhzCustomEventSceneRpcSessionClose,

SubGhzCustomEventViewReceiverOK,
SubGhzCustomEventViewReceiverOKLong,
SubGhzCustomEventViewReceiverOKRelease,
SubGhzCustomEventViewReceiverConfig,
SubGhzCustomEventViewReceiverBack,
SubGhzCustomEventViewReceiverOffDisplay,
Expand Down
2 changes: 1 addition & 1 deletion applications/main/subghz/helpers/subghz_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ typedef enum {
SubGhzRxKeyStateExit,
SubGhzRxKeyStateRAWLoad,
SubGhzRxKeyStateRAWSave,
SubGhzRxKeyStateRepeating,
SubGhzRxKeyStateTX,
} SubGhzRxKeyState;

/** SubGhzLoadKeyState state */
Expand Down
30 changes: 28 additions & 2 deletions applications/main/subghz/scenes/subghz_scene_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
42 changes: 30 additions & 12 deletions applications/main/subghz/views/receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4657604

Please sign in to comment.