lfrfid_app_scene_read.cpp 1.4 KB

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