MenuFunctions.h 4.0 KB

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