MenuFunctions.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. #ifndef MenuFunctions_h
  2. #define MenuFunctions_h
  3. #include "configs.h"
  4. #ifdef HAS_SCREEN
  5. #define BATTERY_ANALOG_ON 0
  6. #include "WiFiScan.h"
  7. #include "BatteryInterface.h"
  8. #include "SDInterface.h"
  9. #include "settings.h"
  10. #ifdef HAS_BUTTONS
  11. #include <SwitchLib.h>
  12. extern SwitchLib u_btn;
  13. extern SwitchLib d_btn;
  14. extern SwitchLib l_btn;
  15. extern SwitchLib r_btn;
  16. extern SwitchLib c_btn;
  17. #endif
  18. extern WiFiScan wifi_scan_obj;
  19. extern SDInterface sd_obj;
  20. extern BatteryInterface battery_obj;
  21. extern Settings settings_obj;
  22. #define FLASH_BUTTON 0
  23. #if BATTERY_ANALOG_ON == 1
  24. #define BATTERY_PIN 13
  25. #define ANALOG_PIN 34
  26. #define CHARGING_PIN 27
  27. #endif
  28. // Icon definitions
  29. #define ATTACKS 0
  30. #define BEACON_SNIFF 1
  31. #define BLUETOOTH 2
  32. #define BLUETOOTH_SNIFF 3
  33. #define DEAUTH_SNIFF 4
  34. #define DRAW 5
  35. #define PACKET_MONITOR 6
  36. #define PROBE_SNIFF 7
  37. #define SCANNERS 8
  38. #define CC_SKIMMERS 9
  39. #define SNIFFERS 10
  40. #define WIFI 11
  41. #define BEACON_SPAM 12
  42. #define RICK_ROLL 13
  43. #define REBOOT 14
  44. #define GENERAL_APPS 15
  45. #define UPDATE 16
  46. #define DEVICE 17
  47. #define DEVICE_INFO 18
  48. #define SD_UPDATE 19
  49. #define WEB_UPDATE 20
  50. #define EAPOL 21
  51. #define STATUS_BAT 22
  52. #define STATUS_SD 23
  53. #define PWNAGOTCHI 24
  54. #define SHUTDOWN 25
  55. #define BEACON_LIST 26
  56. #define GENERATE 27
  57. #define CLEAR_ICO 28
  58. #define KEYBOARD_ICO 29
  59. #define JOIN_WIFI 30
  60. #define LANGUAGE 31
  61. #define STATUS_GPS 32
  62. #define GPS_MENU 33
  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 add_ssid_keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
  69. PROGMEM static void ap_list_cb(lv_obj_t * btn, lv_event_t event);
  70. PROGMEM static void station_list_cb(lv_obj_t * btn, lv_event_t event);
  71. PROGMEM static void setting_dropdown_cb(lv_obj_t * btn, lv_event_t event);
  72. // lvgl stuff
  73. PROGMEM static lv_obj_t *kb;
  74. PROGMEM static lv_obj_t * save_as_kb;
  75. struct Menu;
  76. // Individual Nodes of a menu
  77. struct MenuNode {
  78. String name;
  79. bool command;
  80. uint16_t color;
  81. uint8_t icon;
  82. TFT_eSPI_Button* button;
  83. bool selected;
  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 = 0;
  92. };
  93. class MenuFunctions
  94. {
  95. private:
  96. String u_result = "";
  97. uint32_t initTime = 0;
  98. // Main menu stuff
  99. Menu mainMenu;
  100. Menu wifiMenu;
  101. Menu bluetoothMenu;
  102. Menu badusbMenu;
  103. Menu deviceMenu;
  104. // Device menu stuff
  105. Menu whichUpdateMenu;
  106. Menu failedUpdateMenu;
  107. Menu confirmMenu;
  108. Menu updateMenu;
  109. Menu settingsMenu;
  110. Menu specSettingMenu;
  111. Menu infoMenu;
  112. Menu languageMenu;
  113. // WiFi menu stuff
  114. Menu wifiSnifferMenu;
  115. Menu wifiAttackMenu;
  116. Menu wifiGeneralMenu;
  117. Menu wifiAPMenu;
  118. // Bluetooth menu stuff
  119. Menu bluetoothSnifferMenu;
  120. // Settings things menus
  121. Menu generateSSIDsMenu;
  122. static void lv_tick_handler();
  123. // Menu icons
  124. void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable, bool selected = false, String command = "");
  125. void updateStatusBar();
  126. void battery(bool initial = false);
  127. void battery2(bool initial = false);
  128. void showMenuList(Menu* menu, int layer);
  129. String callSetting(String key);
  130. void runBoolSetting(String ley);
  131. void displaySetting(String key, Menu* menu, int index);
  132. void buttonSelected(uint8_t b);
  133. void buttonNotSelected(uint8_t b);
  134. public:
  135. MenuFunctions();
  136. Menu* current_menu;
  137. Menu clearSSIDsMenu;
  138. Menu clearAPsMenu;
  139. #ifdef HAS_GPS
  140. // GPS Menu
  141. Menu gpsInfoMenu;
  142. #endif
  143. Ticker tick;
  144. uint16_t x = -1, y = -1;
  145. boolean pressed = false;
  146. String loaded_file = "";
  147. void initLVGL();
  148. void deinitLVGL();
  149. void addSSIDGFX();
  150. void addAPGFX();
  151. void addStationGFX();
  152. void buildButtons(Menu* menu, int starting_index = 0);
  153. void changeMenu(Menu* menu);
  154. void drawStatusBar();
  155. void displayCurrentMenu();
  156. void main(uint32_t currentTime);
  157. void RunSetup();
  158. void orientDisplay();
  159. };
  160. #endif
  161. #endif