[FL-1371] Lfrfid app: add manufacturers to "Add manually" scene (#577)

* Lfrfid app: add manufacturers to "Add manually" scene
* Lfrfid app: fix submenu name size
This commit is contained in:
SG 2021-07-13 19:06:54 +10:00 committed by GitHub
parent 3571b58d0a
commit e31999b116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 3 deletions

View File

@ -17,6 +17,22 @@ const char* lfrfid_key_get_type_string(LfrfidKeyType type) {
return "Unknown";
}
const char* lfrfid_key_get_manufacturer_string(LfrfidKeyType type) {
switch(type) {
case LfrfidKeyType::KeyEM4100:
return "Em-Marine";
break;
case LfrfidKeyType::KeyH10301:
return "HID";
break;
case LfrfidKeyType::KeyI40134:
return "Indala";
break;
}
return "Unknown";
}
bool lfrfid_key_get_string_type(const char* string, LfrfidKeyType* type) {
bool result = true;

View File

@ -11,5 +11,6 @@ enum class LfrfidKeyType : uint8_t {
};
const char* lfrfid_key_get_type_string(LfrfidKeyType type);
const char* lfrfid_key_get_manufacturer_string(LfrfidKeyType type);
bool lfrfid_key_get_string_type(const char* string, LfrfidKeyType* type);
uint8_t lfrfid_key_get_type_data_count(LfrfidKeyType type);

View File

@ -3,9 +3,13 @@
void LfRfidAppSceneSaveType::on_enter(LfRfidApp* app, bool need_restore) {
auto submenu = app->view_controller.get<SubmenuVM>();
for(uint8_t i = 0; i <= static_cast<uint8_t>(LfrfidKeyType::KeyI40134); i++) {
submenu->add_item(
lfrfid_key_get_type_string(static_cast<LfrfidKeyType>(i)), i, submenu_callback, app);
for(uint8_t i = 0; i <= keys_count; i++) {
string_init_printf(
submenu_name[i],
"%s %s",
lfrfid_key_get_manufacturer_string(static_cast<LfrfidKeyType>(i)),
lfrfid_key_get_type_string(static_cast<LfrfidKeyType>(i)));
submenu->add_item(string_get_cstr(submenu_name[i]), i, submenu_callback, app);
}
if(need_restore) {
@ -33,6 +37,9 @@ bool LfRfidAppSceneSaveType::on_event(LfRfidApp* app, LfRfidApp::Event* event) {
void LfRfidAppSceneSaveType::on_exit(LfRfidApp* app) {
app->view_controller.get<SubmenuVM>()->clean();
for(uint8_t i = 0; i <= keys_count; i++) {
string_clear(submenu_name[i]);
}
}
void LfRfidAppSceneSaveType::submenu_callback(void* context, uint32_t index) {

View File

@ -10,4 +10,6 @@ public:
private:
static void submenu_callback(void* context, uint32_t index);
uint32_t submenu_item_selected = 0;
static const uint8_t keys_count = static_cast<uint8_t>(LfrfidKeyType::KeyI40134);
string_t submenu_name[keys_count + 1];
};