MenuFunctions.h 5.4 KB

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