Display.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 <LinkedList.h>
  9. #include <SPI.h>
  10. #include <lvgl.h>
  11. #include <Ticker.h>
  12. #include "SPIFFS.h"
  13. #include "Assets.h"
  14. #include <TFT_eSPI.h>
  15. // WiFi stuff
  16. #define OTA_UPDATE 100
  17. #define SHOW_INFO 101
  18. #define WIFI_SCAN_OFF 0
  19. #define WIFI_SCAN_PROBE 1
  20. #define WIFI_SCAN_AP 2
  21. #define WIFI_SCAN_PWN 3
  22. #define WIFI_SCAN_EAPOL 4
  23. #define WIFI_SCAN_DEAUTH 5
  24. #define WIFI_SCAN_ALL 6
  25. #define WIFI_PACKET_MONITOR 7
  26. #define WIFI_ATTACK_BEACON_SPAM 8
  27. #define WIFI_ATTACK_RICK_ROLL 9
  28. #define BT_SCAN_ALL 10
  29. #define BT_SCAN_SKIMMERS 11
  30. #define WIFI_SCAN_ESPRESSIF 12
  31. #define LV_JOIN_WIFI 13
  32. #define LV_ADD_SSID 14
  33. #define WIFI_ATTACK_BEACON_LIST 15
  34. class Display
  35. {
  36. private:
  37. bool SwitchOn = false;
  38. bool run_setup = true;
  39. // For the byte we read from the serial port
  40. byte data = 0;
  41. // A few test variables used during debugging
  42. boolean change_colour = 1;
  43. boolean selected = 1;
  44. void drawFrame();
  45. #ifdef SCREEN_BUFFER
  46. void scrollScreenBuffer(bool down = false);
  47. #endif
  48. public:
  49. Display();
  50. TFT_eSPI tft = TFT_eSPI();
  51. TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
  52. const String PROGMEM version_number = MARAUDER_VERSION;
  53. bool printing = false;
  54. bool loading = false;
  55. bool tteBar = false;
  56. bool draw_tft = false;
  57. bool exit_draw = false;
  58. uint8_t TOP_FIXED_AREA_2 = 48;
  59. uint8_t print_delay_1, print_delay_2 = 10;
  60. uint8_t current_banner_pos = SCREEN_WIDTH;
  61. LinkedList<String>* display_buffer;
  62. #ifdef SCREEN_BUFFER
  63. LinkedList<String>* screen_buffer;
  64. #endif
  65. // The initial y coordinate of the top of the bottom text line
  66. uint16_t yDraw = YMAX - BOT_FIXED_AREA - TEXT_HEIGHT;
  67. // Keep track of the drawing x coordinate
  68. uint16_t xPos = 0;
  69. // The initial y coordinate of the top of the scrolling area
  70. uint16_t yStart = TOP_FIXED_AREA_2;
  71. // yArea must be a integral multiple of TEXT_HEIGHT
  72. uint16_t yArea = YMAX - TOP_FIXED_AREA_2 - BOT_FIXED_AREA;
  73. // We have to blank the top line each time the display is scrolled, but this takes up to 13 milliseconds
  74. // for a full width line, meanwhile the serial buffer may be filling... and overflowing
  75. // We can speed up scrolling of short text lines by just blanking the character we drew
  76. int blank[19]; // We keep all the strings pixel lengths to optimise the speed of the top line blanking
  77. void tftDrawRedOnOffButton();
  78. void tftDrawGreenOnOffButton();
  79. void tftDrawGraphObjects(byte x_scale);
  80. void tftDrawEapolColorKey();
  81. void tftDrawColorKey();
  82. void tftDrawXScaleButtons(byte x_scale);
  83. void tftDrawYScaleButtons(byte y_scale);
  84. void tftDrawChannelScaleButtons(int set_channel);
  85. void tftDrawExitScaleButtons();
  86. void buildBanner(String msg, int xpos);
  87. void clearScreen();
  88. void displayBuffer(bool do_clear = false);
  89. void drawJpeg(const char *filename, int xpos, int ypos);
  90. void getTouchWhileFunction(bool pressed);
  91. void initScrollValues(bool tte = false);
  92. void jpegInfo();
  93. void jpegRender(int xpos, int ypos);
  94. void listDir(fs::FS &fs, const char * dirname, uint8_t levels);
  95. void listFiles();
  96. void main(uint8_t scan_mode);
  97. void RunSetup();
  98. void scrollAddress(uint16_t vsp);
  99. int scroll_line(uint32_t color);
  100. void setupScrollArea(uint16_t tfa, uint16_t bfa);
  101. void showCenterText(String text, int y);
  102. void touchToExit();
  103. void twoPartDisplay(String center_text);
  104. void updateBanner(String msg);
  105. };
  106. #endif
  107. #endif