MenuFunctions.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. #ifndef MenuFunctions_h
  2. #define MenuFunctions_h
  3. #define BATTERY_ANALOG_ON 0
  4. #include "WiFiScan.h"
  5. #include "Display.h"
  6. #include "BatteryInterface.h"
  7. #include "SDInterface.h"
  8. #include "Web.h"
  9. #include "esp_interface.h"
  10. #include "a32u4_interface.h"
  11. #include "settings.h"
  12. #include "configs.h"
  13. #ifdef MARAUDER_MINI
  14. #include <SwitchLib.h>
  15. extern SwitchLib u_btn;
  16. extern SwitchLib d_btn;
  17. extern SwitchLib l_btn;
  18. extern SwitchLib r_btn;
  19. extern SwitchLib c_btn;
  20. #endif
  21. extern Display display_obj;
  22. extern WiFiScan wifi_scan_obj;
  23. extern Web web_obj;
  24. extern SDInterface sd_obj;
  25. extern BatteryInterface battery_obj;
  26. extern EspInterface esp_obj;
  27. extern A32u4Interface a32u4_obj;
  28. extern Settings settings_obj;
  29. #define FLASH_BUTTON 0
  30. #if BATTERY_ANALOG_ON == 1
  31. #define BATTERY_PIN 13
  32. #define ANALOG_PIN 34
  33. #define CHARGING_PIN 27
  34. #endif
  35. // Icon definitions
  36. #define ATTACKS 0
  37. #define BEACON_SNIFF 1
  38. #define BLUETOOTH 2
  39. #define BLUETOOTH_SNIFF 3
  40. #define DEAUTH_SNIFF 4
  41. #define DRAW 5
  42. #define PACKET_MONITOR 6
  43. #define PROBE_SNIFF 7
  44. #define SCANNERS 8
  45. #define CC_SKIMMERS 9
  46. #define SNIFFERS 10
  47. #define WIFI 11
  48. #define BEACON_SPAM 12
  49. #define RICK_ROLL 13
  50. #define REBOOT 14
  51. #define GENERAL_APPS 15
  52. #define UPDATE 16
  53. #define DEVICE 17
  54. #define DEVICE_INFO 18
  55. #define SD_UPDATE 19
  56. #define WEB_UPDATE 20
  57. #define EAPOL 21
  58. #define STATUS_BAT 22
  59. #define STATUS_SD 23
  60. #define PWNAGOTCHI 24
  61. #define ESPRESSIF 25
  62. #define SHUTDOWN 26
  63. #define BEACON_LIST 27
  64. #define GENERATE 28
  65. #define CLEAR_ICO 29
  66. #define KEYBOARD_ICO 30
  67. #define JOIN_WIFI 31
  68. #define ESP_UPDATE_ICO 32
  69. #define BAD_USB_ICO 33
  70. #define TEST_BAD_USB_ICO 34
  71. PROGMEM void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p);
  72. PROGMEM bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data);
  73. PROGMEM static lv_disp_buf_t disp_buf;
  74. PROGMEM static lv_color_t buf[LV_HOR_RES_MAX * 10];
  75. PROGMEM static void ta_event_cb(lv_obj_t * ta, lv_event_t event);
  76. PROGMEM static void join_wifi_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
  77. PROGMEM static void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
  78. PROGMEM static void write_bad_usb_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
  79. PROGMEM static void load_btn_cb(lv_obj_t * load_btn, lv_event_t event);
  80. PROGMEM static void test_btn_cb(lv_obj_t * load_btn, lv_event_t event);
  81. PROGMEM static void ap_list_cb(lv_obj_t * btn, lv_event_t event);
  82. PROGMEM static void setting_dropdown_cb(lv_obj_t * btn, lv_event_t event);
  83. PROGMEM static void save_as_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
  84. // lvgl stuff
  85. PROGMEM static lv_obj_t *kb;
  86. PROGMEM static lv_obj_t * save_as_kb;
  87. struct Menu;
  88. // Individual Nodes of a menu
  89. struct MenuNode {
  90. String name;
  91. String command;
  92. uint16_t color;
  93. int icon;
  94. TFT_eSPI_Button* button;
  95. bool selected;
  96. std::function<void()> callable;
  97. };
  98. // Full Menus
  99. struct Menu {
  100. String name;
  101. LinkedList<MenuNode>* list;
  102. Menu * parentMenu;
  103. uint8_t selected = 0;
  104. };
  105. class MenuFunctions
  106. {
  107. private:
  108. String u_result = "";
  109. uint32_t initTime = 0;
  110. //Menu* current_menu;
  111. // Main menu stuff
  112. Menu mainMenu;
  113. Menu wifiMenu;
  114. Menu bluetoothMenu;
  115. Menu badusbMenu;
  116. Menu generalMenu;
  117. Menu deviceMenu;
  118. // Device menu stuff
  119. Menu whichUpdateMenu;
  120. Menu failedUpdateMenu;
  121. Menu confirmMenu;
  122. Menu espUpdateMenu;
  123. Menu updateMenu;
  124. Menu settingsMenu;
  125. Menu specSettingMenu;
  126. Menu infoMenu;
  127. // WiFi menu stuff
  128. Menu wifiSnifferMenu;
  129. Menu wifiAttackMenu;
  130. Menu wifiGeneralMenu;
  131. // Bluetooth menu stuff
  132. Menu bluetoothSnifferMenu;
  133. Menu bluetoothGeneralMenu;
  134. // Settings things menus
  135. Menu shutdownWiFiMenu;
  136. Menu shutdownBLEMenu;
  137. Menu generateSSIDsMenu;
  138. Menu clearSSIDsMenu;
  139. Menu clearAPsMenu;
  140. static void lv_tick_handler();
  141. // Menu icons
  142. //TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
  143. void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable, bool selected = false, String command = "");
  144. void updateStatusBar();
  145. void battery(bool initial = false);
  146. void battery2(bool initial = false);
  147. void showMenuList(Menu* menu, int layer);
  148. String callSetting(String key);
  149. void runBoolSetting(String ley);
  150. void displaySetting(String key, Menu* menu, int index);
  151. void buttonSelected(uint8_t b);
  152. void buttonNotSelected(uint8_t b);
  153. public:
  154. MenuFunctions();
  155. Menu* current_menu;
  156. Ticker tick;
  157. uint16_t x = -1, y = -1;
  158. boolean pressed = false;
  159. String loaded_file = "";
  160. void initLVGL();
  161. void deinitLVGL();
  162. void joinWiFiGFX();
  163. void addSSIDGFX();
  164. void addAPGFX();
  165. void displaySettingsGFX();
  166. void writeBadUSB();
  167. void buildButtons(Menu* menu);
  168. void changeMenu(Menu* menu);
  169. void drawStatusBar();
  170. void displayCurrentMenu();
  171. void main(uint32_t currentTime);
  172. void RunSetup();
  173. void orientDisplay();
  174. };
  175. #endif