MenuFunctions.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. PROGMEM static void add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
  70. // lvgl stuff
  71. PROGMEM static lv_obj_t *kb;
  72. struct Menu;
  73. // Individual Nodes of a menu
  74. struct MenuNode {
  75. String name;
  76. uint16_t color;
  77. int icon;
  78. TFT_eSPI_Button* button;
  79. std::function<void()> callable;
  80. };
  81. // Full Menus
  82. struct Menu {
  83. String name;
  84. LinkedList<MenuNode>* list;
  85. Menu * parentMenu;
  86. //uint8_t selected;
  87. };
  88. class MenuFunctions
  89. {
  90. private:
  91. String u_result = "";
  92. uint32_t initTime = 0;
  93. Menu* current_menu;
  94. // Main menu stuff
  95. Menu mainMenu;
  96. Menu wifiMenu;
  97. Menu bluetoothMenu;
  98. Menu generalMenu;
  99. Menu deviceMenu;
  100. // Device menu stuff
  101. Menu whichUpdateMenu;
  102. Menu failedUpdateMenu;
  103. Menu confirmMenu;
  104. Menu updateMenu;
  105. Menu infoMenu;
  106. // WiFi menu stuff
  107. Menu wifiSnifferMenu;
  108. Menu wifiScannerMenu;
  109. Menu wifiAttackMenu;
  110. Menu wifiGeneralMenu;
  111. // Bluetooth menu stuff
  112. Menu bluetoothSnifferMenu;
  113. Menu bluetoothScannerMenu;
  114. Menu bluetoothGeneralMenu;
  115. // Settings things menus
  116. Menu shutdownWiFiMenu;
  117. Menu shutdownBLEMenu;
  118. Menu generateSSIDsMenu;
  119. Menu clearSSIDsMenu;
  120. static void lv_tick_handler();
  121. // Menu icons
  122. //TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
  123. void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable);
  124. void drawStatusBar();
  125. void updateStatusBar();
  126. void battery(bool initial = false);
  127. void battery2(bool initial = false);
  128. void showMenuList(Menu* menu, int layer);
  129. void orientDisplay();
  130. public:
  131. MenuFunctions();
  132. Ticker tick;
  133. uint16_t x = -1, y = -1;
  134. boolean pressed = false;
  135. void initLVGL();
  136. void deinitLVGL();
  137. void joinWiFiGFX();
  138. void addSSIDGFX();
  139. void buildButtons(Menu* menu);
  140. void changeMenu(Menu* menu);
  141. void displayCurrentMenu();
  142. void main(uint32_t currentTime);
  143. void RunSetup();
  144. };
  145. #endif