2022-01-05 16:10:18 +00:00
|
|
|
#include "accessor_app.h"
|
2021-04-28 12:13:25 +00:00
|
|
|
#include <furi.h>
|
2022-01-05 16:10:18 +00:00
|
|
|
#include <furi_hal.h>
|
2021-04-28 12:13:25 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
void AccessorApp::run(void) {
|
|
|
|
AccessorEvent event;
|
|
|
|
bool consumed;
|
|
|
|
bool exit = false;
|
|
|
|
|
|
|
|
wiegand.begin();
|
2022-03-29 13:01:56 +00:00
|
|
|
onewire_host_start(onewire_host);
|
2021-04-28 12:13:25 +00:00
|
|
|
|
|
|
|
scenes[current_scene]->on_enter(this);
|
|
|
|
|
|
|
|
while(!exit) {
|
|
|
|
view.receive_event(&event);
|
|
|
|
|
|
|
|
consumed = scenes[current_scene]->on_event(this, &event);
|
|
|
|
|
|
|
|
if(!consumed) {
|
|
|
|
if(event.type == AccessorEvent::Type::Back) {
|
|
|
|
exit = switch_to_previous_scene();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
scenes[current_scene]->on_exit(this);
|
2021-05-24 09:57:14 +00:00
|
|
|
|
|
|
|
wiegand.end();
|
2022-03-29 13:01:56 +00:00
|
|
|
onewire_host_stop(onewire_host);
|
2021-04-28 12:13:25 +00:00
|
|
|
}
|
|
|
|
|
2023-01-17 15:07:47 +00:00
|
|
|
AccessorApp::AccessorApp()
|
|
|
|
: text_store{0} {
|
2022-08-11 08:28:57 +00:00
|
|
|
notification = static_cast<NotificationApp*>(furi_record_open(RECORD_NOTIFICATION));
|
2022-03-29 13:01:56 +00:00
|
|
|
onewire_host = onewire_host_alloc();
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_power_enable_otg();
|
2021-04-28 12:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AccessorApp::~AccessorApp() {
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_power_disable_otg();
|
2022-08-11 08:28:57 +00:00
|
|
|
furi_record_close(RECORD_NOTIFICATION);
|
2022-03-29 13:01:56 +00:00
|
|
|
onewire_host_free(onewire_host);
|
2021-04-28 12:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AccessorAppViewManager* AccessorApp::get_view_manager() {
|
|
|
|
return &view;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AccessorApp::switch_to_next_scene(Scene next_scene) {
|
|
|
|
previous_scenes_list.push_front(current_scene);
|
|
|
|
|
|
|
|
if(next_scene != Scene::Exit) {
|
|
|
|
scenes[current_scene]->on_exit(this);
|
|
|
|
current_scene = next_scene;
|
|
|
|
scenes[current_scene]->on_enter(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AccessorApp::search_and_switch_to_previous_scene(std::initializer_list<Scene> scenes_list) {
|
|
|
|
Scene previous_scene = Scene::Start;
|
|
|
|
bool scene_found = false;
|
|
|
|
|
|
|
|
while(!scene_found) {
|
|
|
|
previous_scene = get_previous_scene();
|
|
|
|
for(Scene element : scenes_list) {
|
|
|
|
if(previous_scene == element || previous_scene == Scene::Start) {
|
|
|
|
scene_found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
scenes[current_scene]->on_exit(this);
|
|
|
|
current_scene = previous_scene;
|
|
|
|
scenes[current_scene]->on_enter(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AccessorApp::switch_to_previous_scene(uint8_t count) {
|
|
|
|
Scene previous_scene = Scene::Start;
|
|
|
|
|
|
|
|
for(uint8_t i = 0; i < count; i++) {
|
|
|
|
previous_scene = get_previous_scene();
|
|
|
|
if(previous_scene == Scene::Exit) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(previous_scene == Scene::Exit) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
scenes[current_scene]->on_exit(this);
|
|
|
|
current_scene = previous_scene;
|
|
|
|
scenes[current_scene]->on_enter(this);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AccessorApp::Scene AccessorApp::get_previous_scene() {
|
|
|
|
Scene scene = previous_scenes_list.front();
|
|
|
|
previous_scenes_list.pop_front();
|
|
|
|
return scene;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************** NOTIFY *******************************/
|
|
|
|
|
|
|
|
void AccessorApp::notify_green_blink() {
|
2021-05-24 13:44:14 +00:00
|
|
|
notification_message(notification, &sequence_blink_green_10);
|
2021-04-28 12:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AccessorApp::notify_success() {
|
2021-05-24 13:44:14 +00:00
|
|
|
notification_message(notification, &sequence_success);
|
2021-04-28 12:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************** TEXT STORE *****************************/
|
|
|
|
|
|
|
|
char* AccessorApp::get_text_store() {
|
|
|
|
return text_store;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t AccessorApp::get_text_store_size() {
|
|
|
|
return text_store_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AccessorApp::set_text_store(const char* text...) {
|
|
|
|
va_list args;
|
|
|
|
va_start(args, text);
|
|
|
|
|
|
|
|
vsnprintf(text_store, text_store_size, text, args);
|
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************** APP RESOURCES *****************************/
|
|
|
|
|
|
|
|
WIEGAND* AccessorApp::get_wiegand() {
|
|
|
|
return &wiegand;
|
|
|
|
}
|
|
|
|
|
2022-03-29 13:01:56 +00:00
|
|
|
OneWireHost* AccessorApp::get_one_wire() {
|
|
|
|
return onewire_host;
|
[FL-2399, FL-2261] Tickless sleep shenanigans (#1168)
* Disable USART in sleep
* Restore UART state on suspend/resume
* FuriHal: Enable stop mode and add insomnia to I2C and SPI
* Remove IDLE interrupt
* FuriHal: add FPU isr and disable all FPU interrupt, add core2 stop mode configuration on deep sleep
* FuriHal: tie stop mode debug with debug rtc flag
* FuriHal: adjust flash latency on clock switch, tie mcu debug with RTC debug flag
* FuriHal: move resource init to early stage
* Add EXTI pending check, enable debug traps with compile-time flag
* Wrap sleep debug functions in conditional compilation
* Remove erroneous changed
* Do not use CSS, remove it from everywhere
* Enable/disable USB on VBUS connect (prototype)
* FuriHal: add LPMS and DEEPSLEEP magic, workaround state inconsistency between cores
* FuriHal: honor c1 LMPS
* USB mode switch fix
* Applications: add flags and insomnia bypass system
* Correct spelling
* FuriHal: cleanup insomnia usage, reset sleep flags on wakeup, add shutdown api
* FuriHal: extra check on reinit request
* FuriHal: rename gpio_display_rst pin to gpio_display_rst_n
* FuriHal: add debug HAL
* FuriHal: add some magic to core2 reload procedure, fix issue with crash on ble keyboard exit
* FuriHal: cleanup ble glue, add BLE_GLUE_DEBUG flag
* FuriHal: ble reinit API, move os timer to LPTIM1 for deep sleep capability, shutdown that works
* FuriHal: take insomnia while shutdown
* Remove USB switch on/off on VBUS change
* Better tick skew handling
* Improve tick consistency under load
* Add USB_HP dummy IRQ handler
* Move interrupt check closer to sleep
* Clean up includes
* Re-enable Insomnia globally
* FuriHal: enable CSS
* FuriHal: remove questionable core2 clock shenanigans
* FuriHal: use core1 RCC registers in idle timer config
* FuriHal: return back CSS handlers, add lptim isr dispatching
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
Co-authored-by: nminaylov <nm29719@gmail.com>
2022-04-29 13:29:51 +00:00
|
|
|
}
|