metroflip_i.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #pragma once
  2. #include <furi.h>
  3. #include <gui/gui.h>
  4. #include <gui/view.h>
  5. #include <gui/modules/validators.h>
  6. #include <gui/view_dispatcher.h>
  7. #include <gui/scene_manager.h>
  8. #if __has_include(<assets_icons.h>)
  9. #include <assets_icons.h>
  10. #else
  11. extern const Icon I_RFIDDolphinReceive_97x61;
  12. #endif
  13. #include <gui/modules/submenu.h>
  14. #include <gui/modules/popup.h>
  15. #include <gui/modules/loading.h>
  16. #include <gui/modules/text_input.h>
  17. #include <gui/modules/text_box.h>
  18. #include <gui/modules/widget.h>
  19. #include <gui/modules/byte_input.h>
  20. #include <gui/modules/popup.h>
  21. #include "scenes/metroflip_scene.h"
  22. #include <lib/flipper_format/flipper_format.h>
  23. #include <toolbox/name_generator.h>
  24. #include <lib/nfc/protocols/mf_ultralight/mf_ultralight.h>
  25. #include <lib/nfc/helpers/nfc_data_generator.h>
  26. #include <furi_hal_bt.h>
  27. #include <notification/notification_messages.h>
  28. #include <lib/nfc/nfc.h>
  29. #include <nfc/nfc_poller.h>
  30. #include <nfc/nfc_scanner.h>
  31. #include <flipper_application/flipper_application.h>
  32. #include <loader/firmware_api/firmware_api.h>
  33. #include "scenes/metroflip_scene.h"
  34. typedef struct {
  35. Gui* gui;
  36. SceneManager* scene_manager;
  37. ViewDispatcher* view_dispatcher;
  38. NotificationApp* notifications;
  39. Submenu* submenu;
  40. TextInput* text_input;
  41. TextBox* text_box;
  42. ByteInput* byte_input;
  43. Popup* popup;
  44. uint8_t mac_buf[GAP_MAC_ADDR_SIZE];
  45. FuriString* text_box_store;
  46. Widget* widget;
  47. Nfc* nfc;
  48. NfcPoller* poller;
  49. NfcScanner* scanner;
  50. NfcDevice* nfc_device;
  51. // card details:
  52. uint32_t balance_lari;
  53. uint8_t balance_tetri;
  54. uint32_t card_number;
  55. size_t sec_num;
  56. float value;
  57. char currency[4];
  58. char card_type[32];
  59. } Metroflip;
  60. enum MetroflipCustomEvent {
  61. // Reserve first 100 events for button types and indexes, starting from 0
  62. MetroflipCustomEventReserved = 100,
  63. MetroflipCustomEventViewExit,
  64. MetroflipCustomEventByteInputDone,
  65. MetroflipCustomEventTextInputDone,
  66. MetroflipCustomEventWorkerExit,
  67. MetroflipCustomEventPollerDetect,
  68. MetroflipCustomEventPollerSuccess,
  69. MetroflipCustomEventPollerFail,
  70. MetroflipCustomEventPollerSelectFailed,
  71. MetroflipCustomEventPollerFileNotFound,
  72. MetroflipCustomEventCardLost,
  73. MetroflipCustomEventCardDetected,
  74. MetroflipCustomEventWrongCard
  75. };
  76. typedef enum {
  77. MetroflipPollerEventTypeStart,
  78. MetroflipPollerEventTypeCardDetect,
  79. MetroflipPollerEventTypeSuccess,
  80. MetroflipPollerEventTypeFail,
  81. } MetroflipPollerEventType;
  82. typedef enum {
  83. MetroflipViewSubmenu,
  84. MetroflipViewTextInput,
  85. MetroflipViewByteInput,
  86. MetroflipViewPopup,
  87. MetroflipViewMenu,
  88. MetroflipViewLoading,
  89. MetroflipViewTextBox,
  90. MetroflipViewWidget,
  91. MetroflipViewUart,
  92. } MetroflipView;
  93. void metroflip_app_blink_start(Metroflip* metroflip);
  94. void metroflip_app_blink_stop(Metroflip* metroflip);
  95. #ifdef FW_ORIGIN_Official
  96. #define submenu_add_lockable_item( \
  97. submenu, label, index, callback, callback_context, locked, locked_message) \
  98. if(!(locked)) submenu_add_item(submenu, label, index, callback, callback_context)
  99. #endif