GxEPD2_371.h 5.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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: http://www.e-paper-display.com/download_detail/downloadsId=639.html
  5. // Panel: GDEW0371W7 : http://www.e-paper-display.com/products_detail/productId=401.html
  6. // Controller: IL0324 : http://www.e-paper-display.com/download_detail/downloadsId=763.html
  7. //
  8. // Author: Jean-Marc Zingg
  9. //
  10. // Version: see library.properties
  11. //
  12. // Library: https://github.com/ZinggJM/GxEPD2
  13. #ifndef _GxEPD2_371_H_
  14. #define _GxEPD2_371_H_
  15. #include "../GxEPD2_EPD.h"
  16. class GxEPD2_371 : public GxEPD2_EPD
  17. {
  18. public:
  19. // attributes
  20. static const uint16_t WIDTH = 240;
  21. static const uint16_t HEIGHT = 416;
  22. static const GxEPD2::Panel panel = GxEPD2::GDEW0371W7;
  23. static const bool hasColor = false;
  24. static const bool hasPartialUpdate = true;
  25. static const bool usePartialUpdateWindow = false; // set false for better image
  26. static const bool hasFastPartialUpdate = true; // set this false to force full refresh always
  27. static const uint16_t power_on_time = 200; // ms, e.g. 126267us
  28. static const uint16_t power_off_time = 50; // ms, e.g. 39563us
  29. static const uint16_t full_refresh_time = 3000; // ms, e.g. 2953630us
  30. static const uint16_t partial_refresh_time = 1500; // ms, e.g. 1482735us
  31. // constructor
  32. GxEPD2_371(int16_t cs, int16_t dc, int16_t rst, int16_t busy);
  33. // methods (virtual)
  34. // Support for Bitmaps (Sprites) to Controller Buffer and to Screen
  35. void clearScreen(uint8_t value = 0xFF); // init controller memory and screen (default white)
  36. void writeScreenBuffer(uint8_t value = 0xFF); // init controller memory (default white)
  37. // write to controller memory, without screen refresh; x and w should be multiple of 8
  38. 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);
  39. void writeImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  40. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  41. 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);
  42. 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,
  43. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  44. // for differential update: set current and previous buffers equal (for fast partial update to work correctly)
  45. // done by controller (N2OCP); override with empty code
  46. 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) {};
  47. void writeImagePartAgain(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  48. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false) {};
  49. // write sprite of native data to controller memory, without screen refresh; x and w should be multiple of 8
  50. 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);
  51. // write to controller memory, with screen refresh; x and w should be multiple of 8
  52. 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);
  53. void drawImagePart(const uint8_t bitmap[], 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. 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);
  56. 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,
  57. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  58. // write sprite of native data to controller memory, with screen refresh; x and w should be multiple of 8
  59. 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);
  60. void refresh(bool partial_update_mode = false); // screen refresh from controller memory to full screen
  61. void refresh(int16_t x, int16_t y, int16_t w, int16_t h); // screen refresh from controller memory, partial screen
  62. void powerOff(); // turns off generation of panel driving voltages, avoids screen fading over time
  63. void hibernate(); // turns powerOff() and sets controller to deep sleep for minimum power use, ONLY if wakeable by RST (rst >= 0)
  64. private:
  65. void _setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
  66. void _PowerOn();
  67. void _PowerOff();
  68. void _InitDisplay();
  69. void _Init_Full();
  70. void _Init_Part();
  71. void _Update_Full();
  72. void _Update_Part();
  73. private:
  74. static const unsigned char lut_20_LUTC_partial[];
  75. static const unsigned char lut_21_LUTWW_partial[];
  76. static const unsigned char lut_22_LUTKW_partial[];
  77. static const unsigned char lut_23_LUTWK_partial[];
  78. static const unsigned char lut_24_LUTKK_partial[];
  79. static const unsigned char lut_25_LUTBD_partial[];
  80. };
  81. #endif