Display.h 4.5 KB

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