GxEPD2_1085_GDEM1085T51.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // Display Library for SPI e-paper panels from Dalian Good Display and boards from Waveshare.
  2. // Requires HW SPI and Adafruit_GFX. Caution: the e-paper panels require 3.3V supply AND data lines!
  3. //
  4. // based on Demo Example from Good Display, available here: https://www.good-display.com/companyfile/32/
  5. // Panel: GDEM1085T51 : https://www.good-display.com/product/503.html
  6. // Controller : JD79686AB :
  7. //
  8. // Author: Jean-Marc Zingg
  9. //
  10. // Version: see library.properties
  11. //
  12. // Library: https://github.com/ZinggJM/GxEPD2
  13. #ifndef _GxEPD2_1085_GDEM1085T51_H_
  14. #define _GxEPD2_1085_GDEM1085T51_H_
  15. #include "../GxEPD2_EPD.h"
  16. class GxEPD2_1085_GDEM1085T51 : public GxEPD2_EPD
  17. {
  18. public:
  19. // attributes
  20. static const uint16_t WIDTH = 1360;
  21. static const uint16_t WIDTH_VISIBLE = WIDTH;
  22. static const uint16_t HEIGHT = 480;
  23. static const GxEPD2::Panel panel = GxEPD2::GDEM1085T51;
  24. static const bool hasColor = false;
  25. static const bool hasPartialUpdate = true;
  26. static const bool hasFastPartialUpdate = false; // not yet true
  27. static const uint16_t power_on_time = 150; // ms, e.g. 112998us
  28. static const uint16_t power_off_time = 100; // ms, e.g. 63000us
  29. static const uint16_t full_refresh_time = 3500; // ms, e.g. 3472000us
  30. static const uint16_t partial_refresh_time = 3500; // ms, e.g. 3465000us
  31. // constructor
  32. GxEPD2_1085_GDEM1085T51(int16_t cs, int16_t dc, int16_t rst, int16_t busy, int16_t cs2);
  33. // methods (virtual)
  34. virtual void init(uint32_t serial_diag_bitrate = 0); // serial_diag_bitrate = 0 : disabled
  35. virtual void init(uint32_t serial_diag_bitrate, bool initial, uint16_t reset_duration = 10, bool pulldown_rst_mode = false);
  36. // Support for Bitmaps (Sprites) to Controller Buffer and to Screen
  37. void clearScreen(uint8_t value = 0xFF); // init controller memory and screen (default white)
  38. void writeScreenBuffer(uint8_t value = 0xFF); // init controller memory (default white)
  39. void writeScreenBufferAgain(uint8_t value = 0xFF); // init previous buffer controller memory (default white)
  40. // write to controller memory, without screen refresh; x and w should be multiple of 8
  41. 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);
  42. void writeImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  43. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  44. 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);
  45. 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,
  46. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  47. // write sprite of native data to controller memory, without screen refresh; x and w should be multiple of 8
  48. 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);
  49. // write to controller memory, with screen refresh; x and w should be multiple of 8
  50. 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);
  51. void drawImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  52. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  53. //for differential update: set current and previous buffers equal (for fast partial update to work correctly)
  54. void writeImageAgain(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);
  55. void writeImagePartAgain(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  56. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  57. 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);
  58. 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,
  59. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  60. // write sprite of native data to controller memory, with screen refresh; x and w should be multiple of 8
  61. 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);
  62. void refresh(bool partial_update_mode = false); // screen refresh from controller memory to full screen
  63. void refresh(int16_t x, int16_t y, int16_t w, int16_t h); // screen refresh from controller memory, partial screen
  64. void powerOff(); // turns off generation of panel driving voltages, avoids screen fading over time
  65. void hibernate(); // turns powerOff() and sets controller to deep sleep for minimum power use, ONLY if wakeable by RST (rst >= 0)
  66. private:
  67. void _writeCommandToMaster(uint8_t c);
  68. void _writeCommandToSlave(uint8_t c);
  69. void _writeCommandToBoth(uint8_t c);
  70. void _writeDataToMaster(uint8_t d);
  71. void _writeDataToSlave(uint8_t d);
  72. void _writeDataToBoth(uint8_t d);
  73. void _startTransferToMaster();
  74. void _startTransferToSlave();
  75. void _transferToMaster(uint8_t value);
  76. void _transferToSlave(uint8_t value);
  77. void _endTransferToMaster();
  78. void _endTransferToSlave();
  79. void _writeScreenBuffer(uint8_t command, uint8_t value);
  80. void _writeImage(uint8_t command, 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);
  81. void _writeImagePart(uint8_t command, const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  82. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  83. void _setPartialRamAreaMaster(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
  84. void _setPartialRamAreaSlave(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
  85. void _PowerOn();
  86. void _PowerOff();
  87. void _InitDisplay();
  88. void _Init_Full();
  89. void _Init_Part();
  90. void _Update_Full();
  91. void _Update_Part();
  92. private:
  93. int16_t _cs2;
  94. static const unsigned char lut_20_vcomDC[];
  95. static const unsigned char lut_21_ww[];
  96. static const unsigned char lut_22_bw[];
  97. static const unsigned char lut_23_wb[];
  98. static const unsigned char lut_24_bb[];
  99. static const unsigned char lut_20_vcomDC_partial[];
  100. static const unsigned char lut_21_ww_partial[];
  101. static const unsigned char lut_22_bw_partial[];
  102. static const unsigned char lut_23_wb_partial[];
  103. static const unsigned char lut_24_bb_partial[];
  104. };
  105. #endif