subghz option to delete old signals on full memory

This commit is contained in:
MX 2023-12-24 03:08:24 +03:00
parent 111750c420
commit b84f14386c
No known key found for this signature in database
GPG Key ID: 7CCC66B7DBDD1C83
4 changed files with 49 additions and 0 deletions

View File

@ -112,6 +112,22 @@ static void subghz_scene_add_to_history_callback(
uint16_t idx = subghz_history_get_item(history);
SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx);
if(subghz->last_settings->delete_old_signals) {
if(subghz_history_get_last_index(subghz->history) >= 54) {
subghz->state_notifications = SubGhzNotificationStateRx;
subghz_view_receiver_disable_draw_callback(subghz->subghz_receiver);
subghz_history_delete_item(subghz->history, 0);
subghz_view_receiver_delete_item(subghz->subghz_receiver, 0);
subghz_view_receiver_enable_draw_callback(subghz->subghz_receiver);
subghz_scene_receiver_update_statusbar(subghz);
subghz->idx_menu_chosen =
subghz_view_receiver_get_idx_menu(subghz->subghz_receiver);
idx--;
}
}
if(subghz_history_add_to_history(history, decoder_base, &preset)) {
furi_string_reset(item_name);
furi_string_reset(item_time);

View File

@ -13,6 +13,7 @@ enum SubGhzSettingIndex {
SubGhzSettingIndexIgnoreMagellan,
SubGhzSettingIndexIgnorePrinceton,
SubGhzSettingIndexIgnoreNiceFlorS,
SubGhzSettingIndexDeleteOldSignals,
SubGhzSettingIndexSound,
SubGhzSettingIndexResetToDefault,
SubGhzSettingIndexLock,
@ -283,6 +284,15 @@ static void subghz_scene_receiver_config_set_niceflors(VariableItem* item) {
subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_NiceFlorS);
}
static void subghz_scene_receiver_config_set_delete_old_signals(VariableItem* item) {
SubGhz* subghz = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, combobox_text[index]);
subghz->last_settings->delete_old_signals = index == 1;
}
static void subghz_scene_receiver_config_var_list_enter_callback(void* context, uint32_t index) {
furi_assert(context);
SubGhz* subghz = context;
@ -314,6 +324,7 @@ static void subghz_scene_receiver_config_var_list_enter_callback(void* context,
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
subghz->last_settings->ignore_filter = subghz->ignore_filter;
subghz->last_settings->filter = subghz->filter;
subghz->last_settings->delete_old_signals = false;
subghz_txrx_speaker_set_state(subghz->txrx, speaker_value[default_index]);
@ -461,6 +472,17 @@ void subghz_scene_receiver_config_on_enter(void* context) {
subghz->ignore_filter, SubGhzProtocolFlag_NiceFlorS);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, combobox_text[value_index]);
item = variable_item_list_add(
subghz->variable_item_list,
"Delete old signals when memory is full",
COMBO_BOX_COUNT,
subghz_scene_receiver_config_set_delete_old_signals,
subghz);
value_index = subghz->last_settings->delete_old_signals;
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, combobox_text[value_index]);
}
// Enable speaker, will send all incoming noises and signals to speaker so you can listen how your remote sounds like :)

View File

@ -19,6 +19,7 @@
#define SUBGHZ_LAST_SETTING_FIELD_IGNORE_FILTER "IgnoreFilter"
#define SUBGHZ_LAST_SETTING_FIELD_FILTER "Filter"
#define SUBGHZ_LAST_SETTING_FIELD_RSSI_THRESHOLD "RSSI"
#define SUBGHZ_LAST_SETTING_FIELD_DELETE_OLD "DelOldSignals"
SubGhzLastSettings* subghz_last_settings_alloc(void) {
SubGhzLastSettings* instance = malloc(sizeof(SubGhzLastSettings));
@ -44,6 +45,7 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
bool temp_external_module_power_amp = false;
bool temp_timestamp_file_names = false;
bool temp_enable_hopping = false;
bool temp_delete_old_sig = false;
uint32_t temp_ignore_filter = 0;
uint32_t temp_filter = 0;
float temp_rssi = 0;
@ -106,6 +108,8 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
1);
filter_was_read = flipper_format_read_uint32(
fff_data_file, SUBGHZ_LAST_SETTING_FIELD_FILTER, (uint32_t*)&temp_filter, 1);
flipper_format_read_bool(
fff_data_file, SUBGHZ_LAST_SETTING_FIELD_DELETE_OLD, (bool*)&temp_delete_old_sig, 1);
} else {
FURI_LOG_E(TAG, "Error open file %s", SUBGHZ_LAST_SETTINGS_PATH);
}
@ -156,6 +160,8 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
instance->timestamp_file_names = temp_timestamp_file_names;
instance->delete_old_signals = temp_delete_old_sig;
// External power amp CC1101
instance->external_module_power_amp = temp_external_module_power_amp;
@ -270,6 +276,10 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) {
file, SUBGHZ_LAST_SETTING_FIELD_FILTER, &instance->filter, 1)) {
break;
}
if(!flipper_format_insert_or_update_bool(
file, SUBGHZ_LAST_SETTING_FIELD_DELETE_OLD, &instance->delete_old_signals, 1)) {
break;
}
saved = true;
} while(0);

View File

@ -30,6 +30,7 @@ typedef struct {
uint32_t ignore_filter;
uint32_t filter;
float rssi;
bool delete_old_signals;
} SubGhzLastSettings;
SubGhzLastSettings* subghz_last_settings_alloc(void);