seader_i.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #pragma once
  2. #include <stdlib.h> // malloc
  3. #include <stdint.h> // uint32_t
  4. #include <stdarg.h> // __VA_ARGS__
  5. #include <string.h>
  6. #include <stdio.h>
  7. #include <furi.h>
  8. #include <furi_hal.h>
  9. #include <gui/gui.h>
  10. #include <gui/view_dispatcher.h>
  11. #include <gui/scene_manager.h>
  12. #include <notification/notification_messages.h>
  13. #include <seader_icons.h>
  14. #include <gui/modules/submenu.h>
  15. #include <gui/modules/popup.h>
  16. #include <gui/modules/loading.h>
  17. #include <gui/modules/text_input.h>
  18. #include <gui/modules/widget.h>
  19. #include <input/input.h>
  20. // ASN1
  21. #include <asn_system.h>
  22. #include <asn_internal.h>
  23. #include <asn_codecs_prim.h>
  24. #include <asn_codecs.h>
  25. #include <asn_application.h>
  26. #include <Payload.h>
  27. #include <FrameProtocol.h>
  28. #include "scenes/seader_scene.h"
  29. #include "sub.h"
  30. #include "seader.h"
  31. #include "ccid.h"
  32. #include "uart.h"
  33. #include "rfal_picopass.h"
  34. #include "seader_worker.h"
  35. #include "seader_credential.h"
  36. #define WORKER_ALL_RX_EVENTS \
  37. (WorkerEvtStop | WorkerEvtRxDone | WorkerEvtCfgChange | WorkerEvtLineCfgSet | \
  38. WorkerEvtCtrlLineSet)
  39. #define WORKER_ALL_TX_EVENTS (WorkerEvtTxStop | WorkerEvtSamRx)
  40. #define SEADER_TEXT_STORE_SIZE 128
  41. enum SeaderCustomEvent {
  42. // Reserve first 100 events for button types and indexes, starting from 0
  43. SeaderCustomEventReserved = 100,
  44. SeaderCustomEventViewExit,
  45. SeaderCustomEventWorkerExit,
  46. SeaderCustomEventByteInputDone,
  47. SeaderCustomEventTextInputDone,
  48. };
  49. typedef enum {
  50. WorkerEvtStop = (1 << 0),
  51. WorkerEvtRxDone = (1 << 1),
  52. WorkerEvtTxStop = (1 << 2),
  53. WorkerEvtSamRx = (1 << 3),
  54. WorkerEvtCfgChange = (1 << 4),
  55. WorkerEvtLineCfgSet = (1 << 5),
  56. WorkerEvtCtrlLineSet = (1 << 6),
  57. } WorkerEvtFlags;
  58. struct Seader {
  59. bool revert_power;
  60. SeaderWorker* worker;
  61. ViewDispatcher* view_dispatcher;
  62. Gui* gui;
  63. NotificationApp* notifications;
  64. SceneManager* scene_manager;
  65. SeaderUartBridge* uart;
  66. SeaderCredential* credential;
  67. char text_store[SEADER_TEXT_STORE_SIZE + 1];
  68. FuriString* text_box_store;
  69. // Common Views
  70. Submenu* submenu;
  71. Popup* popup;
  72. Loading* loading;
  73. TextInput* text_input;
  74. Widget* widget;
  75. };
  76. typedef enum {
  77. SeaderViewMenu,
  78. SeaderViewPopup,
  79. SeaderViewLoading,
  80. SeaderViewTextInput,
  81. SeaderViewWidget,
  82. } SeaderView;
  83. void seader_text_store_set(Seader* seader, const char* text, ...);
  84. void seader_text_store_clear(Seader* seader);
  85. void seader_blink_start(Seader* seader);
  86. void seader_blink_stop(Seader* seader);
  87. void seader_show_loading_popup(void* context, bool show);