mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 16:28:36 -07:00
Subghz save files with receive time [ci skip]
+ merge better scene_save_name code (removing kostily) some modifications to original code was made to keep previous formats original implementation by Willy-JL Source:a1c7dc5eaa7e7509d481 (diff-1708ba08196de5331f4b4c3d8e13162e78d5edb33e1308c1b4cc09975264151e)
This commit is contained in:
@@ -165,6 +165,9 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||
if(subghz_txrx_protocol_is_serializable(subghz->txrx)) {
|
||||
subghz_file_name_clear(subghz);
|
||||
|
||||
subghz->save_datetime =
|
||||
subghz_history_get_datetime(subghz->history, subghz->idx_menu_chosen);
|
||||
subghz->save_datetime_set = true;
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -6,44 +6,12 @@
|
||||
#include <dolphin/dolphin.h>
|
||||
#include <toolbox/name_generator.h>
|
||||
|
||||
#define MAX_TEXT_INPUT_LEN 23
|
||||
|
||||
void subghz_scene_save_name_text_input_callback(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneSaveName);
|
||||
}
|
||||
|
||||
void subghz_scene_save_name_get_timefilename(
|
||||
FuriString* name,
|
||||
const char* proto_name,
|
||||
bool fulldate) {
|
||||
FuriHalRtcDateTime datetime = {0};
|
||||
furi_hal_rtc_get_datetime(&datetime);
|
||||
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) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
@@ -54,35 +22,33 @@ void subghz_scene_save_name_on_enter(void* context) {
|
||||
FuriString* file_name = furi_string_alloc();
|
||||
FuriString* dir_name = furi_string_alloc();
|
||||
|
||||
char file_name_buf[SUBGHZ_MAX_LEN_NAME] = {0};
|
||||
FuriHalRtcDateTime* datetime = subghz->save_datetime_set ? &subghz->save_datetime : NULL;
|
||||
subghz->save_datetime_set = false;
|
||||
if(!subghz_path_is_file(subghz->file_path)) {
|
||||
char file_name_buf[SUBGHZ_MAX_LEN_NAME] = {0};
|
||||
if(subghz->last_settings->timestamp_file_names) {
|
||||
SubGhzProtocolDecoderBase* decoder_result = subghz_txrx_get_decoder(subghz->txrx);
|
||||
if(decoder_result != 0x0) {
|
||||
if(decoder_result != NULL) {
|
||||
if(strlen(decoder_result->protocol->name) != 0) {
|
||||
if(scene_manager_has_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneSetType)) {
|
||||
subghz_scene_save_name_get_timefilename(file_name, "S", true);
|
||||
} else {
|
||||
subghz_scene_save_name_get_timefilename(
|
||||
file_name, decoder_result->protocol->name, false);
|
||||
}
|
||||
SubGhzProtocolDecoderBase* decoder_result = subghz_txrx_get_decoder(subghz->txrx);
|
||||
|
||||
} else {
|
||||
subghz_scene_save_name_get_timefilename(file_name, "S", true);
|
||||
bool skip_dec_is_present = false;
|
||||
if(decoder_result != 0x0) {
|
||||
if(decoder_result != NULL) {
|
||||
if(strlen(decoder_result->protocol->name) != 0 &&
|
||||
subghz->last_settings->timestamp_file_names) {
|
||||
if(!scene_manager_has_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneSetType)) {
|
||||
name_generator_make_auto_datetime(
|
||||
file_name_buf,
|
||||
SUBGHZ_MAX_LEN_NAME,
|
||||
decoder_result->protocol->name,
|
||||
datetime);
|
||||
skip_dec_is_present = true;
|
||||
}
|
||||
} else {
|
||||
subghz_scene_save_name_get_timefilename(file_name, "S", true);
|
||||
}
|
||||
} else {
|
||||
subghz_scene_save_name_get_timefilename(file_name, "S", true);
|
||||
}
|
||||
} else {
|
||||
name_generator_make_auto(
|
||||
file_name_buf, SUBGHZ_MAX_LEN_NAME, SUBGHZ_APP_FILENAME_PREFIX);
|
||||
furi_string_set(file_name, file_name_buf);
|
||||
}
|
||||
if(!skip_dec_is_present) {
|
||||
name_generator_make_auto_datetime(file_name_buf, SUBGHZ_MAX_LEN_NAME, NULL, datetime);
|
||||
}
|
||||
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;
|
||||
@@ -96,7 +62,9 @@ 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, "RAW", true);
|
||||
name_generator_make_auto_datetime(
|
||||
file_name_buf, SUBGHZ_MAX_LEN_NAME, "RAW", datetime);
|
||||
furi_string_set(file_name, file_name_buf);
|
||||
}
|
||||
}
|
||||
furi_string_set(subghz->file_path, dir_name);
|
||||
@@ -109,7 +77,7 @@ void subghz_scene_save_name_on_enter(void* context) {
|
||||
subghz_scene_save_name_text_input_callback,
|
||||
subghz,
|
||||
subghz->file_name_tmp,
|
||||
MAX_TEXT_INPUT_LEN,
|
||||
SUBGHZ_MAX_LEN_NAME,
|
||||
dev_name_empty);
|
||||
|
||||
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
|
||||
|
||||
@@ -131,6 +131,16 @@ const char* subghz_history_get_protocol_name(SubGhzHistory* instance, uint16_t i
|
||||
return furi_string_get_cstr(instance->tmp_string);
|
||||
}
|
||||
|
||||
FuriHalRtcDateTime subghz_history_get_datetime(SubGhzHistory* instance, uint16_t idx) {
|
||||
furi_assert(instance);
|
||||
SubGhzHistoryItem* item = SubGhzHistoryItemArray_get(instance->history->data, idx);
|
||||
if(item) {
|
||||
return item->datetime;
|
||||
} else {
|
||||
return (FuriHalRtcDateTime){};
|
||||
}
|
||||
}
|
||||
|
||||
FlipperFormat* subghz_history_get_raw_data(SubGhzHistory* instance, uint16_t idx) {
|
||||
furi_assert(instance);
|
||||
SubGhzHistoryItem* item = SubGhzHistoryItemArray_get(instance->history->data, idx);
|
||||
|
||||
@@ -70,6 +70,14 @@ uint8_t subghz_history_get_type_protocol(SubGhzHistory* instance, uint16_t idx);
|
||||
*/
|
||||
const char* subghz_history_get_protocol_name(SubGhzHistory* instance, uint16_t idx);
|
||||
|
||||
/** Get datetime from history[idx]
|
||||
*
|
||||
* @param instance - SubGhzHistory instance
|
||||
* @param idx - record index
|
||||
* @return datetime - FuriHalRtcDateTime received timestamp
|
||||
*/
|
||||
FuriHalRtcDateTime subghz_history_get_datetime(SubGhzHistory* instance, uint16_t idx);
|
||||
|
||||
/** Get string item menu to history[idx]
|
||||
*
|
||||
* @param instance - SubGhzHistory instance
|
||||
|
||||
@@ -79,6 +79,9 @@ struct SubGhz {
|
||||
SubGhzReadRAW* subghz_read_raw;
|
||||
bool raw_send_only;
|
||||
|
||||
bool save_datetime_set;
|
||||
FuriHalRtcDateTime save_datetime;
|
||||
|
||||
SubGhzLastSettings* last_settings;
|
||||
|
||||
SubGhzProtocolFlag filter;
|
||||
|
||||
Reference in New Issue
Block a user