MenuFunctions.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. extern Display display_obj;
  12. extern WiFiScan wifi_scan_obj;
  13. extern Web web_obj;
  14. extern SDInterface sd_obj;
  15. extern BatteryInterface battery_obj;
  16. extern EspInterface esp_obj;
  17. extern A32u4Interface a32u4_obj;
  18. // Keypad start position, key sizes and spacing
  19. #define KEY_X 120 // Centre of key
  20. #define KEY_Y 50
  21. #define KEY_W 240 // Width and height
  22. #define KEY_H 22
  23. #define KEY_SPACING_X 0 // X and Y gap
  24. #define KEY_SPACING_Y 1
  25. #define KEY_TEXTSIZE 1 // Font size multiplier
  26. #define ICON_W 22
  27. #define ICON_H 22
  28. #define BUTTON_PADDING 22
  29. //#define BUTTON_ARRAY_LEN 5
  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. PROGMEM void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p);
  73. PROGMEM bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data);
  74. PROGMEM static lv_disp_buf_t disp_buf;
  75. PROGMEM static lv_color_t buf[LV_HOR_RES_MAX * 10];
  76. PROGMEM static void ta_event_cb(lv_obj_t * ta, lv_event_t event);
  77. PROGMEM static void join_wifi_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
  78. PROGMEM static void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
  79. PROGMEM static void write_bad_usb_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
  80. PROGMEM static void load_btn_cb(lv_obj_t * load_btn, lv_event_t event);
  81. PROGMEM static void test_btn_cb(lv_obj_t * load_btn, lv_event_t event);
  82. PROGMEM static void ap_list_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. uint16_t color;
  92. int icon;
  93. TFT_eSPI_Button* button;
  94. std::function<void()> callable;
  95. };
  96. // Full Menus
  97. struct Menu {
  98. String name;
  99. LinkedList<MenuNode>* list;
  100. Menu * parentMenu;
  101. //uint8_t selected;
  102. };
  103. class MenuFunctions
  104. {
  105. private:
  106. String u_result = "";
  107. uint32_t initTime = 0;
  108. //Menu* current_menu;
  109. // Main menu stuff
  110. Menu mainMenu;
  111. Menu wifiMenu;
  112. Menu bluetoothMenu;
  113. Menu badusbMenu;
  114. Menu generalMenu;
  115. Menu deviceMenu;
  116. // Device menu stuff
  117. Menu whichUpdateMenu;
  118. Menu failedUpdateMenu;
  119. Menu confirmMenu;
  120. Menu espUpdateMenu;
  121. Menu updateMenu;
  122. Menu infoMenu;
  123. // WiFi menu stuff
  124. Menu wifiSnifferMenu;
  125. Menu wifiAttackMenu;
  126. Menu wifiGeneralMenu;
  127. // Bluetooth menu stuff
  128. Menu bluetoothSnifferMenu;
  129. Menu bluetoothGeneralMenu;
  130. // Settings things menus
  131. Menu shutdownWiFiMenu;
  132. Menu shutdownBLEMenu;
  133. Menu generateSSIDsMenu;
  134. Menu clearSSIDsMenu;
  135. Menu clearAPsMenu;
  136. static void lv_tick_handler();
  137. // Menu icons
  138. //TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
  139. void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable);
  140. void drawStatusBar();
  141. void updateStatusBar();
  142. void battery(bool initial = false);
  143. void battery2(bool initial = false);
  144. void showMenuList(Menu* menu, int layer);
  145. public:
  146. MenuFunctions();
  147. Menu* current_menu;
  148. Ticker tick;
  149. uint16_t x = -1, y = -1;
  150. boolean pressed = false;
  151. String loaded_file = "";
  152. void initLVGL();
  153. void deinitLVGL();
  154. void joinWiFiGFX();
  155. void addSSIDGFX();
  156. void addAPGFX();
  157. void writeBadUSB();
  158. void buildButtons(Menu* menu);
  159. void changeMenu(Menu* menu);
  160. void displayCurrentMenu();
  161. void main(uint32_t currentTime);
  162. void RunSetup();
  163. void orientDisplay();
  164. };
  165. #endif