MenuFunctions.h 3.7 KB

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