uhf_app_i.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #pragma once
  2. #include <furi.h>
  3. #include <gui/gui.h>
  4. #include <gui/view_dispatcher.h>
  5. #include <gui/scene_manager.h>
  6. #include <gui/canvas_i.h>
  7. #include <notification/notification_messages.h>
  8. #include <gui/modules/submenu.h>
  9. #include <gui/modules/popup.h>
  10. #include <gui/modules/loading.h>
  11. #include <gui/modules/text_input.h>
  12. #include <gui/modules/widget.h>
  13. #include <input/input.h>
  14. #include "uhf_app.h"
  15. #include "uhf_worker.h"
  16. #include "uhf_device.h"
  17. #include "scenes/uhf_scene.h"
  18. #include <storage/storage.h>
  19. #include <lib/toolbox/path.h>
  20. #include <toolbox/path.h>
  21. #include <flipper_format/flipper_format.h>
  22. #include <uhf_rfid_icons.h>
  23. #define UHF_TEXT_STORE_SIZE 128
  24. // #define UHF_APPS_DATA_FOLDER EXT_PATH("apps_data")
  25. // #define UHF_APPS_STORAGE_FOLDER
  26. // UHF_APPS_DATA_FOLDER "/"
  27. // "uhf_rfid"
  28. // #define UHF_FILE_EXTENSION ".uhf"
  29. enum UHFCustomEvent {
  30. // Reserve first 100 events for button types and indexes, starting from 0
  31. UHFCustomEventReserved = 100,
  32. UHFCustomEventVerifyDone,
  33. UHFCustomEventViewExit,
  34. UHFCustomEventWorkerExit,
  35. UHFCustomEventByteInputDone,
  36. UHFCustomEventTextInputDone,
  37. };
  38. typedef enum {
  39. EventTypeTick,
  40. EventTypeKey,
  41. } EventType;
  42. struct UHFApp {
  43. UHFWorker* worker;
  44. ViewDispatcher* view_dispatcher;
  45. Gui* gui;
  46. NotificationApp* notifications;
  47. SceneManager* scene_manager;
  48. // Storage* storage;
  49. UHFDevice* uhf_device;
  50. char text_store[UHF_TEXT_STORE_SIZE + 1];
  51. FuriString* text_box_store;
  52. // Common Views
  53. Submenu* submenu;
  54. Popup* popup;
  55. Loading* loading;
  56. TextInput* text_input;
  57. Widget* widget;
  58. };
  59. typedef enum {
  60. UHFViewMenu,
  61. UHFViewPopup,
  62. UHFViewLoading,
  63. UHFViewTextInput,
  64. UHFViewWidget,
  65. } UHFView;
  66. UHFApp* uhf_app_alloc();
  67. void uhf_text_store_set(UHFApp* uhf, const char* text, ...);
  68. void uhf_text_store_clear(UHFApp* uhf);
  69. void uhf_blink_start(UHFApp* uhf);
  70. void uhf_blink_stop(UHFApp* uhf);
  71. void uhf_show_loading_popup(void* context, bool show);
  72. /** Check if memory is set to pattern
  73. *
  74. * @warning zero size will return false
  75. *
  76. * @param[in] data Pointer to the byte array
  77. * @param[in] pattern The pattern
  78. * @param[in] size The byte array size
  79. *
  80. * @return True if memory is set to pattern, false otherwise
  81. */
  82. bool uhf_is_memset(const uint8_t* data, const uint8_t pattern, size_t size);
  83. char* convertToHexString(const uint8_t* array, size_t length);
  84. bool uhf_save_read_data(UHFResponseData* uhf_response_data, Storage* storage, const char* filename);