lfrfid_app_scene_emulate.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #include "lfrfid_app_scene_emulate.h"
  2. #include <core/common_defines.h>
  3. #include <dolphin/dolphin.h>
  4. void LfRfidAppSceneEmulate::on_enter(LfRfidApp* app, bool /* need_restore */) {
  5. DOLPHIN_DEED(DolphinDeedRfidEmulate);
  6. auto popup = app->view_controller.get<PopupVM>();
  7. popup->set_header("Emulating", 89, 30, AlignCenter, AlignTop);
  8. if(string_size(app->file_name)) {
  9. popup->set_text(string_get_cstr(app->file_name), 89, 43, AlignCenter, AlignTop);
  10. } else {
  11. popup->set_text(
  12. protocol_dict_get_name(app->dict, app->protocol_id), 89, 43, AlignCenter, AlignTop);
  13. }
  14. popup->set_icon(0, 3, &I_RFIDDolphinSend_97x61);
  15. app->view_controller.switch_to<PopupVM>();
  16. lfrfid_worker_start_thread(app->lfworker);
  17. lfrfid_worker_emulate_start(app->lfworker, (LFRFIDProtocol)app->protocol_id);
  18. notification_message(app->notification, &sequence_blink_start_magenta);
  19. }
  20. bool LfRfidAppSceneEmulate::on_event(LfRfidApp* app, LfRfidApp::Event* event) {
  21. UNUSED(app);
  22. UNUSED(event);
  23. bool consumed = false;
  24. return consumed;
  25. }
  26. void LfRfidAppSceneEmulate::on_exit(LfRfidApp* app) {
  27. app->view_controller.get<PopupVM>()->clean();
  28. lfrfid_worker_stop(app->lfworker);
  29. lfrfid_worker_stop_thread(app->lfworker);
  30. notification_message(app->notification, &sequence_blink_stop);
  31. }