MenuFunctions.h 5.2 KB

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