Add File Naming setting for more detailed naming (#3002)

* added filename mode setting
* added furi_flag checks for when filename_mode is set
* changed naming for ibutton, lfrfid and subghz
* requested changes from PR
* Lib: gather all naming bits and pieces under name generator module. Properly bump api version. FuriHal: fix RTC flag enum.
* PR requested changes
* bug fix for arg type
* added functionality for other application scenes
* Lib: cleanup name generator API, simplify usage. Sync API symbols.
* Lib: proper size type in name_generator. Cleanup.
* FuriHal: cleanup rtc api usage across firmware

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Max
2023-09-01 14:57:49 +09:00
committed by GitHub
co-authored by あく
parent e5fdb2e069
commit 52b5966262
27 changed files with 207 additions and 98 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ env.Append(
File("manchester_decoder.h"),
File("manchester_encoder.h"),
File("path.h"),
File("random_name.h"),
File("name_generator.h"),
File("sha256.h"),
File("crc32_calc.h"),
File("dir_walk.h"),
+75
View File
@@ -0,0 +1,75 @@
#include "name_generator.h"
#include <stdio.h>
#include <stdint.h>
#include <furi_hal_rtc.h>
#include <stdlib.h>
#include <stdbool.h>
#include <furi.h>
const char* const name_generator_left[] = {
"ancient", "hollow", "strange", "disappeared", "unknown", "unthinkable", "unnameable",
"nameless", "my", "concealed", "forgotten", "hidden", "mysterious", "obscure",
"random", "remote", "uncharted", "undefined", "untraveled", "untold",
};
const char* const name_generator_right[] = {
"door",
"entrance",
"doorway",
"entry",
"portal",
"entree",
"opening",
"crack",
"access",
"corridor",
"passage",
"port",
};
void name_generator_make_auto(char* name, size_t max_name_size, const char* prefix) {
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDetailedFilename)) {
name_generator_make_detailed(name, max_name_size, prefix);
} else {
name_generator_make_random(name, max_name_size);
}
}
void name_generator_make_random(char* name, size_t max_name_size) {
furi_assert(name);
furi_assert(max_name_size);
uint8_t name_generator_left_i = rand() % COUNT_OF(name_generator_left);
uint8_t name_generator_right_i = rand() % COUNT_OF(name_generator_right);
snprintf(
name,
max_name_size,
"%s_%s",
name_generator_left[name_generator_left_i],
name_generator_right[name_generator_right_i]);
// Set first symbol to upper case
name[0] = name[0] - 0x20;
}
void name_generator_make_detailed(char* name, size_t max_name_size, const char* prefix) {
furi_assert(name);
furi_assert(max_name_size);
furi_assert(prefix);
FuriHalRtcDateTime dateTime;
furi_hal_rtc_get_datetime(&dateTime);
snprintf(
name,
max_name_size,
"%s-%.4d_%.2d_%.2d-%.2d_%.2d",
prefix,
dateTime.year,
dateTime.month,
dateTime.day,
dateTime.hour,
dateTime.minute);
}
+35
View File
@@ -0,0 +1,35 @@
#pragma once
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Generates detailed/random name based on furi_hal flags
*
* @param name buffer to write random name
* @param max_name_size length of given buffer
* @param[in] prefix The prefix of the name
*/
void name_generator_make_auto(char* name, size_t max_name_size, const char* prefix);
/** Generates random name
*
* @param name buffer to write random name
* @param max_name_size length of given buffer
*/
void name_generator_make_random(char* name, size_t max_name_size);
/** Generates detailed name
*
* @param name buffer to write random name
* @param max_name_size length of given buffer
* @param[in] prefix The prefix of the name
*/
void name_generator_make_detailed(char* name, size_t max_name_size, const char* prefix);
#ifdef __cplusplus
}
#endif
-35
View File
@@ -1,35 +0,0 @@
#include "random_name.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <furi.h>
void set_random_name(char* name, uint8_t max_name_size) {
const char* prefix[] = {
"ancient", "hollow", "strange", "disappeared", "unknown",
"unthinkable", "unnamable", "nameless", "my", "concealed",
"forgotten", "hidden", "mysterious", "obscure", "random",
"remote", "uncharted", "undefined", "untravelled", "untold",
};
const char* suffix[] = {
"door",
"entrance",
"doorway",
"entry",
"portal",
"entree",
"opening",
"crack",
"access",
"corridor",
"passage",
"port",
};
uint8_t prefix_i = rand() % COUNT_OF(prefix);
uint8_t suffix_i = rand() % COUNT_OF(suffix);
snprintf(name, max_name_size, "%s_%s", prefix[prefix_i], suffix[suffix_i]);
// Set first symbol to upper case
name[0] = name[0] - 0x20;
}
-17
View File
@@ -1,17 +0,0 @@
#pragma once
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Generates random name
* @param name buffer to write random name
* @param max_name_size length of given buffer
*/
void set_random_name(char* name, uint8_t max_name_size);
#ifdef __cplusplus
}
#endif