SubGhz: remove direct reading subghz->txrx->speaker_state

This commit is contained in:
gid9798 2023-05-06 17:56:10 +03:00
parent 1567225a64
commit e65a5e2b7c
4 changed files with 18 additions and 4 deletions

View File

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

View File

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

View File

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

View File

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