Removing AM* preset if launching regular read mode

This commit is contained in:
Dimitry 2023-01-02 23:54:04 +02:00
parent ba429f6c88
commit df88a805a0
2 changed files with 21 additions and 6 deletions

View file

@ -12,6 +12,25 @@ enum SubmenuIndex {
SubmenuIndexReadRAW,
};
void subghz_scene_start_remove_advanced_preset(SubGhz* subghz) {
// delete operation is harmless
subghz_setting_delete_custom_preset(subghz->setting, ADVANCED_AM_PRESET_NAME);
}
void subghz_scene_start_load_advanced_preset(SubGhz* subghz) {
for(uint8_t i = 0; i < subghz_setting_get_preset_count(subghz->setting); i++) {
if(!strcmp(subghz_setting_get_preset_name(subghz->setting, i), ADVANCED_AM_PRESET_NAME)) {
return; // already exists
}
}
// Load custom advanced AM preset with configurable CFGMDM settings
FlipperFormat* advanced_am_preset = subghz_preset_custom_advanced_am_preset_alloc();
subghz_setting_load_custom_preset(
subghz->setting, ADVANCED_AM_PRESET_NAME, advanced_am_preset);
flipper_format_free(advanced_am_preset);
}
void subghz_scene_start_submenu_callback(void* context, uint32_t index) {
SubGhz* subghz = context;
view_dispatcher_send_custom_event(subghz->view_dispatcher, index);
@ -73,12 +92,14 @@ bool subghz_scene_start_on_event(void* context, SceneManagerEvent event) {
return true;
} else if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubmenuIndexReadRAW) {
subghz_scene_start_load_advanced_preset(subghz);
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexReadRAW);
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW);
return true;
} else if(event.event == SubmenuIndexRead) {
subghz_scene_start_remove_advanced_preset(subghz);
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexRead);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiver);

View file

@ -185,12 +185,6 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) {
subghz_setting_load(subghz->setting, EXT_PATH("subghz/assets/setting_user"));
// Load custom advanced AM preset with configurable CFGMDM settings
FlipperFormat* advanced_am_preset = subghz_preset_custom_advanced_am_preset_alloc();
subghz_setting_load_custom_preset(
subghz->setting, ADVANCED_AM_PRESET_NAME, advanced_am_preset);
flipper_format_free(advanced_am_preset);
// Custom Presets load without using config file
FlipperFormat* temp_fm_preset = flipper_format_string_alloc();