mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-15 01:07:22 +00:00
New option to save signal names with timestamps
This commit is contained in:
parent
15f204bbc5
commit
1bb3ab8715
7 changed files with 119 additions and 17 deletions
|
@ -1,10 +1,11 @@
|
|||
#include "../subghz_i.h"
|
||||
#include "../helpers/subghz_custom_event.h"
|
||||
|
||||
uint8_t value_index_exm;
|
||||
uint8_t value_index_dpin;
|
||||
uint8_t value_index_cnt;
|
||||
uint8_t value_index_pwr;
|
||||
static uint8_t value_index_exm;
|
||||
static uint8_t value_index_dpin;
|
||||
static uint8_t value_index_cnt;
|
||||
static uint8_t value_index_pwr;
|
||||
static uint8_t value_index_time;
|
||||
|
||||
#define EXT_MODULES_COUNT (sizeof(radio_modules_variables_text) / sizeof(char* const))
|
||||
const char* const radio_modules_variables_text[] = {
|
||||
|
@ -18,6 +19,12 @@ const char* const ext_mod_power_text[EXT_MOD_POWER_COUNT] = {
|
|||
"OFF",
|
||||
};
|
||||
|
||||
#define TIMESTAMP_NAMES_COUNT 2
|
||||
const char* const timestamp_names_text[TIMESTAMP_NAMES_COUNT] = {
|
||||
"OFF",
|
||||
"ON",
|
||||
};
|
||||
|
||||
#define DEBUG_P_COUNT 2
|
||||
const char* const debug_pin_text[DEBUG_P_COUNT] = {
|
||||
"OFF",
|
||||
|
@ -104,6 +111,17 @@ static void subghz_scene_receiver_config_set_ext_mod_power(VariableItem* item) {
|
|||
subghz_last_settings_save(subghz->last_settings);
|
||||
}
|
||||
|
||||
static void subghz_scene_receiver_config_set_timestamp_file_names(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, timestamp_names_text[index]);
|
||||
|
||||
furi_hal_subghz_set_timestamp_file_names((index == 1));
|
||||
subghz->last_settings->timestamp_file_names = (index == 1);
|
||||
subghz_last_settings_save(subghz->last_settings);
|
||||
}
|
||||
|
||||
void subghz_scene_ext_module_settings_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
|
@ -129,6 +147,16 @@ void subghz_scene_ext_module_settings_on_enter(void* context) {
|
|||
variable_item_set_current_value_index(item, value_index_pwr);
|
||||
variable_item_set_current_value_text(item, ext_mod_power_text[value_index_pwr]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
subghz->variable_item_list,
|
||||
"Time in names",
|
||||
TIMESTAMP_NAMES_COUNT,
|
||||
subghz_scene_receiver_config_set_timestamp_file_names,
|
||||
subghz);
|
||||
value_index_time = furi_hal_subghz_get_timestamp_file_names();
|
||||
variable_item_set_current_value_index(item, value_index_time);
|
||||
variable_item_set_current_value_text(item, timestamp_names_text[value_index_time]);
|
||||
|
||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||
item = variable_item_list_add(
|
||||
subghz->variable_item_list,
|
||||
|
|
|
@ -14,18 +14,34 @@ void subghz_scene_save_name_text_input_callback(void* context) {
|
|||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneSaveName);
|
||||
}
|
||||
|
||||
void subghz_scene_save_name_get_timefilename(FuriString* name) {
|
||||
void subghz_scene_save_name_get_timefilename(
|
||||
FuriString* name,
|
||||
const char* proto_name,
|
||||
bool fulldate) {
|
||||
FuriHalRtcDateTime datetime = {0};
|
||||
furi_hal_rtc_get_datetime(&datetime);
|
||||
furi_string_printf(
|
||||
name,
|
||||
"RAW_%.4d%.2d%.2d-%.2d%.2d%.2d",
|
||||
datetime.year,
|
||||
datetime.month,
|
||||
datetime.day,
|
||||
datetime.hour,
|
||||
datetime.minute,
|
||||
datetime.second);
|
||||
if(fulldate) {
|
||||
furi_string_printf(
|
||||
name,
|
||||
"%s_%.4d%.2d%.2d-%.2d%.2d%.2d",
|
||||
proto_name,
|
||||
datetime.year,
|
||||
datetime.month,
|
||||
datetime.day,
|
||||
datetime.hour,
|
||||
datetime.minute,
|
||||
datetime.second);
|
||||
} else {
|
||||
furi_string_printf(
|
||||
name,
|
||||
"%s_%.2d%.2d-%.2d%.2d%.2d",
|
||||
proto_name,
|
||||
datetime.month,
|
||||
datetime.day,
|
||||
datetime.hour,
|
||||
datetime.minute,
|
||||
datetime.second);
|
||||
}
|
||||
}
|
||||
|
||||
void subghz_scene_save_name_on_enter(void* context) {
|
||||
|
@ -42,8 +58,25 @@ void subghz_scene_save_name_on_enter(void* context) {
|
|||
|
||||
if(!subghz_path_is_file(subghz->file_path)) {
|
||||
char file_name_buf[SUBGHZ_MAX_LEN_NAME] = {0};
|
||||
set_random_name(file_name_buf, SUBGHZ_MAX_LEN_NAME);
|
||||
furi_string_set(file_name, file_name_buf);
|
||||
if(furi_hal_subghz_get_timestamp_file_names()) {
|
||||
if(subghz->txrx->decoder_result->protocol->name != 0x0) {
|
||||
if(subghz->txrx->decoder_result->protocol->name != NULL) {
|
||||
if(strlen(subghz->txrx->decoder_result->protocol->name) != 0) {
|
||||
subghz_scene_save_name_get_timefilename(
|
||||
file_name, subghz->txrx->decoder_result->protocol->name, false);
|
||||
} else {
|
||||
subghz_scene_save_name_get_timefilename(file_name, "S", true);
|
||||
}
|
||||
} else {
|
||||
subghz_scene_save_name_get_timefilename(file_name, "S", true);
|
||||
}
|
||||
} else {
|
||||
subghz_scene_save_name_get_timefilename(file_name, "S", true);
|
||||
}
|
||||
} else {
|
||||
set_random_name(file_name_buf, SUBGHZ_MAX_LEN_NAME);
|
||||
furi_string_set(file_name, file_name_buf);
|
||||
}
|
||||
furi_string_set(subghz->file_path, SUBGHZ_APP_FOLDER);
|
||||
//highlighting the entire filename by default
|
||||
dev_name_empty = true;
|
||||
|
@ -57,7 +90,7 @@ void subghz_scene_save_name_on_enter(void* context) {
|
|||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) ==
|
||||
SubGhzCustomEventManagerSetRAW) {
|
||||
dev_name_empty = true;
|
||||
subghz_scene_save_name_get_timefilename(file_name);
|
||||
subghz_scene_save_name_get_timefilename(file_name, "RAW", true);
|
||||
}
|
||||
}
|
||||
furi_string_set(subghz->file_path, dir_name);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#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_TIMESTAMP_FILE_NAMES "TimestampNames"
|
||||
|
||||
SubGhzLastSettings* subghz_last_settings_alloc(void) {
|
||||
SubGhzLastSettings* instance = malloc(sizeof(SubGhzLastSettings));
|
||||
|
@ -45,6 +46,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_timestamp_file_names = false;
|
||||
//int32_t temp_preset = 0;
|
||||
bool frequency_analyzer_feedback_level_was_read = false;
|
||||
bool frequency_analyzer_trigger_was_read = false;
|
||||
|
@ -76,6 +78,11 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
|||
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_TIMESTAMP_FILE_NAMES,
|
||||
(bool*)&temp_timestamp_file_names,
|
||||
1);
|
||||
|
||||
} else {
|
||||
FURI_LOG_E(TAG, "Error open file %s", SUBGHZ_LAST_SETTINGS_PATH);
|
||||
|
@ -89,6 +96,7 @@ 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->timestamp_file_names = false;
|
||||
|
||||
} else {
|
||||
instance->frequency = temp_frequency;
|
||||
|
@ -109,6 +117,11 @@ 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;
|
||||
|
||||
// Set globally
|
||||
furi_hal_subghz_set_timestamp_file_names(instance->timestamp_file_names);
|
||||
|
||||
if(instance->external_module_power_5v_disable) {
|
||||
furi_hal_subghz_set_external_power_disable(true);
|
||||
furi_hal_subghz_disable_ext_power();
|
||||
|
@ -189,6 +202,13 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) {
|
|||
1)) {
|
||||
break;
|
||||
}
|
||||
if(!flipper_format_insert_or_update_bool(
|
||||
file,
|
||||
SUBGHZ_LAST_SETTING_FIELD_TIMESTAMP_FILE_NAMES,
|
||||
&instance->timestamp_file_names,
|
||||
1)) {
|
||||
break;
|
||||
}
|
||||
saved = true;
|
||||
} while(0);
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ typedef struct {
|
|||
float frequency_analyzer_trigger;
|
||||
bool external_module_enabled;
|
||||
bool external_module_power_5v_disable;
|
||||
bool timestamp_file_names;
|
||||
} SubGhzLastSettings;
|
||||
|
||||
SubGhzLastSettings* subghz_last_settings_alloc(void);
|
||||
|
|
|
@ -1373,6 +1373,7 @@ Function,+,furi_hal_subghz_get_lqi,uint8_t,
|
|||
Function,+,furi_hal_subghz_get_radio_type,SubGhzRadioType,
|
||||
Function,+,furi_hal_subghz_get_rolling_counter_mult,uint8_t,
|
||||
Function,+,furi_hal_subghz_get_rssi,float,
|
||||
Function,+,furi_hal_subghz_get_timestamp_file_names,_Bool,
|
||||
Function,+,furi_hal_subghz_idle,void,
|
||||
Function,-,furi_hal_subghz_init,void,
|
||||
Function,+,furi_hal_subghz_init_check,_Bool,
|
||||
|
@ -1395,6 +1396,7 @@ Function,+,furi_hal_subghz_set_frequency_and_path,uint32_t,uint32_t
|
|||
Function,+,furi_hal_subghz_set_path,void,FuriHalSubGhzPath
|
||||
Function,+,furi_hal_subghz_set_radio_type,_Bool,SubGhzRadioType
|
||||
Function,+,furi_hal_subghz_set_rolling_counter_mult,void,uint8_t
|
||||
Function,+,furi_hal_subghz_set_timestamp_file_names,void,_Bool
|
||||
Function,-,furi_hal_subghz_shutdown,void,
|
||||
Function,+,furi_hal_subghz_sleep,void,
|
||||
Function,+,furi_hal_subghz_start_async_rx,void,"FuriHalSubGhzCaptureCallback, void*"
|
||||
|
|
|
|
@ -40,6 +40,7 @@ volatile FuriHalSubGhz furi_hal_subghz = {
|
|||
.cc1101_g0_pin = &gpio_cc1101_g0,
|
||||
.rolling_counter_mult = 1,
|
||||
.ext_module_power_disabled = false,
|
||||
.timestamp_file_names = false,
|
||||
};
|
||||
|
||||
bool furi_hal_subghz_set_radio_type(SubGhzRadioType state) {
|
||||
|
@ -79,6 +80,14 @@ bool furi_hal_subghz_get_external_power_disable(void) {
|
|||
return furi_hal_subghz.ext_module_power_disabled;
|
||||
}
|
||||
|
||||
void furi_hal_subghz_set_timestamp_file_names(bool state) {
|
||||
furi_hal_subghz.timestamp_file_names = state;
|
||||
}
|
||||
|
||||
bool furi_hal_subghz_get_timestamp_file_names(void) {
|
||||
return furi_hal_subghz.timestamp_file_names;
|
||||
}
|
||||
|
||||
void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin) {
|
||||
furi_hal_subghz.async_mirror_pin = pin;
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ typedef struct {
|
|||
const GpioPin* cc1101_g0_pin;
|
||||
uint8_t rolling_counter_mult;
|
||||
bool ext_module_power_disabled;
|
||||
bool timestamp_file_names;
|
||||
} FuriHalSubGhz;
|
||||
|
||||
extern volatile FuriHalSubGhz furi_hal_subghz;
|
||||
|
@ -330,6 +331,14 @@ void furi_hal_subghz_set_external_power_disable(bool state);
|
|||
*/
|
||||
bool furi_hal_subghz_get_external_power_disable(void);
|
||||
|
||||
/** If true - disable generation of random name and add timestamp to filenames instead
|
||||
*/
|
||||
void furi_hal_subghz_set_timestamp_file_names(bool state);
|
||||
|
||||
/** Get the current state of the timestamp instead of random name flag
|
||||
*/
|
||||
bool furi_hal_subghz_get_timestamp_file_names(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue