diff --git a/applications/main/subghz/scenes/subghz_scene_receiver.c b/applications/main/subghz/scenes/subghz_scene_receiver.c index 7dd7d3993..8de7870a8 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver.c @@ -215,7 +215,7 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) { // Stop CC1101 Rx subghz->state_notifications = SubGhzNotificationStateIDLE; subghz_txrx_stop(subghz); - subghz->txrx->hopper_state = SubGhzHopperStateOFF; + subghz_hopper_set_state(subghz, SubGhzHopperStateOFF); subghz->txrx->idx_menu_chosen = 0; subghz_receiver_set_rx_callback(subghz->txrx->receiver, NULL, subghz); @@ -269,7 +269,7 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) { break; } } else if(event.type == SceneManagerEventTypeTick) { - if(subghz->txrx->hopper_state != SubGhzHopperStateOFF) { + if(subghz_hopper_get_state(subghz) != SubGhzHopperStateOFF) { subghz_hopper_update(subghz); subghz_scene_receiver_update_statusbar(subghz); } diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_config.c b/applications/main/subghz/scenes/subghz_scene_receiver_config.c index bd9780428..ef8ffc9bd 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_config.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_config.c @@ -143,7 +143,7 @@ static void subghz_scene_receiver_config_set_frequency(VariableItem* item) { SubGhz* subghz = variable_item_get_context(item); uint8_t index = variable_item_get_current_value_index(item); - if(subghz->txrx->hopper_state == SubGhzHopperStateOFF) { + if(subghz_hopper_get_state(subghz) == SubGhzHopperStateOFF) { char text_buf[10] = {0}; snprintf( text_buf, @@ -209,7 +209,7 @@ static void subghz_scene_receiver_config_set_hopping_running(VariableItem* item) subghz_setting_get_frequency_default_index(subghz->setting)); } - subghz->txrx->hopper_state = hopping_value[index]; + subghz_hopper_set_state(subghz, hopping_value[index]); } static void subghz_scene_receiver_config_set_speaker(VariableItem* item) { @@ -317,7 +317,7 @@ void subghz_scene_receiver_config_on_enter(void* context) { subghz_scene_receiver_config_set_hopping_running, subghz); value_index = subghz_scene_receiver_config_hopper_value_index( - subghz->txrx->hopper_state, hopping_value, HOPPING_COUNT, subghz); + subghz_hopper_get_state(subghz), hopping_value, HOPPING_COUNT, subghz); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, hopping_text[value_index]); } diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_info.c b/applications/main/subghz/scenes/subghz_scene_receiver_info.c index 13095b081..dd637c1eb 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_info.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_info.c @@ -122,9 +122,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) if(event.type == SceneManagerEventTypeCustom) { if(event.event == SubGhzCustomEventSceneReceiverInfoTxStart) { //CC1101 Stop RX -> Start TX - if(subghz->txrx->hopper_state != SubGhzHopperStateOFF) { - subghz->txrx->hopper_state = SubGhzHopperStatePause; - } + subghz_subghz_hopper_set_pause(subghz); subghz_txrx_stop(subghz); @@ -142,9 +140,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) subghz_setting_get_preset_data_by_name( subghz->setting, furi_string_get_cstr(subghz->txrx->preset->name))); subghz_rx(subghz, subghz->txrx->preset->frequency); - if(subghz->txrx->hopper_state == SubGhzHopperStatePause) { - subghz->txrx->hopper_state = SubGhzHopperStateRunning; - } + subghz_hopper_remove_pause(subghz); subghz->state_notifications = SubGhzNotificationStateRx; } else { subghz->state_notifications = SubGhzNotificationStateTx; @@ -165,16 +161,14 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) subghz->setting, furi_string_get_cstr(subghz->txrx->preset->name))); subghz_rx(subghz, subghz->txrx->preset->frequency); - if(subghz->txrx->hopper_state == SubGhzHopperStatePause) { - subghz->txrx->hopper_state = SubGhzHopperStateRunning; - } + subghz_hopper_remove_pause(subghz); subghz->state_notifications = SubGhzNotificationStateRx; } return true; } else if(event.event == SubGhzCustomEventSceneReceiverInfoSave) { //CC1101 Stop RX -> Save subghz->state_notifications = SubGhzNotificationStateIDLE; - subghz->txrx->hopper_state = SubGhzHopperStateOFF; + subghz_hopper_set_state(subghz, SubGhzHopperStateOFF); subghz_txrx_stop(subghz); if(!subghz_scene_receiver_info_update_parser(subghz)) { @@ -193,7 +187,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) return true; } } else if(event.type == SceneManagerEventTypeTick) { - if(subghz->txrx->hopper_state != SubGhzHopperStateOFF) { + if(subghz_hopper_get_state(subghz) != SubGhzHopperStateOFF) { subghz_hopper_update(subghz); } switch(subghz->state_notifications) { diff --git a/applications/main/subghz/subghz.c b/applications/main/subghz/subghz.c index 4bbdba6c5..7e35346b8 100644 --- a/applications/main/subghz/subghz.c +++ b/applications/main/subghz/subghz.c @@ -271,7 +271,7 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) { subghz, "AM650", subghz_setting_get_default_frequency(subghz->setting), NULL, 0); } subghz->txrx->txrx_state = SubGhzTxRxStateSleep; - subghz->txrx->hopper_state = SubGhzHopperStateOFF; + subghz_hopper_set_state(subghz, SubGhzHopperStateOFF); subghz->txrx->speaker_state = SubGhzSpeakerStateDisable; subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE; subghz->txrx->debug_pin_state = false; diff --git a/applications/main/subghz/subghz_i.c b/applications/main/subghz/subghz_i.c index bf9823cea..194b404db 100644 --- a/applications/main/subghz/subghz_i.c +++ b/applications/main/subghz/subghz_i.c @@ -629,6 +629,30 @@ void subghz_hopper_update(SubGhz* subghz) { } } +SubGhzHopperState subghz_hopper_get_state(SubGhz* subghz) { + furi_assert(subghz); + return subghz->txrx->hopper_state; +} + +void subghz_hopper_set_state(SubGhz* subghz, SubGhzHopperState state) { + furi_assert(subghz); + subghz->txrx->hopper_state = state; +} + +void subghz_hopper_remove_pause(SubGhz* subghz) { + furi_assert(subghz); + if(subghz->txrx->hopper_state == SubGhzHopperStatePause) { + subghz->txrx->hopper_state = SubGhzHopperStateRunning; + } +} + +void subghz_subghz_hopper_set_pause(SubGhz* subghz) { + furi_assert(subghz); + if(subghz->txrx->hopper_state == SubGhzHopperStateOFF) { + subghz->txrx->hopper_state = SubGhzHopperStatePause; + } +} + void subghz_speaker_on(SubGhz* subghz) { if(subghz->txrx->debug_pin_state) { furi_hal_subghz_set_async_mirror_pin(&gpio_ibutton); diff --git a/applications/main/subghz/subghz_i.h b/applications/main/subghz/subghz_i.h index 5969d85cb..f772c388c 100644 --- a/applications/main/subghz/subghz_i.h +++ b/applications/main/subghz/subghz_i.h @@ -180,6 +180,10 @@ void subghz_speaker_unmute(SubGhz* subghz); void subghz_txrx_stop(SubGhz* subghz); SubGhzTxRxState subghz_txrx_get_state(SubGhz* subghz); +SubGhzHopperState subghz_hopper_get_state(SubGhz* subghz); +void subghz_hopper_set_state(SubGhz* subghz, SubGhzHopperState state); +void subghz_hopper_remove_pause(SubGhz* subghz); +void subghz_subghz_hopper_set_pause(SubGhz* subghz); extern const NotificationSequence subghz_sequence_rx; extern const NotificationSequence subghz_sequence_rx_locked;