GxEPD2_it103_1872x1404.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // Display Library for SPI e-paper panels from Dalian Good Display and boards from Waveshare.
  2. // Requires HW SPI and Adafruit_GFX. Caution: these e-papers require 3.3V supply AND data lines!
  3. //
  4. // GxEPD2_it103_1872x1404 class is based on Demo Example from Waveshare for Raspberry PI https://github.com/waveshare/IT8951/archive/master.zip
  5. // Controller: IT8951 : https://www.waveshare.com/w/upload/1/18/IT8951_D_V0.2.4.3_20170728.pdf
  6. //
  7. // The GxEPD2_it103_1872x1404 driver class supports the Waveshare e-Paper IT8951 Driver HAT connected with SPI for the ES103TC1 10.3" e-paper panel (parallel IF)
  8. // https://www.waveshare.com/product/displays/e-paper/epaper-1/10.3inch-e-paper-d.htm
  9. // This Driver HAT requires 5V power supply but works with 3.3V data lines; requires both MOSI and MISO SPI lines.
  10. //
  11. // Author: Jean-Marc Zingg
  12. //
  13. // Version: see library.properties
  14. //
  15. // Library: https://github.com/ZinggJM/GxEPD2
  16. #ifndef _GxEPD2_it103_1872x1404_H_
  17. #define _GxEPD2_it103_1872x1404_H_
  18. #include "../GxEPD2_EPD.h"
  19. class GxEPD2_it103_1872x1404 : public GxEPD2_EPD
  20. {
  21. public:
  22. // attributes
  23. static const uint16_t WIDTH = 1872;
  24. static const uint16_t WIDTH_VISIBLE = WIDTH;
  25. static const uint16_t HEIGHT = 1404;
  26. static const GxEPD2::Panel panel = GxEPD2::ES103TC1;
  27. static const bool hasColor = false;
  28. static const bool hasPartialUpdate = true;
  29. static const bool hasFastPartialUpdate = true;
  30. static const uint16_t reset_to_ready_time = 1800; // ms, e.g. 1729001us
  31. static const uint16_t power_on_time = 10; // ms, e.g. 3001us
  32. static const uint16_t power_off_time = 250; // ms, e.g. 214001us
  33. static const uint16_t full_refresh_time = 850; // ms, e.g. 827000us
  34. static const uint16_t partial_refresh_time = 300; // ms, e.g. 284000us
  35. static const uint16_t refresh_cmd_time = 10; // ms, e.g. 6052us
  36. static const uint16_t refresh_par_time = 2; // ms, e.g. 1921us
  37. static const uint16_t default_wait_time = 1; // ms, default busy check, needed?
  38. static const uint16_t diag_min_time = 3; // ms, e.g. > refresh_par_time
  39. static const uint16_t set_vcom_time = 500; // ms, e.g. 454967us
  40. // constructor
  41. GxEPD2_it103_1872x1404(int16_t cs, int16_t dc, int16_t rst, int16_t busy);
  42. // methods (virtual)
  43. void init(uint32_t serial_diag_bitrate = 0); // serial_diag_bitrate = 0 : disabled
  44. void init(uint32_t serial_diag_bitrate, bool initial, uint16_t reset_duration = 20, bool pulldown_rst_mode = false);
  45. // Support for Bitmaps (Sprites) to Controller Buffer and to Screen
  46. void clearScreen(uint8_t value = 0x33); // init controller memory and screen (default white)
  47. void writeScreenBuffer(uint8_t value = 0x33); // init controller memory (default white)
  48. // write to controller memory, without screen refresh; x and w should be multiple of 8
  49. void writeImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  50. void writeImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  51. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  52. void writeImage(const uint8_t* black, const uint8_t* color, int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  53. void writeImagePart(const uint8_t* black, const uint8_t* color, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  54. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  55. // write sprite of native data to controller memory, without screen refresh; x and w should be multiple of 8
  56. void writeNative(const uint8_t* data1, const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  57. // write to controller memory, with screen refresh; x and w should be multiple of 8
  58. void drawImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  59. void drawImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  60. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  61. void drawImage(const uint8_t* black, const uint8_t* color, int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  62. void drawImagePart(const uint8_t* black, const uint8_t* color, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  63. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  64. // write sprite of native data to controller memory, with screen refresh; x and w should be multiple of 8
  65. void drawNative(const uint8_t* data1, const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  66. void refresh(bool partial_update_mode = false); // screen refresh from controller memory to full screen
  67. void refresh(int16_t x, int16_t y, int16_t w, int16_t h); // screen refresh from controller memory, partial screen
  68. void powerOff(); // turns off generation of panel driving voltages, avoids screen fading over time
  69. void hibernate(); // turns powerOff() and sets controller to deep sleep for minimum power use, ONLY if wakeable by RST (rst >= 0)
  70. private:
  71. struct IT8951DevInfoStruct
  72. {
  73. uint16_t usPanelW;
  74. uint16_t usPanelH;
  75. uint16_t usImgBufAddrL;
  76. uint16_t usImgBufAddrH;
  77. uint16_t usFWVersion[8]; //16 Bytes String
  78. uint16_t usLUTVersion[8]; //16 Bytes String
  79. };
  80. IT8951DevInfoStruct IT8951DevInfo;
  81. SPISettings _spi_settings;
  82. SPISettings _spi_settings_for_read;
  83. private:
  84. void _writeScreenBuffer(uint8_t value);
  85. void _refresh(int16_t x, int16_t y, int16_t w, int16_t h, bool partial_update_mode);
  86. void _send8pixel(uint8_t data);
  87. void _setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
  88. void _PowerOn();
  89. void _PowerOff();
  90. void _InitDisplay();
  91. void _Init_Full();
  92. void _Init_Part();
  93. // IT8951
  94. void _waitWhileBusy2(const char* comment = 0, uint16_t busy_time = 5000);
  95. uint16_t _transfer16(uint16_t value);
  96. void _writeCommand16(uint16_t c);
  97. void _writeData16(uint16_t d);
  98. void _writeData16(const uint16_t* d, uint32_t n);
  99. uint16_t _readData16();
  100. void _readData16(uint16_t* d, uint32_t n);
  101. void _writeCommandData16(uint16_t c, const uint16_t* d, uint16_t n);
  102. void _IT8951SystemRun();
  103. void _IT8951StandBy();
  104. void _IT8951Sleep();
  105. uint16_t _IT8951ReadReg(uint16_t usRegAddr);
  106. void _IT8951WriteReg(uint16_t usRegAddr, uint16_t usValue);
  107. uint16_t _IT8951GetVCOM(void);
  108. void _IT8951SetVCOM(uint16_t vcom);
  109. };
  110. #endif