1
mirror of https://github.com/flipperdevices/flipperzero-firmware.git synced 2025-12-13 05:19:50 +04:00

[FL-1542], [FL-1603] Generate random name (#602)

* Lib: add random name library
* Text_input: add default text clearing
* All: rework all applications with new text_input API
* Nfc: fix removing dev file on save_name scene enter
* Lib: move all free radicals to toolbox and update API usage.

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
gornekich
2021-07-25 14:34:54 +03:00
committed by GitHub
parent 0c7a8edf51
commit ebd158a823
39 changed files with 142 additions and 132 deletions

View File

@@ -3,7 +3,7 @@
#include <callback-connector.h>
#include <m-string.h>
#include <file-worker-cpp.h>
#include <path.h>
#include <lib/toolbox/path.h>
const char* iButtonApp::app_folder = "/any/ibutton";
const char* iButtonApp::app_extension = ".ibtn";
@@ -40,9 +40,6 @@ iButtonApp::iButtonApp()
: notification{"notification"} {
api_hal_power_insomnia_enter();
key_worker = new KeyWorker(&ibutton_gpio);
// we need random
srand(DWT->CYCCNT);
}
iButtonApp::~iButtonApp() {
@@ -186,38 +183,6 @@ uint8_t iButtonApp::get_text_store_size() {
return text_store_size;
}
void iButtonApp::generate_random_name(char* name, uint8_t max_name_size) {
const uint8_t prefix_size = 9;
const char* prefix[prefix_size] = {
"ancient",
"hollow",
"strange",
"disappeared",
"unknown",
"unthinkable",
"unnamable",
"nameless",
"my",
};
const uint8_t suffix_size = 8;
const char* suffix[suffix_size] = {
"door",
"entrance",
"doorway",
"entry",
"portal",
"entree",
"opening",
"crack",
};
sniprintf(
name, max_name_size, "%s_%s", prefix[rand() % prefix_size], suffix[rand() % suffix_size]);
// to upper
name[0] = name[0] - 0x20;
}
// file managment
bool iButtonApp::save_key(const char* key_name) {
// Create ibutton directory if necessary