uhf_app_i.h 2.0 KB

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