lfrfid-app-scene-read.cpp 993 B

12345678910111213141516171819202122232425262728293031
  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. notification_message(app->notification, &sequence_blink_red_10);
  17. }
  18. }
  19. return consumed;
  20. }
  21. void LfRfidAppSceneRead::on_exit(LfRfidApp* app) {
  22. app->view_controller.get<PopupVM>()->clean();
  23. app->worker.stop_read();
  24. }