mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-19 19:31:50 +03:00
feat: add RX config option "Reset to default"
This commit is contained in:
parent
53fffffd1b
commit
1fec80a533
@ -77,6 +77,7 @@ typedef enum {
|
||||
SubGhzCustomEventSceneAnalyzerLock,
|
||||
SubGhzCustomEventSceneAnalyzerUnlock,
|
||||
SubGhzCustomEventSceneSettingLock,
|
||||
SubGhzCustomEventSceneSettingResetToDefault,
|
||||
|
||||
SubGhzCustomEventSceneExit,
|
||||
SubGhzCustomEventSceneStay,
|
||||
|
@ -12,6 +12,7 @@ enum SubGhzSettingIndex {
|
||||
SubGhzSettingIndexIgnoreCars,
|
||||
SubGhzSettingIndexIgnoreMagellan,
|
||||
SubGhzSettingIndexSound,
|
||||
SubGhzSettingIndexResetToDefault,
|
||||
SubGhzSettingIndexLock,
|
||||
SubGhzSettingIndexRAWThresholdRSSI,
|
||||
};
|
||||
@ -278,6 +279,46 @@ static void subghz_scene_receiver_config_var_list_enter_callback(void* context,
|
||||
if(index == SubGhzSettingIndexLock) {
|
||||
view_dispatcher_send_custom_event(
|
||||
subghz->view_dispatcher, SubGhzCustomEventSceneSettingLock);
|
||||
} else if(index == SubGhzSettingIndexResetToDefault) {
|
||||
// Reset all values to default state!
|
||||
#if SUBGHZ_LAST_SETTING_SAVE_PRESET
|
||||
subghz_txrx_set_preset_internal(
|
||||
subghz->txrx,
|
||||
SUBGHZ_LAST_SETTING_DEFAULT_FREQUENCY,
|
||||
SUBGHZ_LAST_SETTING_DEFAULT_PRESET);
|
||||
#else
|
||||
subghz_txrx_set_default_preset(subghz->txrx, SUBGHZ_LAST_SETTING_DEFAULT_FREQUENCY);
|
||||
#endif
|
||||
SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx);
|
||||
SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx);
|
||||
const char* preset_name = furi_string_get_cstr(preset.name);
|
||||
int preset_index = subghz_setting_get_inx_preset_by_name(setting, preset_name);
|
||||
const int default_index = 0;
|
||||
|
||||
subghz->last_settings->frequency = preset.frequency;
|
||||
subghz->last_settings->preset_index = preset_index;
|
||||
|
||||
subghz_threshold_rssi_set(subghz->threshold_rssi, raw_threshold_rssi_value[default_index]);
|
||||
subghz->filter = bin_raw_value[0];
|
||||
subghz->ignore_filter = 0x00;
|
||||
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
|
||||
subghz->last_settings->ignore_filter = subghz->ignore_filter;
|
||||
subghz->last_settings->filter = subghz->filter;
|
||||
|
||||
subghz_txrx_speaker_set_state(subghz->txrx, speaker_value[default_index]);
|
||||
|
||||
subghz_txrx_hopper_set_state(subghz->txrx, hopping_value[default_index]);
|
||||
subghz->last_settings->enable_hopping = hopping_value[default_index];
|
||||
|
||||
variable_item_list_set_selected_item(subghz->variable_item_list, default_index);
|
||||
variable_item_list_reset(subghz->variable_item_list);
|
||||
#ifdef FURI_DEBUG
|
||||
subghz_last_settings_log(subghz->last_settings);
|
||||
#endif
|
||||
subghz_last_settings_save(subghz->last_settings);
|
||||
|
||||
view_dispatcher_send_custom_event(
|
||||
subghz->view_dispatcher, SubGhzCustomEventSceneSettingResetToDefault);
|
||||
}
|
||||
}
|
||||
|
||||
@ -400,6 +441,16 @@ void subghz_scene_receiver_config_on_enter(void* context) {
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, combobox_text[value_index]);
|
||||
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
||||
SubGhzCustomEventManagerSet) {
|
||||
// Reset to default
|
||||
variable_item_list_add(subghz->variable_item_list, "Reset to default", 1, NULL, NULL);
|
||||
|
||||
variable_item_list_set_enter_callback(
|
||||
subghz->variable_item_list,
|
||||
subghz_scene_receiver_config_var_list_enter_callback,
|
||||
subghz);
|
||||
}
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
||||
SubGhzCustomEventManagerSet) {
|
||||
// Lock keyboard
|
||||
@ -409,6 +460,7 @@ void subghz_scene_receiver_config_on_enter(void* context) {
|
||||
subghz_scene_receiver_config_var_list_enter_callback,
|
||||
subghz);
|
||||
}
|
||||
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) ==
|
||||
SubGhzCustomEventManagerSet) {
|
||||
item = variable_item_list_add(
|
||||
@ -436,6 +488,9 @@ bool subghz_scene_receiver_config_on_event(void* context, SceneManagerEvent even
|
||||
subghz_lock(subghz);
|
||||
scene_manager_previous_scene(subghz->scene_manager);
|
||||
consumed = true;
|
||||
} else if(event.event == SubGhzCustomEventSceneSettingResetToDefault) {
|
||||
scene_manager_previous_scene(subghz->scene_manager);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
|
@ -6,11 +6,6 @@
|
||||
#define SUBGHZ_LAST_SETTING_FILE_TYPE "Flipper SubGhz Last Setting File"
|
||||
#define SUBGHZ_LAST_SETTING_FILE_VERSION 1
|
||||
#define SUBGHZ_LAST_SETTINGS_PATH EXT_PATH("subghz/assets/last_subghz.settings")
|
||||
// 1 = "AM650"
|
||||
// "AM270", "AM650", "FM238", "FM476",
|
||||
#define SUBGHZ_LAST_SETTING_DEFAULT_PRESET 1
|
||||
#define SUBGHZ_LAST_SETTING_DEFAULT_FREQUENCY 433920000
|
||||
#define SUBGHZ_LAST_SETTING_FREQUENCY_ANALYZER_FEEDBACK_LEVEL 2
|
||||
|
||||
#define SUBGHZ_LAST_SETTING_FIELD_FREQUENCY "Frequency"
|
||||
#define SUBGHZ_LAST_SETTING_FIELD_PRESET "Preset" // AKA Modulation
|
||||
|
@ -9,6 +9,11 @@
|
||||
#define SUBGHZ_LAST_SETTING_FREQUENCY_ANALYZER_TRIGGER (-93.0f)
|
||||
#define SUBGHZ_LAST_SETTING_SAVE_BIN_RAW true
|
||||
#define SUBGHZ_LAST_SETTING_SAVE_PRESET true
|
||||
// 1 = "AM650"
|
||||
// "AM270", "AM650", "FM238", "FM476",
|
||||
#define SUBGHZ_LAST_SETTING_DEFAULT_PRESET 1
|
||||
#define SUBGHZ_LAST_SETTING_DEFAULT_FREQUENCY 433920000
|
||||
#define SUBGHZ_LAST_SETTING_FREQUENCY_ANALYZER_FEEDBACK_LEVEL 2
|
||||
|
||||
typedef struct {
|
||||
uint32_t frequency;
|
||||
|
Loading…
Reference in New Issue
Block a user