From e65a5e2b7cb8d34b15318f8aebeb528b856d01ba Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Sat, 6 May 2023 17:56:10 +0300 Subject: [PATCH] SubGhz: remove direct reading subghz->txrx->speaker_state --- .../main/subghz/scenes/subghz_scene_receiver_config.c | 5 +++-- applications/main/subghz/subghz.c | 2 +- applications/main/subghz/subghz_i.c | 10 ++++++++++ applications/main/subghz/subghz_i.h | 5 ++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_config.c b/applications/main/subghz/scenes/subghz_scene_receiver_config.c index 7aa3d4e46..de78e002b 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_config.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_config.c @@ -217,7 +217,7 @@ static void subghz_scene_receiver_config_set_speaker(VariableItem* item) { uint8_t index = variable_item_get_current_value_index(item); variable_item_set_current_value_text(item, speaker_text[index]); - subghz->txrx->speaker_state = speaker_value[index]; + subghz_speaker_set_state(subghz, speaker_value[index]); } static void subghz_scene_receiver_config_set_bin_raw(VariableItem* item) { @@ -378,7 +378,8 @@ void subghz_scene_receiver_config_on_enter(void* context) { SPEAKER_COUNT, subghz_scene_receiver_config_set_speaker, subghz); - value_index = value_index_uint32(subghz->txrx->speaker_state, speaker_value, SPEAKER_COUNT); + value_index = + value_index_uint32(subghz_speaker_get_state(subghz), speaker_value, SPEAKER_COUNT); variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, speaker_text[value_index]); diff --git a/applications/main/subghz/subghz.c b/applications/main/subghz/subghz.c index b64470860..7e6cebe98 100644 --- a/applications/main/subghz/subghz.c +++ b/applications/main/subghz/subghz.c @@ -272,7 +272,7 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) { } subghz->txrx->txrx_state = SubGhzTxRxStateSleep; subghz_hopper_set_state(subghz, SubGhzHopperStateOFF); - subghz->txrx->speaker_state = SubGhzSpeakerStateDisable; + subghz_speaker_set_state(subghz, SubGhzSpeakerStateDisable); subghz_rx_key_state_set(subghz, SubGhzRxKeyStateIDLE); subghz->txrx->debug_pin_state = false; if(!alloc_for_tx_only) { diff --git a/applications/main/subghz/subghz_i.c b/applications/main/subghz/subghz_i.c index b2275c4d3..25d03915b 100644 --- a/applications/main/subghz/subghz_i.c +++ b/applications/main/subghz/subghz_i.c @@ -718,6 +718,16 @@ void subghz_speaker_unmute(SubGhz* subghz) { } } +void subghz_speaker_set_state(SubGhz* subghz, SubGhzSpeakerState state) { + furi_assert(subghz); + subghz->txrx->speaker_state = state; +} + +SubGhzSpeakerState subghz_speaker_get_state(SubGhz* subghz) { + furi_assert(subghz); + return subghz->txrx->speaker_state; +} + void subghz_lock(SubGhz* subghz) { furi_assert(subghz); subghz->lock = SubGhzLockOn; diff --git a/applications/main/subghz/subghz_i.h b/applications/main/subghz/subghz_i.h index acbb1823a..63687e97c 100644 --- a/applications/main/subghz/subghz_i.h +++ b/applications/main/subghz/subghz_i.h @@ -124,9 +124,10 @@ struct SubGhz { SubGhzTestStatic* subghz_test_static; SubGhzTestPacket* subghz_test_packet; #endif - FuriString* error_str; SubGhzSetting* setting; SubGhzLastSettings* last_settings; + + FuriString* error_str; SubGhzLock lock; bool in_decoder_scene; @@ -178,6 +179,8 @@ void subghz_speaker_on(SubGhz* subghz); void subghz_speaker_off(SubGhz* subghz); void subghz_speaker_mute(SubGhz* subghz); void subghz_speaker_unmute(SubGhz* subghz); +void subghz_speaker_set_state(SubGhz* subghz, SubGhzSpeakerState state); +SubGhzSpeakerState subghz_speaker_get_state(SubGhz* subghz); void subghz_txrx_stop(SubGhz* subghz); SubGhzTxRxState subghz_txrx_get_state(SubGhz* subghz);