weebo_i.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #pragma once
  2. #include <furi.h>
  3. #include <furi_hal.h>
  4. #include <gui/gui.h>
  5. #include <gui/view_dispatcher.h>
  6. #include <gui/scene_manager.h>
  7. #include <notification/notification_messages.h>
  8. #include <storage/storage.h>
  9. #include <dialogs/dialogs.h>
  10. #include <gui/modules/submenu.h>
  11. #include <gui/modules/popup.h>
  12. #include <gui/modules/loading.h>
  13. #include <gui/modules/text_input.h>
  14. #include <gui/modules/number_input.h>
  15. #include <gui/modules/text_box.h>
  16. #include <gui/modules/widget.h>
  17. #include <input/input.h>
  18. #include <lib/flipper_format/flipper_format.h>
  19. #include <lib/toolbox/path.h>
  20. #include <lib/nfc/nfc.h>
  21. #include <nfc/nfc_poller.h>
  22. #include <nfc/nfc_listener.h>
  23. #include <nfc/nfc_device.h>
  24. #include <nfc/protocols/mf_ultralight/mf_ultralight_poller.h>
  25. #include <nfc/protocols/mf_ultralight/mf_ultralight_listener.h>
  26. #include <lib/toolbox/stream/stream.h>
  27. #include <lib/toolbox/stream/file_stream.h>
  28. /* generated by fbt from .png files in images folder */
  29. #include <weebo_icons.h>
  30. #include <amiibo.h>
  31. #include "weebo.h"
  32. #include "weebo_common.h"
  33. #include "scenes/weebo_scene.h"
  34. #define WEEBO_TEXT_STORE_SIZE 128
  35. #define WEEBO_FILE_NAME_MAX_LENGTH 64
  36. #define NTAG215_SIZE 540
  37. #define NFC3D_UID_OFFSET 0x1D4
  38. #define PAGE_SIZE 4
  39. enum WeeboCustomEvent {
  40. // Reserve first 100 events for button types and indexes, starting from 0
  41. WeeboCustomEventReserved = 100,
  42. WeeboCustomEventViewExit,
  43. WeeboCustomEventTextInputDone,
  44. WeeboCustomEventNumberInputDone,
  45. // Card writing
  46. WeeboCustomEventCardDetected,
  47. WeeboCustomEventWritingUserData,
  48. WeeboCustomEventWritingConfigData,
  49. WeeboCustomEventWriteSuccess,
  50. WeeboCustomEventWriteFailure,
  51. WeeboCustomEventWrongCard,
  52. };
  53. typedef void (*WeeboLoadingCallback)(void* context, bool state);
  54. struct Weebo {
  55. ViewDispatcher* view_dispatcher;
  56. Gui* gui;
  57. NotificationApp* notifications;
  58. SceneManager* scene_manager;
  59. Storage* storage;
  60. char text_store[WEEBO_TEXT_STORE_SIZE + 1];
  61. FuriString* text_box_store;
  62. // Common Views
  63. Submenu* submenu;
  64. Popup* popup;
  65. Loading* loading;
  66. TextInput* text_input;
  67. NumberInput* number_input;
  68. TextBox* text_box;
  69. Widget* widget;
  70. DialogsApp* dialogs;
  71. Nfc* nfc;
  72. NfcPoller* poller;
  73. NfcListener* listener;
  74. NfcDevice* nfc_device;
  75. FuriString* load_path;
  76. char file_name[WEEBO_FILE_NAME_MAX_LENGTH + 1];
  77. bool keys_loaded;
  78. nfc3d_amiibo_keys keys;
  79. WeeboLoadingCallback loading_cb;
  80. void* loading_cb_ctx;
  81. uint8_t figure[NFC3D_AMIIBO_SIZE];
  82. };
  83. typedef enum {
  84. WeeboViewMenu,
  85. WeeboViewPopup,
  86. WeeboViewLoading,
  87. WeeboViewTextInput,
  88. WeeboViewNumberInput,
  89. WeeboViewTextBox,
  90. WeeboViewWidget,
  91. } WeeboView;
  92. void weebo_text_store_set(Weebo* weebo, const char* text, ...);
  93. void weebo_text_store_clear(Weebo* weebo);
  94. void weebo_blink_start(Weebo* weebo);
  95. void weebo_blink_stop(Weebo* weebo);
  96. void weebo_show_loading_popup(void* context, bool show);
  97. void weebo_set_loading_callback(Weebo* weebo, WeeboLoadingCallback callback, void* context);
  98. bool weebo_file_select(Weebo* weebo);