lf-rfid-app.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #include <map>
  3. #include <list>
  4. #include "lf-rfid-view-manager.h"
  5. #include "scene/lf-rfid-scene-start.h"
  6. #include "scene/lf-rfid-scene-emulate-indala.h"
  7. #include "scene/lf-rfid-scene-emulate-hid.h"
  8. #include "scene/lf-rfid-scene-emulate-emmarine.h"
  9. #include "scene/lf-rfid-scene-read-normal.h"
  10. #include "scene/lf-rfid-scene-read-indala.h"
  11. #include "scene/lf-rfid-scene-tune.h"
  12. #include "scene/lf-rfid-scene-write.h"
  13. #include "helpers/rfid-reader.h"
  14. #include "helpers/rfid-timer-emulator.h"
  15. #include <notification/notification-messages.h>
  16. class LfrfidApp {
  17. public:
  18. void run(void);
  19. LfrfidApp();
  20. ~LfrfidApp();
  21. enum class Scene : uint8_t {
  22. Exit,
  23. Start,
  24. ReadNormal,
  25. ReadIndala,
  26. EmulateIndala,
  27. EmulateHID,
  28. EmulateEM,
  29. Tune,
  30. Write,
  31. };
  32. LfrfidAppViewManager* get_view_manager();
  33. void switch_to_next_scene(Scene index);
  34. void search_and_switch_to_previous_scene(std::initializer_list<Scene> scenes_list);
  35. bool switch_to_previous_scene(uint8_t count = 1);
  36. Scene get_previous_scene();
  37. void notify_green_blink();
  38. void notify_success();
  39. char* get_text_store();
  40. uint8_t get_text_store_size();
  41. void set_text_store(const char* text...);
  42. RfidReader* get_reader();
  43. RfidTimerEmulator* get_emulator();
  44. RfidWriter* get_writer();
  45. private:
  46. std::list<Scene> previous_scenes_list = {Scene::Exit};
  47. Scene current_scene = Scene::Start;
  48. LfrfidAppViewManager view;
  49. std::map<Scene, LfrfidScene*> scenes = {
  50. {Scene::Start, new LfrfidSceneStart()},
  51. {Scene::ReadNormal, new LfrfidSceneReadNormal()},
  52. {Scene::ReadIndala, new LfrfidSceneReadIndala()},
  53. {Scene::EmulateIndala, new LfrfidSceneEmulateIndala()},
  54. {Scene::EmulateHID, new LfrfidSceneEmulateHID()},
  55. {Scene::EmulateEM, new LfrfidSceneEmulateEMMarine()},
  56. {Scene::Tune, new LfrfidSceneTune()},
  57. {Scene::Write, new LfrfidSceneWrite()},
  58. };
  59. static const uint8_t text_store_size = 128;
  60. char text_store[text_store_size + 1];
  61. NotificationApp* notification;
  62. RfidReader reader;
  63. RfidTimerEmulator emulator;
  64. RfidWriter writer;
  65. };