lfrfid_app_scene_rpc.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "lfrfid_app_scene_rpc.h"
  2. #include <core/common_defines.h>
  3. #include <dolphin/dolphin.h>
  4. static const NotificationSequence sequence_blink_start_magenta = {
  5. &message_blink_start_10,
  6. &message_blink_set_color_magenta,
  7. &message_do_not_reset,
  8. NULL,
  9. };
  10. static const NotificationSequence sequence_blink_stop = {
  11. &message_blink_stop,
  12. NULL,
  13. };
  14. void LfRfidAppSceneRpc::on_enter(LfRfidApp* app, bool /* need_restore */) {
  15. auto popup = app->view_controller.get<PopupVM>();
  16. popup->set_header("LF RFID", 89, 30, AlignCenter, AlignTop);
  17. popup->set_text("RPC mode", 89, 43, AlignCenter, AlignTop);
  18. popup->set_icon(0, 3, &I_RFIDDolphinSend_97x61);
  19. app->view_controller.switch_to<PopupVM>();
  20. notification_message(app->notification, &sequence_display_backlight_on);
  21. }
  22. bool LfRfidAppSceneRpc::on_event(LfRfidApp* app, LfRfidApp::Event* event) {
  23. UNUSED(app);
  24. UNUSED(event);
  25. bool consumed = false;
  26. if(event->type == LfRfidApp::EventType::Exit) {
  27. consumed = true;
  28. LfRfidApp::Event view_event;
  29. view_event.type = LfRfidApp::EventType::Back;
  30. app->view_controller.send_event(&view_event);
  31. } else if(event->type == LfRfidApp::EventType::EmulateStart) {
  32. auto popup = app->view_controller.get<PopupVM>();
  33. consumed = true;
  34. emulating = true;
  35. app->text_store.set("emulating\n%s", app->worker.key.get_name());
  36. popup->set_text(app->text_store.text, 89, 43, AlignCenter, AlignTop);
  37. notification_message(app->notification, &sequence_blink_start_magenta);
  38. }
  39. return consumed;
  40. }
  41. void LfRfidAppSceneRpc::on_exit(LfRfidApp* app) {
  42. if(emulating) {
  43. app->worker.stop_emulate();
  44. notification_message(app->notification, &sequence_blink_stop);
  45. }
  46. app->view_controller.get<PopupVM>()->clean();
  47. }