New LF-RFID app (#534)
* 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
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
#include "lfrfid-debug-app-scene-start.h"
|
||||
|
||||
typedef enum {
|
||||
SubmenuTune,
|
||||
} SubmenuIndex;
|
||||
|
||||
void LfRfidDebugAppSceneStart::on_enter(LfRfidDebugApp* app, bool need_restore) {
|
||||
auto submenu = app->view_controller.get<SubmenuVM>();
|
||||
auto callback = cbc::obtain_connector(this, &LfRfidDebugAppSceneStart::submenu_callback);
|
||||
|
||||
submenu->add_item("Tune", SubmenuTune, callback, app);
|
||||
|
||||
if(need_restore) {
|
||||
submenu->set_selected_item(submenu_item_selected);
|
||||
}
|
||||
app->view_controller.switch_to<SubmenuVM>();
|
||||
}
|
||||
|
||||
bool LfRfidDebugAppSceneStart::on_event(LfRfidDebugApp* app, LfRfidDebugApp::Event* event) {
|
||||
bool consumed = false;
|
||||
|
||||
if(event->type == LfRfidDebugApp::EventType::MenuSelected) {
|
||||
submenu_item_selected = event->payload.menu_index;
|
||||
switch(event->payload.menu_index) {
|
||||
case SubmenuTune:
|
||||
app->scene_controller.switch_to_next_scene(LfRfidDebugApp::SceneType::TuneScene);
|
||||
break;
|
||||
}
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void LfRfidDebugAppSceneStart::on_exit(LfRfidDebugApp* app) {
|
||||
app->view_controller.get<SubmenuVM>()->clean();
|
||||
}
|
||||
|
||||
void LfRfidDebugAppSceneStart::submenu_callback(void* context, uint32_t index) {
|
||||
LfRfidDebugApp* app = static_cast<LfRfidDebugApp*>(context);
|
||||
LfRfidDebugApp::Event event;
|
||||
|
||||
event.type = LfRfidDebugApp::EventType::MenuSelected;
|
||||
event.payload.menu_index = index;
|
||||
|
||||
app->view_controller.send_event(&event);
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "../lfrfid-debug-app.h"
|
||||
|
||||
class LfRfidDebugAppSceneStart : public GenericScene<LfRfidDebugApp> {
|
||||
public:
|
||||
void on_enter(LfRfidDebugApp* app, bool need_restore) final;
|
||||
bool on_event(LfRfidDebugApp* app, LfRfidDebugApp::Event* event) final;
|
||||
void on_exit(LfRfidDebugApp* app) final;
|
||||
|
||||
private:
|
||||
void submenu_callback(void* context, uint32_t index);
|
||||
uint32_t submenu_item_selected = 0;
|
||||
};
|
@@ -0,0 +1,28 @@
|
||||
#include "lfrfid-debug-app-scene-tune.h"
|
||||
|
||||
void LfRfidDebugAppSceneTune::on_enter(LfRfidDebugApp* app, bool need_restore) {
|
||||
app->view_controller.switch_to<LfRfidViewTuneVM>();
|
||||
|
||||
api_hal_rfid_pins_read();
|
||||
api_hal_rfid_tim_read(125000, 0.5);
|
||||
api_hal_rfid_tim_read_start();
|
||||
}
|
||||
|
||||
bool LfRfidDebugAppSceneTune::on_event(LfRfidDebugApp* app, LfRfidDebugApp::Event* event) {
|
||||
bool consumed = false;
|
||||
|
||||
LfRfidViewTuneVM* tune = app->view_controller;
|
||||
|
||||
if(tune->is_dirty()) {
|
||||
api_hal_rfid_set_read_period(tune->get_ARR());
|
||||
api_hal_rfid_set_read_pulse(tune->get_CCR());
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void LfRfidDebugAppSceneTune::on_exit(LfRfidDebugApp* app) {
|
||||
api_hal_rfid_tim_read_stop();
|
||||
api_hal_rfid_tim_reset();
|
||||
api_hal_rfid_pins_reset();
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include "../lfrfid-debug-app.h"
|
||||
|
||||
class LfRfidDebugAppSceneTune : public GenericScene<LfRfidDebugApp> {
|
||||
public:
|
||||
void on_enter(LfRfidDebugApp* app, bool need_restore) final;
|
||||
bool on_event(LfRfidDebugApp* app, LfRfidDebugApp::Event* event) final;
|
||||
void on_exit(LfRfidDebugApp* app) final;
|
||||
};
|
Reference in New Issue
Block a user