lfrfid-app-scene-emulate.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #include "lfrfid-app-scene-emulate.h"
  2. void LfRfidAppSceneEmulate::on_enter(LfRfidApp* app, bool need_restore) {
  3. string_init(data_string);
  4. uint8_t* data = app->worker.key.get_data();
  5. for(uint8_t i = 0; i < app->worker.key.get_type_data_count(); i++) {
  6. string_cat_printf(data_string, "%02X", data[i]);
  7. }
  8. auto popup = app->view_controller.get<PopupVM>();
  9. popup->set_header("Emulating", 90, 34, AlignCenter, AlignTop);
  10. popup->set_text(string_get_cstr(data_string), 90, 48, AlignCenter, AlignTop);
  11. popup->set_icon(0, 4, I_RFIDDolphinSend_98x60);
  12. app->view_controller.switch_to<PopupVM>();
  13. app->worker.start_emulate();
  14. }
  15. bool LfRfidAppSceneEmulate::on_event(LfRfidApp* app, LfRfidApp::Event* event) {
  16. bool consumed = false;
  17. if(event->type == LfRfidApp::EventType::Tick) {
  18. notification_message(app->notification, &sequence_blink_cyan_10);
  19. }
  20. return consumed;
  21. }
  22. void LfRfidAppSceneEmulate::on_exit(LfRfidApp* app) {
  23. app->view_controller.get<PopupVM>()->clean();
  24. app->worker.stop_emulate();
  25. string_clear(data_string);
  26. }