MenuFunctions.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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 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. uint16_t color;
  94. int icon;
  95. TFT_eSPI_Button* button;
  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;
  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 infoMenu;
  125. // WiFi menu stuff
  126. Menu wifiSnifferMenu;
  127. Menu wifiAttackMenu;
  128. Menu wifiGeneralMenu;
  129. // Bluetooth menu stuff
  130. Menu bluetoothSnifferMenu;
  131. Menu bluetoothGeneralMenu;
  132. // Settings things menus
  133. Menu shutdownWiFiMenu;
  134. Menu shutdownBLEMenu;
  135. Menu generateSSIDsMenu;
  136. Menu clearSSIDsMenu;
  137. Menu clearAPsMenu;
  138. static void lv_tick_handler();
  139. // Menu icons
  140. //TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
  141. void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable);
  142. void drawStatusBar();
  143. void updateStatusBar();
  144. void battery(bool initial = false);
  145. void battery2(bool initial = false);
  146. void showMenuList(Menu* menu, int layer);
  147. public:
  148. MenuFunctions();
  149. Menu* current_menu;
  150. Ticker tick;
  151. uint16_t x = -1, y = -1;
  152. boolean pressed = false;
  153. String loaded_file = "";
  154. void initLVGL();
  155. void deinitLVGL();
  156. void joinWiFiGFX();
  157. void addSSIDGFX();
  158. void addAPGFX();
  159. void displaySettingsGFX();
  160. void writeBadUSB();
  161. void buildButtons(Menu* menu);
  162. void changeMenu(Menu* menu);
  163. void displayCurrentMenu();
  164. void main(uint32_t currentTime);
  165. void RunSetup();
  166. void orientDisplay();
  167. };
  168. #endif