MenuFunctions.h 3.5 KB

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