mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-23 21:13:16 +00:00
ebd158a823
* 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>
43 lines
977 B
C
43 lines
977 B
C
#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) {
|
|
static bool rand_generator_inited = false;
|
|
|
|
if(!rand_generator_inited) {
|
|
srand(DWT->CYCCNT);
|
|
rand_generator_inited = true;
|
|
}
|
|
const char* prefix[] = {
|
|
"ancient",
|
|
"hollow",
|
|
"strange",
|
|
"disappeared",
|
|
"unknown",
|
|
"unthinkable",
|
|
"unnamable",
|
|
"nameless",
|
|
"my",
|
|
};
|
|
|
|
const char* suffix[] = {
|
|
"door",
|
|
"entrance",
|
|
"doorway",
|
|
"entry",
|
|
"portal",
|
|
"entree",
|
|
"opening",
|
|
"crack",
|
|
};
|
|
uint8_t prefix_i = rand() % SIZEOF_ARRAY(prefix);
|
|
uint8_t suffix_i = rand() % SIZEOF_ARRAY(suffix);
|
|
|
|
sniprintf(
|
|
name, max_name_size, "%s_%s", prefix[prefix_i], suffix[suffix_i]);
|
|
// Set first symbol to upper case
|
|
name[0] = name[0] - 0x20;
|
|
}
|