MenuFunctions.h 3.6 KB

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