mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-16 01:28:00 +00:00
46bc515c6a
* App Lfrfid: init * HAL-resources: add external gpios * HAL-pwm: fix frequency calculation * App LFRFID: generic manchester decoder * App LFRFID: em-marine decoder * App iButton: fix dwt timing acquire * App LFRFID: rfid reader * App LFRFID: temporary read keys on read scene * App LFRFID: remove atomic bool init. * App LFRFID: add *.c to build * App LFRFID: unstable HID decoder * App LFRFID: HID-26 reading * HAL OS: disable sleep * App LFRFID: HID-26 reader: remove debug * App LFRFID: static data decoder-analyzer * App LFRFID: very raw Indala decoder * App LFRFID: multiprotocol reader * App LFRFID: more reliable HID decoder * App LFRFID: syntax fix * App LFRFID: simple read scene * Gui: force redraw on screen stream connect * HAL-OS: allow sleep * App LFRFID: notify api, tune view, tune scene * App LFRFID: simple rfid emulator * App LFRFID: more scenes, more reliable EM decoder. * App LFRFID: format fix * App LFRFID: warning fix * Api-hal-resources: add rfid pins, rename external pins * App LFRFID: remove unused emulator * App LFRFID: use new gpio hal api * App accessor: use new ext gpio name * App LFRFID: remove unused emulator * App LFRFID: remove debug gpio * Api-hal-resources: alternate functions init * Api-hal-rfid: new api * Api-hal-ibutton: new api * Api-hal: new headers * App LFRFID: use new api in reader subroutines * App LFRFID: use new api in emulator subroutines * App LFRFID: remove old app * App LFRFID, App iButton: fix memleak * Api-hal-rfid: comments * App LFRFID: pulse joiner helper, it combines pulses of different polarity into one pulse suitable for a timer * App LFRFID: pulse joiner, now can accept only ne pulse * App LFRFID: pulse joiner, fixes * App LFRFID: EM encoder and emulation * App LFRFID: format fixes * App LFRFID: emmarine encoder cleanup * App LFRFID: HID Encoder blank * App LFRFID: Indala Encoder blank
90 lines
No EOL
2.7 KiB
C++
90 lines
No EOL
2.7 KiB
C++
#include "lf-rfid-view-manager.h"
|
|
#include "lf-rfid-event.h"
|
|
#include <callback-connector.h>
|
|
|
|
LfrfidAppViewManager::LfrfidAppViewManager() {
|
|
event_queue = osMessageQueueNew(10, sizeof(LfrfidEvent), NULL);
|
|
|
|
view_dispatcher = view_dispatcher_alloc();
|
|
auto callback = cbc::obtain_connector(this, &LfrfidAppViewManager::previous_view_callback);
|
|
|
|
// allocate views
|
|
submenu = submenu_alloc();
|
|
add_view(ViewType::Submenu, submenu_get_view(submenu));
|
|
|
|
popup = popup_alloc();
|
|
add_view(ViewType::Popup, popup_get_view(popup));
|
|
|
|
tune = new LfRfidViewTune();
|
|
add_view(ViewType::Tune, tune->get_view());
|
|
|
|
gui = static_cast<Gui*>(furi_record_open("gui"));
|
|
view_dispatcher_attach_to_gui(view_dispatcher, gui, ViewDispatcherTypeFullscreen);
|
|
|
|
// set previous view callback for all views
|
|
view_set_previous_callback(submenu_get_view(submenu), callback);
|
|
view_set_previous_callback(popup_get_view(popup), callback);
|
|
view_set_previous_callback(tune->get_view(), callback);
|
|
}
|
|
|
|
LfrfidAppViewManager::~LfrfidAppViewManager() {
|
|
// remove views
|
|
view_dispatcher_remove_view(
|
|
view_dispatcher, static_cast<uint32_t>(LfrfidAppViewManager::ViewType::Submenu));
|
|
view_dispatcher_remove_view(
|
|
view_dispatcher, static_cast<uint32_t>(LfrfidAppViewManager::ViewType::Popup));
|
|
view_dispatcher_remove_view(
|
|
view_dispatcher, static_cast<uint32_t>(LfrfidAppViewManager::ViewType::Tune));
|
|
|
|
// free view modules
|
|
submenu_free(submenu);
|
|
popup_free(popup);
|
|
delete tune;
|
|
|
|
// free dispatcher
|
|
view_dispatcher_free(view_dispatcher);
|
|
|
|
// free event queue
|
|
osMessageQueueDelete(event_queue);
|
|
}
|
|
|
|
void LfrfidAppViewManager::switch_to(ViewType type) {
|
|
view_dispatcher_switch_to_view(view_dispatcher, static_cast<uint32_t>(type));
|
|
}
|
|
|
|
Submenu* LfrfidAppViewManager::get_submenu() {
|
|
return submenu;
|
|
}
|
|
|
|
Popup* LfrfidAppViewManager::get_popup() {
|
|
return popup;
|
|
}
|
|
|
|
LfRfidViewTune* LfrfidAppViewManager::get_tune() {
|
|
return tune;
|
|
}
|
|
|
|
void LfrfidAppViewManager::receive_event(LfrfidEvent* event) {
|
|
if(osMessageQueueGet(event_queue, event, NULL, 100) != osOK) {
|
|
event->type = LfrfidEvent::Type::Tick;
|
|
}
|
|
}
|
|
|
|
void LfrfidAppViewManager::send_event(LfrfidEvent* event) {
|
|
osStatus_t result = osMessageQueuePut(event_queue, event, 0, 0);
|
|
furi_check(result == osOK);
|
|
}
|
|
|
|
uint32_t LfrfidAppViewManager::previous_view_callback(void* context) {
|
|
if(event_queue != NULL) {
|
|
LfrfidEvent event;
|
|
event.type = LfrfidEvent::Type::Back;
|
|
send_event(&event);
|
|
}
|
|
|
|
return VIEW_IGNORE;
|
|
}
|
|
|
|
void LfrfidAppViewManager::add_view(ViewType view_type, View* view) {
|
|
view_dispatcher_add_view(view_dispatcher, static_cast<uint32_t>(view_type), view);
|
|
} |