GxEPD2_154_M09.h 6.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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: http://www.e-paper-display.com/download_detail/downloadsId=806.html
  5. // Panel: GDEW0154M09 : http://www.e-paper-display.com/products_detail/productId=513.html
  6. // Controller : JD79653A : http://www.e-paper-display.com/download_detail/downloadsId%3d943.html
  7. //
  8. // Author: Jean-Marc Zingg
  9. //
  10. // Version: see library.properties
  11. //
  12. // Library: https://github.com/ZinggJM/GxEPD2
  13. #ifndef _GxEPD2_154_M09_H_
  14. #define _GxEPD2_154_M09_H_
  15. #include "../GxEPD2_EPD.h"
  16. class GxEPD2_154_M09 : public GxEPD2_EPD
  17. {
  18. public:
  19. // attributes
  20. static const uint16_t WIDTH = 200;
  21. static const uint16_t HEIGHT = 200;
  22. static const GxEPD2::Panel panel = GxEPD2::GDEW0154M09;
  23. static const bool hasColor = false;
  24. static const bool hasPartialUpdate = true;
  25. static const bool hasFastPartialUpdate = true;
  26. static const uint16_t power_on_time = 250; // ms, e.g. 206410us
  27. static const uint16_t power_off_time = 100; // ms, e.g. 62091us
  28. static const uint16_t full_refresh_time = 1000; // ms, e.g. 924485us
  29. static const uint16_t partial_refresh_time = 400; // ms, e.g. 324440us
  30. // constructor
  31. GxEPD2_154_M09(int16_t cs, int16_t dc, int16_t rst, int16_t busy);
  32. // methods (virtual)
  33. // Support for Bitmaps (Sprites) to Controller Buffer and to Screen
  34. void clearScreen(uint8_t value = 0xFF); // init controller memory and screen (default white)
  35. void writeScreenBuffer(uint8_t value = 0xFF); // init controller memory (default white)
  36. void writeScreenBufferAgain(uint8_t value = 0xFF); // init previous buffer 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. // write sprite of native data to controller memory, without screen refresh; x and w should be multiple of 8
  45. 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);
  46. // write to controller memory, with screen refresh; x and w should be multiple of 8
  47. 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);
  48. void drawImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  49. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  50. //for differential update: set current and previous buffers equal (for fast partial update to work correctly)
  51. 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);
  52. void writeImagePartAgain(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
  53. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  54. 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);
  55. 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,
  56. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  57. // write sprite of native data to controller memory, with screen refresh; x and w should be multiple of 8
  58. 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);
  59. void refresh(bool partial_update_mode = false); // screen refresh from controller memory to full screen
  60. void refresh(int16_t x, int16_t y, int16_t w, int16_t h); // screen refresh from controller memory, partial screen
  61. void powerOff(); // turns off generation of panel driving voltages, avoids screen fading over time
  62. void hibernate(); // turns powerOff() and sets controller to deep sleep for minimum power use, ONLY if wakeable by RST (rst >= 0)
  63. private:
  64. void _writeScreenBuffer(uint8_t command, uint8_t value);
  65. 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);
  66. 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,
  67. int16_t x, int16_t y, int16_t w, int16_t h, bool invert = false, bool mirror_y = false, bool pgm = false);
  68. void _setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
  69. void _PowerOn();
  70. void _PowerOff();
  71. void _InitDisplay();
  72. void _Init_Full();
  73. void _Init_Part();
  74. void _Update_Full();
  75. void _Update_Part();
  76. private:
  77. static const unsigned char lut_20_vcomDC[];
  78. static const unsigned char lut_21_ww[];
  79. static const unsigned char lut_22_bw[];
  80. static const unsigned char lut_23_wb[];
  81. static const unsigned char lut_24_bb[];
  82. static const unsigned char lut_20_vcomDC_partial[];
  83. static const unsigned char lut_21_ww_partial[];
  84. static const unsigned char lut_22_bw_partial[];
  85. static const unsigned char lut_23_wb_partial[];
  86. static const unsigned char lut_24_bb_partial[];
  87. };
  88. #endif