mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-21 10:13:10 +00:00
22e1ecb642
* Hal lfrfid: add read timer pulse and period config fns * New debug application for lfrfid subsystem * New lfrfid: app, fix naming * App lfrfid: assets * Container view module * App ibutton: remove unused header * App lfrfid scenes * App notification, add yield to blocking operations, add speaker volume control * App lfrfid: reading key scene * Assets: placeholder icon * App lfrfid: reworked container view module * App lfrfid: new scenes * App lfrfid: write scene * App lfrfid: write hid * App lfrfid: emulate scene * App lfrfid: save name scene * App lfrfid: add missing file
60 lines
1.9 KiB
C++
60 lines
1.9 KiB
C++
#include "lfrfid-app-scene-readed-menu.h"
|
|
|
|
typedef enum {
|
|
SubmenuWrite,
|
|
SubmenuNameAndSave,
|
|
SubmenuEmulate,
|
|
} SubmenuIndex;
|
|
|
|
void LfRfidAppSceneReadedMenu::on_enter(LfRfidApp* app, bool need_restore) {
|
|
auto submenu = app->view_controller.get<SubmenuVM>();
|
|
|
|
submenu->add_item("Write", SubmenuWrite, submenu_callback, app);
|
|
submenu->add_item("Name and Save", SubmenuNameAndSave, submenu_callback, app);
|
|
submenu->add_item("Emulate", SubmenuEmulate, submenu_callback, app);
|
|
|
|
if(need_restore) {
|
|
submenu->set_selected_item(submenu_item_selected);
|
|
}
|
|
|
|
app->view_controller.switch_to<SubmenuVM>();
|
|
}
|
|
|
|
bool LfRfidAppSceneReadedMenu::on_event(LfRfidApp* app, LfRfidApp::Event* event) {
|
|
bool consumed = false;
|
|
|
|
if(event->type == LfRfidApp::EventType::MenuSelected) {
|
|
submenu_item_selected = event->payload.menu_index;
|
|
switch(event->payload.menu_index) {
|
|
case SubmenuWrite:
|
|
app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::Write);
|
|
break;
|
|
case SubmenuNameAndSave:
|
|
app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::SaveName);
|
|
break;
|
|
case SubmenuEmulate:
|
|
app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::Emulate);
|
|
break;
|
|
}
|
|
consumed = true;
|
|
} else if(event->type == LfRfidApp::EventType::Back) {
|
|
app->scene_controller.search_and_switch_to_previous_scene({LfRfidApp::SceneType::Start});
|
|
consumed = true;
|
|
}
|
|
|
|
return consumed;
|
|
}
|
|
|
|
void LfRfidAppSceneReadedMenu::on_exit(LfRfidApp* app) {
|
|
app->view_controller.get<SubmenuVM>()->clean();
|
|
}
|
|
|
|
void LfRfidAppSceneReadedMenu::submenu_callback(void* context, uint32_t index) {
|
|
LfRfidApp* app = static_cast<LfRfidApp*>(context);
|
|
LfRfidApp::Event event;
|
|
|
|
event.type = LfRfidApp::EventType::MenuSelected;
|
|
event.payload.menu_index = index;
|
|
|
|
app->view_controller.send_event(&event);
|
|
}
|