Display.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. //void addNodes(Menu* menu, String name, Menu* child, std::function<void()> callable);
  60. //void changeMenu(Menu* menu);
  61. //void showMenuList(Menu* menu, int layer);
  62. //static void lv_tick_handler();
  63. public:
  64. Display();
  65. //Ticker tick;
  66. TFT_eSPI tft = TFT_eSPI();
  67. TFT_eSprite img = TFT_eSprite(&tft);
  68. TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
  69. const String PROGMEM version_number = MARAUDER_VERSION;
  70. bool printing = false;
  71. bool loading = false;
  72. bool tteBar = false;
  73. bool draw_tft = false;
  74. bool exit_draw = false;
  75. int TOP_FIXED_AREA_2 = 48;
  76. int print_delay_1, print_delay_2 = 10;
  77. int current_banner_pos = SCREEN_WIDTH;
  78. //Menu* current_menu;
  79. //Menu mainMenu;
  80. //Menu wifiMenu;
  81. //Menu bluetoothMenu;
  82. LinkedList<String>* display_buffer;
  83. // The initial y coordinate of the top of the bottom text line
  84. uint16_t yDraw = YMAX - BOT_FIXED_AREA - TEXT_HEIGHT;
  85. // Keep track of the drawing x coordinate
  86. uint16_t xPos = 0;
  87. // The initial y coordinate of the top of the scrolling area
  88. uint16_t yStart = TOP_FIXED_AREA_2;
  89. // yArea must be a integral multiple of TEXT_HEIGHT
  90. uint16_t yArea = YMAX - TOP_FIXED_AREA_2 - BOT_FIXED_AREA;
  91. // We have to blank the top line each time the display is scrolled, but this takes up to 13 milliseconds
  92. // for a full width line, meanwhile the serial buffer may be filling... and overflowing
  93. // We can speed up scrolling of short text lines by just blanking the character we drew
  94. int blank[19]; // We keep all the strings pixel lengths to optimise the speed of the top line blanking
  95. //void initLVGL();
  96. //void deinitLVGL();
  97. //void joinWiFiGFX();
  98. void tftDrawRedOnOffButton();
  99. void tftDrawGreenOnOffButton();
  100. void tftDrawGraphObjects(byte x_scale);
  101. void tftDrawEapolColorKey();
  102. void tftDrawColorKey();
  103. void tftDrawXScaleButtons(byte x_scale);
  104. void tftDrawYScaleButtons(byte y_scale);
  105. void tftDrawChannelScaleButtons(int set_channel);
  106. void tftDrawExitScaleButtons();
  107. void buildBanner(String msg, int xpos);
  108. void clearScreen();
  109. void displayBuffer(bool do_clear = false);
  110. void drawJpeg(const char *filename, int xpos, int ypos);
  111. void setupDraw();
  112. void drawStylus();
  113. void getTouchWhileFunction(bool pressed);
  114. void initScrollValues(bool tte = false);
  115. void jpegInfo();
  116. void jpegRender(int xpos, int ypos);
  117. void listDir(fs::FS &fs, const char * dirname, uint8_t levels);
  118. void listFiles();
  119. void main(uint8_t scan_mode);
  120. void RunSetup();
  121. void scrollAddress(uint16_t vsp);
  122. int scroll_line(uint32_t color);
  123. void setupScrollArea(uint16_t tfa, uint16_t bfa);
  124. void showCenterText(String text, int y);
  125. void touchToExit();
  126. void twoPartDisplay(String center_text);
  127. void updateBanner(String msg);
  128. };
  129. #endif
  130. #endif