Skip to content

Commit

Permalink
subghz option to delete old signals on full memory
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Dec 24, 2023
1 parent 111750c commit b84f143
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
16 changes: 16 additions & 0 deletions applications/main/subghz/scenes/subghz_scene_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 22 additions & 0 deletions applications/main/subghz/scenes/subghz_scene_receiver_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum SubGhzSettingIndex {
SubGhzSettingIndexIgnoreMagellan,
SubGhzSettingIndexIgnorePrinceton,
SubGhzSettingIndexIgnoreNiceFlorS,
SubGhzSettingIndexDeleteOldSignals,
SubGhzSettingIndexSound,
SubGhzSettingIndexResetToDefault,
SubGhzSettingIndexLock,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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]);

Expand Down Expand Up @@ -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 :)
Expand Down
10 changes: 10 additions & 0 deletions applications/main/subghz/subghz_last_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions applications/main/subghz/subghz_last_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b84f143

Please sign in to comment.