mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-23 13:03:13 +00:00
SubGHz: FA -> Save last trigger level
This commit is contained in:
parent
1e183d5450
commit
17cb7533cb
6 changed files with 34 additions and 2 deletions
|
@ -274,7 +274,8 @@ SubGhzFrequencyAnalyzerWorker* subghz_frequency_analyzer_worker_alloc(void* cont
|
|||
|
||||
SubGhz* subghz = context;
|
||||
instance->setting = subghz->setting;
|
||||
instance->trigger_level = SUBGHZ_FREQUENCY_ANALYZER_THRESHOLD;
|
||||
instance->trigger_level = subghz->last_settings->frequency_analyzer_trigger;
|
||||
//instance->trigger_level = SUBGHZ_FREQUENCY_ANALYZER_THRESHOLD;
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,5 +82,7 @@ void subghz_scene_frequency_analyzer_on_exit(void* context) {
|
|||
|
||||
subghz->last_settings->frequency_analyzer_feedback_level =
|
||||
subghz_frequency_analyzer_feedback_level(subghz->subghz_frequency_analyzer, 0, false);
|
||||
subghz->last_settings->frequency_analyzer_trigger =
|
||||
subghz_frequency_analyzer_get_trigger_level(subghz->subghz_frequency_analyzer);
|
||||
subghz_last_settings_save(subghz->last_settings);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#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_FREQUENCY_ANALYZER_TRIGGER -97.0f
|
||||
|
||||
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
|
||||
#define SUBGHZ_LAST_SETTING_DEFAULT_READ_RAW 0
|
||||
|
@ -23,6 +24,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"
|
||||
#define SUBGHZ_LAST_SETTING_FIELD_FREQUENCY_ANALYZER_TRIGGER "FATrigger"
|
||||
|
||||
SubGhzLastSettings* subghz_last_settings_alloc(void) {
|
||||
SubGhzLastSettings* instance = malloc(sizeof(SubGhzLastSettings));
|
||||
|
@ -46,8 +48,10 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
|||
|
||||
uint32_t temp_frequency = 0;
|
||||
uint32_t temp_frequency_analyzer_feedback_level = 0;
|
||||
float temp_frequency_analyzer_trigger = 0;
|
||||
//int32_t temp_preset = 0;
|
||||
bool frequency_analyzer_feedback_level_was_read = false;
|
||||
bool frequency_analyzer_trigger_was_read = false;
|
||||
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
|
||||
uint32_t temp_read_raw = 0;
|
||||
#endif
|
||||
|
@ -64,6 +68,11 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
|||
SUBGHZ_LAST_SETTING_FIELD_FREQUENCY_ANALYZER_FEEDBACK_LEVEL,
|
||||
(uint32_t*)&temp_frequency_analyzer_feedback_level,
|
||||
1);
|
||||
frequency_analyzer_trigger_was_read = flipper_format_read_float(
|
||||
fff_data_file,
|
||||
SUBGHZ_LAST_SETTING_FIELD_FREQUENCY_ANALYZER_TRIGGER,
|
||||
(float*)&temp_frequency_analyzer_trigger,
|
||||
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);
|
||||
|
@ -78,6 +87,7 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
|||
instance->preset = SUBGHZ_LAST_SETTING_DEFAULT_PRESET;
|
||||
instance->frequency_analyzer_feedback_level =
|
||||
SUBGHZ_LAST_SETTING_FREQUENCY_ANALYZER_FEEDBACK_LEVEL;
|
||||
instance->frequency_analyzer_trigger = SUBGHZ_LAST_SETTING_FREQUENCY_ANALYZER_TRIGGER;
|
||||
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
|
||||
instance->detect_raw = SUBGHZ_LAST_SETTING_DEFAULT_READ_RAW;
|
||||
#endif
|
||||
|
@ -87,6 +97,10 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
|||
frequency_analyzer_feedback_level_was_read ?
|
||||
temp_frequency_analyzer_feedback_level :
|
||||
SUBGHZ_LAST_SETTING_FREQUENCY_ANALYZER_FEEDBACK_LEVEL;
|
||||
|
||||
instance->frequency_analyzer_trigger = frequency_analyzer_trigger_was_read ?
|
||||
temp_frequency_analyzer_trigger :
|
||||
SUBGHZ_LAST_SETTING_FREQUENCY_ANALYZER_TRIGGER;
|
||||
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
|
||||
instance->detect_raw = temp_read_raw;
|
||||
#endif
|
||||
|
@ -143,6 +157,13 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) {
|
|||
1)) {
|
||||
break;
|
||||
}
|
||||
if(!flipper_format_insert_or_update_float(
|
||||
file,
|
||||
SUBGHZ_LAST_SETTING_FIELD_FREQUENCY_ANALYZER_TRIGGER,
|
||||
&instance->frequency_analyzer_trigger,
|
||||
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)) {
|
||||
|
|
|
@ -20,6 +20,7 @@ typedef struct {
|
|||
#endif
|
||||
int32_t preset;
|
||||
uint32_t frequency_analyzer_feedback_level;
|
||||
float frequency_analyzer_trigger;
|
||||
} SubGhzLastSettings;
|
||||
|
||||
SubGhzLastSettings* subghz_last_settings_alloc(void);
|
||||
|
|
|
@ -542,7 +542,7 @@ void subghz_frequency_analyzer_enter(void* context) {
|
|||
instance->selected_index = 0;
|
||||
instance->max_index = 0;
|
||||
instance->show_frame = false;
|
||||
subghz_frequency_analyzer_worker_set_trigger_level(instance->worker, RSSI_MIN);
|
||||
//subghz_frequency_analyzer_worker_set_trigger_level(instance->worker, RSSI_MIN);
|
||||
|
||||
with_view_model(
|
||||
instance->view,
|
||||
|
@ -638,4 +638,9 @@ SubGHzFrequencyAnalyzerFeedbackLevel subghz_frequency_analyzer_feedback_level(
|
|||
}
|
||||
|
||||
return instance->feedback_level;
|
||||
}
|
||||
|
||||
float subghz_frequency_analyzer_get_trigger_level(SubGhzFrequencyAnalyzer* instance) {
|
||||
furi_assert(instance);
|
||||
return subghz_frequency_analyzer_worker_get_trigger_level(instance->worker);
|
||||
}
|
|
@ -30,3 +30,5 @@ SubGHzFrequencyAnalyzerFeedbackLevel subghz_frequency_analyzer_feedback_level(
|
|||
SubGhzFrequencyAnalyzer* instance,
|
||||
SubGHzFrequencyAnalyzerFeedbackLevel level,
|
||||
bool update);
|
||||
|
||||
float subghz_frequency_analyzer_get_trigger_level(SubGhzFrequencyAnalyzer* instance);
|
Loading…
Reference in a new issue