mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-14 02:28:36 -07:00
Remake it more properly
still has problems, need to rewrite subghz_devices tx/rx switch code, checking strcmp every time is not good too, but better than loading whole config from microsd
This commit is contained in:
@@ -124,6 +124,10 @@ static void subghz_scene_reciever_config_set_ext_mod_power_amp_text(VariableItem
|
||||
}
|
||||
|
||||
subghz->last_settings->external_module_power_amp = index == 1;
|
||||
|
||||
// Set globally in furi hal
|
||||
furi_hal_subghz_set_ext_power_amp(subghz->last_settings->external_module_power_amp);
|
||||
|
||||
subghz_last_settings_save(subghz->last_settings);
|
||||
}
|
||||
|
||||
@@ -159,9 +163,9 @@ void subghz_scene_radio_settings_on_enter(void* context) {
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, radio_device_text[value_index]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
item = variable_item_list_add(
|
||||
variable_item_list,
|
||||
"Ext High Power",
|
||||
"Ext Power Amp",
|
||||
EXT_MOD_POWER_AMP_COUNT,
|
||||
subghz_scene_reciever_config_set_ext_mod_power_amp_text,
|
||||
subghz);
|
||||
@@ -171,7 +175,7 @@ void subghz_scene_radio_settings_on_enter(void* context) {
|
||||
|
||||
item = variable_item_list_add(
|
||||
variable_item_list,
|
||||
"Time in names",
|
||||
"Time In Names",
|
||||
TIMESTAMP_NAMES_COUNT,
|
||||
subghz_scene_receiver_config_set_timestamp_file_names,
|
||||
subghz);
|
||||
@@ -182,7 +186,7 @@ void subghz_scene_radio_settings_on_enter(void* context) {
|
||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||
item = variable_item_list_add(
|
||||
variable_item_list,
|
||||
"Counter incr.",
|
||||
"Counter Incr.",
|
||||
DEBUG_COUNTER_COUNT,
|
||||
subghz_scene_receiver_config_set_debug_counter,
|
||||
subghz);
|
||||
@@ -211,7 +215,7 @@ void subghz_scene_radio_settings_on_enter(void* context) {
|
||||
} else {
|
||||
item = variable_item_list_add(
|
||||
variable_item_list,
|
||||
"Counter incr.",
|
||||
"Counter Incr.",
|
||||
3,
|
||||
subghz_scene_receiver_config_set_debug_counter,
|
||||
subghz);
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include <flipper_format/flipper_format_i.h>
|
||||
|
||||
#include <subghz/subghz_last_settings.h>
|
||||
|
||||
void subghz_dangerous_freq() {
|
||||
bool is_extended_i = false;
|
||||
|
||||
@@ -19,5 +21,16 @@ void subghz_dangerous_freq() {
|
||||
furi_hal_subghz_set_dangerous_frequency(is_extended_i);
|
||||
|
||||
flipper_format_free(fff_data_file);
|
||||
|
||||
// Load external module power amp setting (TODO: move to other place)
|
||||
// TODO: Disable this when external module is not CC1101 E07
|
||||
SubGhzLastSettings* last_settings = subghz_last_settings_alloc();
|
||||
subghz_last_settings_load(last_settings, 0);
|
||||
|
||||
// Set globally in furi hal
|
||||
furi_hal_subghz_set_ext_power_amp(last_settings->external_module_power_amp);
|
||||
|
||||
subghz_last_settings_free(last_settings);
|
||||
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
#define SUBGHZ_LAST_SETTING_FIELD_FREQUENCY_ANALYZER_TRIGGER "FATrigger"
|
||||
#define SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_ENABLED "External"
|
||||
#define SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER "ExtPower"
|
||||
#define SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER_AMP "ExtPowerAmp"
|
||||
#define SUBGHZ_LAST_SETTING_FIELD_TIMESTAMP_FILE_NAMES "TimestampNames"
|
||||
#define SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER_AMP "ExtPowerAmp"
|
||||
|
||||
SubGhzLastSettings* subghz_last_settings_alloc(void) {
|
||||
SubGhzLastSettings* instance = malloc(sizeof(SubGhzLastSettings));
|
||||
@@ -47,7 +47,7 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
||||
float temp_frequency_analyzer_trigger = 0;
|
||||
bool temp_external_module_enabled = false;
|
||||
bool temp_external_module_power_5v_disable = false;
|
||||
bool temp_external_module_power_amp = false;
|
||||
bool temp_external_module_power_amp = false;
|
||||
bool temp_timestamp_file_names = false;
|
||||
//int32_t temp_preset = 0;
|
||||
bool frequency_analyzer_feedback_level_was_read = false;
|
||||
@@ -79,17 +79,17 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
||||
fff_data_file,
|
||||
SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER,
|
||||
(bool*)&temp_external_module_power_5v_disable,
|
||||
1);
|
||||
flipper_format_read_bool(
|
||||
fff_data_file,
|
||||
SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER_AMP,
|
||||
(bool*)&temp_external_module_power_amp,
|
||||
1);
|
||||
flipper_format_read_bool(
|
||||
fff_data_file,
|
||||
SUBGHZ_LAST_SETTING_FIELD_TIMESTAMP_FILE_NAMES,
|
||||
(bool*)&temp_timestamp_file_names,
|
||||
1);
|
||||
flipper_format_read_bool(
|
||||
fff_data_file,
|
||||
SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER_AMP,
|
||||
(bool*)&temp_external_module_power_amp,
|
||||
1);
|
||||
|
||||
} else {
|
||||
FURI_LOG_E(TAG, "Error open file %s", SUBGHZ_LAST_SETTINGS_PATH);
|
||||
@@ -103,8 +103,8 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
||||
SUBGHZ_LAST_SETTING_FREQUENCY_ANALYZER_FEEDBACK_LEVEL;
|
||||
instance->frequency_analyzer_trigger = SUBGHZ_LAST_SETTING_FREQUENCY_ANALYZER_TRIGGER;
|
||||
instance->external_module_enabled = false;
|
||||
instance->external_module_power_amp = false;
|
||||
instance->timestamp_file_names = false;
|
||||
instance->external_module_power_amp = false;
|
||||
|
||||
} else {
|
||||
instance->frequency = temp_frequency;
|
||||
@@ -126,9 +126,13 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
||||
instance->external_module_power_5v_disable = temp_external_module_power_5v_disable;
|
||||
|
||||
instance->timestamp_file_names = temp_timestamp_file_names;
|
||||
|
||||
|
||||
// External power amp CC1101
|
||||
instance->external_module_power_amp = temp_external_module_power_amp;
|
||||
|
||||
|
||||
// Set globally in furi hal
|
||||
furi_hal_subghz_set_ext_power_amp(instance->external_module_power_amp);
|
||||
|
||||
/*/} else {
|
||||
instance->preset = temp_preset;
|
||||
}*/
|
||||
@@ -199,17 +203,17 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) {
|
||||
1)) {
|
||||
break;
|
||||
}
|
||||
if(!flipper_format_insert_or_update_bool(
|
||||
if(!flipper_format_insert_or_update_bool(
|
||||
file,
|
||||
SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER_AMP,
|
||||
&instance->external_module_power_amp,
|
||||
SUBGHZ_LAST_SETTING_FIELD_TIMESTAMP_FILE_NAMES,
|
||||
&instance->timestamp_file_names,
|
||||
1)) {
|
||||
break;
|
||||
}
|
||||
if(!flipper_format_insert_or_update_bool(
|
||||
file,
|
||||
SUBGHZ_LAST_SETTING_FIELD_TIMESTAMP_FILE_NAMES,
|
||||
&instance->timestamp_file_names,
|
||||
SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER_AMP,
|
||||
&instance->external_module_power_amp,
|
||||
1)) {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user