MenuFunctions.h 4.9 KB

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