mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-27 15:00:46 +00:00
Save in last settings FrequencyAnalyzer last feedback set
This commit is contained in:
parent
b0d4146c76
commit
06c0adfe98
5 changed files with 52 additions and 0 deletions
|
@ -14,6 +14,10 @@ void subghz_scene_frequency_analyzer_on_enter(void* context) {
|
|||
DOLPHIN_DEED(DolphinDeedSubGhzFrequencyAnalyzer);
|
||||
subghz_frequency_analyzer_set_callback(
|
||||
subghz->subghz_frequency_analyzer, subghz_scene_frequency_analyzer_callback, subghz);
|
||||
subghz_frequency_analyzer_feedback_level(
|
||||
subghz->subghz_frequency_analyzer,
|
||||
subghz->last_settings->frequency_analyzer_feedback_level,
|
||||
true);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdFrequencyAnalyzer);
|
||||
}
|
||||
|
||||
|
@ -44,4 +48,10 @@ bool subghz_scene_frequency_analyzer_on_event(void* context, SceneManagerEvent e
|
|||
void subghz_scene_frequency_analyzer_on_exit(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
notification_message(subghz->notifications, &sequence_reset_rgb);
|
||||
|
||||
subghz->last_settings->frequency_analyzer_feedback_level = subghz_frequency_analyzer_feedback_level(
|
||||
subghz->subghz_frequency_analyzer,
|
||||
0,
|
||||
false);
|
||||
subghz_last_settings_save(subghz->last_settings);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
// "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
|
||||
|
||||
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
|
||||
#define SUBGHZ_LAST_SETTING_DEFAULT_READ_RAW 0
|
||||
|
@ -21,6 +22,7 @@
|
|||
|
||||
#define SUBGHZ_LAST_SETTING_FIELD_FREQUENCY "Frequency"
|
||||
#define SUBGHZ_LAST_SETTING_FIELD_PRESET "Preset"
|
||||
#define SUBGHZ_LAST_SETTING_FIELD_FREQUENCY_ANALYZER_FEEDBACK_LEVEL "FeedbackLevel"
|
||||
|
||||
SubGhzLastSettings* subghz_last_settings_alloc(void) {
|
||||
SubGhzLastSettings* instance = malloc(sizeof(SubGhzLastSettings));
|
||||
|
@ -42,7 +44,9 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
|||
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
|
||||
|
||||
uint32_t temp_frequency = 0;
|
||||
uint32_t temp_frequency_analyzer_feedback_level = 0;
|
||||
int32_t temp_preset = 0;
|
||||
bool frequency_analyzer_feedback_level_was_read = false;
|
||||
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
|
||||
uint32_t temp_read_raw = 0;
|
||||
#endif
|
||||
|
@ -53,6 +57,11 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
|||
fff_data_file, SUBGHZ_LAST_SETTING_FIELD_PRESET, (int32_t*)&temp_preset, 1);
|
||||
flipper_format_read_uint32(
|
||||
fff_data_file, SUBGHZ_LAST_SETTING_FIELD_FREQUENCY, (uint32_t*)&temp_frequency, 1);
|
||||
frequency_analyzer_feedback_level_was_read = flipper_format_read_uint32(
|
||||
fff_data_file,
|
||||
SUBGHZ_LAST_SETTING_FIELD_FREQUENCY_ANALYZER_FEEDBACK_LEVEL,
|
||||
(uint32_t*)&temp_frequency_analyzer_feedback_level,
|
||||
1);
|
||||
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
|
||||
flipper_format_read_uint32(
|
||||
fff_data_file, SUBGHZ_LAST_SETTING_FIELD_DETECT_RAW, (uint32_t*)&temp_read_raw, 1);
|
||||
|
@ -65,11 +74,17 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
|||
FURI_LOG_W(TAG, "Last used frequency not found or can't be used!");
|
||||
instance->frequency = SUBGHZ_LAST_SETTING_DEFAULT_FREQUENCY;
|
||||
instance->preset = SUBGHZ_LAST_SETTING_DEFAULT_PRESET;
|
||||
instance->frequency_analyzer_feedback_level =
|
||||
SUBGHZ_LAST_SETTING_FREQUENCY_ANALYZER_FEEDBACK_LEVEL;
|
||||
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
|
||||
instance->detect_raw = SUBGHZ_LAST_SETTING_DEFAULT_READ_RAW;
|
||||
#endif
|
||||
} else {
|
||||
instance->frequency = temp_frequency;
|
||||
instance->frequency_analyzer_feedback_level =
|
||||
frequency_analyzer_feedback_level_was_read ?
|
||||
temp_frequency_analyzer_feedback_level :
|
||||
SUBGHZ_LAST_SETTING_FREQUENCY_ANALYZER_FEEDBACK_LEVEL;
|
||||
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
|
||||
instance->detect_raw = temp_read_raw;
|
||||
#endif
|
||||
|
@ -118,6 +133,10 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) {
|
|||
file, SUBGHZ_LAST_SETTING_FIELD_FREQUENCY, &instance->frequency, 1)) {
|
||||
break;
|
||||
}
|
||||
if(!flipper_format_insert_or_update_uint32(
|
||||
file, SUBGHZ_LAST_SETTING_FIELD_FREQUENCY_ANALYZER_FEEDBACK_LEVEL, &instance->frequency_analyzer_feedback_level, 1)) {
|
||||
break;
|
||||
}
|
||||
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
|
||||
if(!flipper_format_insert_or_update_uint32(
|
||||
file, SUBGHZ_LAST_SETTING_FIELD_DETECT_RAW, &instance->detect_raw, 1)) {
|
||||
|
|
|
@ -19,6 +19,7 @@ typedef struct {
|
|||
uint32_t detect_raw;
|
||||
#endif
|
||||
int32_t preset;
|
||||
uint32_t frequency_analyzer_feedback_level;
|
||||
} SubGhzLastSettings;
|
||||
|
||||
SubGhzLastSettings* subghz_last_settings_alloc(void);
|
||||
|
|
|
@ -517,4 +517,21 @@ uint32_t subghz_frequency_analyzer_get_frequency_to_save(SubGhzFrequencyAnalyzer
|
|||
false);
|
||||
|
||||
return frequency;
|
||||
}
|
||||
|
||||
uint8_t subghz_frequency_analyzer_feedback_level(
|
||||
SubGhzFrequencyAnalyzer* instance,
|
||||
uint8_t level,
|
||||
bool update) {
|
||||
furi_assert(instance);
|
||||
if(update) {
|
||||
instance->feedback_level = level;
|
||||
with_view_model(
|
||||
instance->view,
|
||||
SubGhzFrequencyAnalyzerModel * model,
|
||||
{ model->feedback_level = instance->feedback_level; },
|
||||
true);
|
||||
}
|
||||
|
||||
return instance->feedback_level;
|
||||
}
|
|
@ -19,3 +19,8 @@ void subghz_frequency_analyzer_free(SubGhzFrequencyAnalyzer* subghz_static);
|
|||
View* subghz_frequency_analyzer_get_view(SubGhzFrequencyAnalyzer* subghz_static);
|
||||
|
||||
uint32_t subghz_frequency_analyzer_get_frequency_to_save(SubGhzFrequencyAnalyzer* instance);
|
||||
|
||||
uint8_t subghz_frequency_analyzer_feedback_level(
|
||||
SubGhzFrequencyAnalyzer* instance,
|
||||
uint8_t level,
|
||||
bool update);
|
||||
|
|
Loading…
Reference in a new issue