GxEPD2_420_GYE042A87.h 6.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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/product/386.html
  5. // Panel: GY-E042A87 : origin unknown
  6. // similar Panel: GDEY042T81 : https://www.good-display.com/product/386.html
  7. // Controller : SSD1683 : https://v4.cecdn.yun300.cn/100001_1909185148/SSD1683.PDF
  8. //
  9. // Author: Jean-Marc Zingg
  10. //
  11. // Version: see library.properties
  12. //
  13. // Library: https://github.com/ZinggJM/GxEPD2
  14. #ifndef _GxEPD2_420_GYE042A87_H_
  15. #define _GxEPD2_420_GYE042A87_H_
  16. #include "../GxEPD2_EPD.h"
  17. class GxEPD2_420_GYE042A87 : public GxEPD2_EPD
  18. {
  19. public:
  20. // attributes
  21. static const uint16_t WIDTH = 400;
  22. static const uint16_t WIDTH_VISIBLE = WIDTH;
  23. static const uint16_t HEIGHT = 300;
  24. static const GxEPD2::Panel panel = GxEPD2::GYE042A87;
  25. static const bool hasColor = false;
  26. static const bool hasPartialUpdate = true;
  27. static const bool hasFastPartialUpdate = true;
  28. static const bool useFastFullUpdate = true; // set false for extended (low) temperature range
  29. static const uint16_t power_on_time = 100; // ms, e.g. 96000us
  30. static const uint16_t power_off_time = 300; // ms, e.g. 268000us
  31. static const uint16_t full_refresh_time = 1200; // ms, e.g. 1140000us
  32. static const uint16_t partial_refresh_time = 400; // ms, e.g. 358000us
  33. // constructor
  34. GxEPD2_420_GYE042A87(int16_t cs, int16_t dc, int16_t rst, int16_t busy);
  35. // methods (virtual)
  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 writeImageForFullRefresh(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);
  43. void writeImageToPrevious(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);
  44. void writeImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  45. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  46. void writeImagePartToPrevious(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  47. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  48. 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);
  49. 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,
  50. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  51. // for differential update: set current and previous buffers equal (for fast partial update to work correctly)
  52. 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);
  53. void writeImagePartAgain(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. // 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. void _writeScreenBuffer(uint8_t command, uint8_t value);
  72. 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);
  73. 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,
  74. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  75. void _setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
  76. void _PowerOn();
  77. void _PowerOff();
  78. void _InitDisplay();
  79. void _Update_Full();
  80. void _Update_Part();
  81. };
  82. #endif