Display.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #ifndef Display_h
  2. #define Display_h
  3. #include "configs.h"
  4. #ifdef HAS_SCREEN
  5. #include <FS.h>
  6. #include <functional>
  7. #include <JPEGDecoder.h>
  8. //#include <SimpleList.h>
  9. #include <LinkedList.h>
  10. #include <SPI.h>
  11. #include <lvgl.h>
  12. #include <Ticker.h>
  13. //#include <M5Stack.h>
  14. #include "SPIFFS.h"
  15. #include "Assets.h"
  16. #include <TFT_eSPI.h>
  17. // WiFi stuff
  18. #define OTA_UPDATE 100
  19. #define SHOW_INFO 101
  20. #define WIFI_SCAN_OFF 0
  21. #define WIFI_SCAN_PROBE 1
  22. #define WIFI_SCAN_AP 2
  23. #define WIFI_SCAN_PWN 3
  24. #define WIFI_SCAN_EAPOL 4
  25. #define WIFI_SCAN_DEAUTH 5
  26. #define WIFI_SCAN_ALL 6
  27. #define WIFI_PACKET_MONITOR 7
  28. #define WIFI_ATTACK_BEACON_SPAM 8
  29. #define WIFI_ATTACK_RICK_ROLL 9
  30. #define BT_SCAN_ALL 10
  31. #define BT_SCAN_SKIMMERS 11
  32. #define WIFI_SCAN_ESPRESSIF 12
  33. #define LV_JOIN_WIFI 13
  34. #define LV_ADD_SSID 14
  35. #define WIFI_ATTACK_BEACON_LIST 15
  36. /*
  37. PROGMEM void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p);
  38. PROGMEM bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data);
  39. PROGMEM static lv_disp_buf_t disp_buf;
  40. PROGMEM static lv_color_t buf[LV_HOR_RES_MAX * 10];
  41. PROGMEM static void ta_event_cb(lv_obj_t * ta, lv_event_t event);
  42. PROGMEM static void keyboard_event_cb(lv_obj_t * keyboard, lv_event_t event);
  43. // lvgl stuff
  44. PROGMEM static lv_obj_t *kb;
  45. */
  46. // #define KIT
  47. // #define TFT_DIY
  48. class Display
  49. {
  50. private:
  51. bool SwitchOn = false;
  52. bool run_setup = true;
  53. // For the byte we read from the serial port
  54. byte data = 0;
  55. // A few test variables used during debugging
  56. boolean change_colour = 1;
  57. boolean selected = 1;
  58. void drawFrame();
  59. #ifdef SCREEN_BUFFER
  60. void scrollScreenBuffer(bool down = false);
  61. #endif
  62. //void addNodes(Menu* menu, String name, Menu* child, std::function<void()> callable);
  63. //void changeMenu(Menu* menu);
  64. //void showMenuList(Menu* menu, int layer);
  65. //static void lv_tick_handler();
  66. public:
  67. Display();
  68. //Ticker tick;
  69. TFT_eSPI tft = TFT_eSPI();
  70. TFT_eSprite img = TFT_eSprite(&tft);
  71. TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
  72. const String PROGMEM version_number = MARAUDER_VERSION;
  73. bool printing = false;
  74. bool loading = false;
  75. bool tteBar = false;
  76. bool draw_tft = false;
  77. bool exit_draw = false;
  78. int TOP_FIXED_AREA_2 = 48;
  79. int print_delay_1, print_delay_2 = 10;
  80. int current_banner_pos = SCREEN_WIDTH;
  81. //Menu* current_menu;
  82. //Menu mainMenu;
  83. //Menu wifiMenu;
  84. //Menu bluetoothMenu;
  85. LinkedList<String>* display_buffer;
  86. #ifdef SCREEN_BUFFER
  87. LinkedList<String>* screen_buffer;
  88. #endif
  89. // The initial y coordinate of the top of the bottom text line
  90. uint16_t yDraw = YMAX - BOT_FIXED_AREA - TEXT_HEIGHT;
  91. // Keep track of the drawing x coordinate
  92. uint16_t xPos = 0;
  93. // The initial y coordinate of the top of the scrolling area
  94. uint16_t yStart = TOP_FIXED_AREA_2;
  95. // yArea must be a integral multiple of TEXT_HEIGHT
  96. uint16_t yArea = YMAX - TOP_FIXED_AREA_2 - BOT_FIXED_AREA;
  97. // We have to blank the top line each time the display is scrolled, but this takes up to 13 milliseconds
  98. // for a full width line, meanwhile the serial buffer may be filling... and overflowing
  99. // We can speed up scrolling of short text lines by just blanking the character we drew
  100. int blank[19]; // We keep all the strings pixel lengths to optimise the speed of the top line blanking
  101. //void initLVGL();
  102. //void deinitLVGL();
  103. //void joinWiFiGFX();
  104. void tftDrawRedOnOffButton();
  105. void tftDrawGreenOnOffButton();
  106. void tftDrawGraphObjects(byte x_scale);
  107. void tftDrawEapolColorKey();
  108. void tftDrawColorKey();
  109. void tftDrawXScaleButtons(byte x_scale);
  110. void tftDrawYScaleButtons(byte y_scale);
  111. void tftDrawChannelScaleButtons(int set_channel);
  112. void tftDrawExitScaleButtons();
  113. void buildBanner(String msg, int xpos);
  114. void clearScreen();
  115. void displayBuffer(bool do_clear = false);
  116. void drawJpeg(const char *filename, int xpos, int ypos);
  117. void setupDraw();
  118. void drawStylus();
  119. void getTouchWhileFunction(bool pressed);
  120. void initScrollValues(bool tte = false);
  121. void jpegInfo();
  122. void jpegRender(int xpos, int ypos);
  123. void listDir(fs::FS &fs, const char * dirname, uint8_t levels);
  124. void listFiles();
  125. void main(uint8_t scan_mode);
  126. void RunSetup();
  127. void scrollAddress(uint16_t vsp);
  128. int scroll_line(uint32_t color);
  129. void setupScrollArea(uint16_t tfa, uint16_t bfa);
  130. void showCenterText(String text, int y);
  131. void touchToExit();
  132. void twoPartDisplay(String center_text);
  133. void updateBanner(String msg);
  134. };
  135. #endif
  136. #endif