lfrfid-app-scene-read.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "lfrfid-app-scene-read.h"
  2. void LfRfidAppSceneRead::on_enter(LfRfidApp* app, bool need_restore) {
  3. auto popup = app->view_controller.get<PopupVM>();
  4. popup->set_header("Reading\nLF RFID", 89, 34, AlignCenter, AlignTop);
  5. popup->set_icon(0, 3, &I_RFIDDolphinReceive_97x61);
  6. app->view_controller.switch_to<PopupVM>();
  7. app->worker.start_read();
  8. }
  9. bool LfRfidAppSceneRead::on_event(LfRfidApp* app, LfRfidApp::Event* event) {
  10. bool consumed = false;
  11. if(event->type == LfRfidApp::EventType::Tick) {
  12. if(app->worker.read()) {
  13. notification_message(app->notification, &sequence_success);
  14. app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::ReadSuccess);
  15. } else {
  16. if(app->worker.any_read()) {
  17. notification_message(app->notification, &sequence_blink_green_10);
  18. } else if(app->worker.detect()) {
  19. notification_message(app->notification, &sequence_blink_blue_10);
  20. } else {
  21. notification_message(app->notification, &sequence_blink_red_10);
  22. }
  23. }
  24. }
  25. return consumed;
  26. }
  27. void LfRfidAppSceneRead::on_exit(LfRfidApp* app) {
  28. app->view_controller.get<PopupVM>()->clean();
  29. app->worker.stop_read();
  30. }