GxEPD2_154c.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. // based on Demo Example from Good Display: http://www.e-paper-display.com/download_list/downloadcategoryid=34&isMode=false.html
  5. // Controller: IL0376F : http://www.e-paper-display.com/download_detail/downloadsId=541.html
  6. //
  7. // Author: Jean-Marc Zingg
  8. //
  9. // Version: see library.properties
  10. //
  11. // Library: https://github.com/ZinggJM/GxEPD2
  12. #ifndef _GxEPD2_154c_H_
  13. #define _GxEPD2_154c_H_
  14. #include "../GxEPD2_EPD.h"
  15. class GxEPD2_154c : public GxEPD2_EPD
  16. {
  17. public:
  18. // attributes
  19. static const uint16_t WIDTH = 200;
  20. static const uint16_t HEIGHT = 200;
  21. static const GxEPD2::Panel panel = GxEPD2::GDEW0154Z04;
  22. static const bool hasColor = true;
  23. static const bool hasPartialUpdate = false;
  24. static const bool hasFastPartialUpdate = false;
  25. static const uint16_t power_on_time = 20; // ms, e.g. 10157us
  26. static const uint16_t power_off_time = 20; // ms, e.g. 10157us
  27. static const uint16_t full_refresh_time = 7500; // ms, e.g. 7135635us
  28. static const uint16_t partial_refresh_time = 7500; // ms, e.g. 7135635us
  29. // constructor
  30. GxEPD2_154c(int8_t cs, int8_t dc, int8_t rst, int8_t busy);
  31. // methods (virtual)
  32. void init(uint32_t serial_diag_bitrate = 0); // = 0 : disabled
  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 clearScreen(uint8_t black_value, uint8_t color_value); // init controller memory and screen
  36. void writeScreenBuffer(uint8_t value = 0xFF); // init controller memory (default white)
  37. void writeScreenBuffer(uint8_t black_value, uint8_t color_value); // init controller memory
  38. // write to controller memory, without screen refresh; x and w should be multiple of 8
  39. 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);
  40. 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);
  41. // write sprite of native data to controller memory, without screen refresh; x and w should be multiple of 8
  42. 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);
  43. // write to controller memory, with screen refresh; x and w should be multiple of 8
  44. 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);
  45. 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);
  46. // write sprite of native data to controller memory, with screen refresh; x and w should be multiple of 8
  47. 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);
  48. void refresh(bool partial_update_mode = false); // screen refresh from controller memory to full screen
  49. void refresh(int16_t x, int16_t y, int16_t w, int16_t h); // screen refresh from controller memory, partial screen
  50. void powerOff(); // turns off generation of panel driving voltages, avoids screen fading over time
  51. void hibernate(); // turns powerOff() and sets controller to deep sleep for minimum power use, ONLY if wakeable by RST (rst >= 0)
  52. void setPaged(); // for GxEPD2_154c paged workaround
  53. private:
  54. void _writeScreenBuffer(uint8_t value);
  55. void _setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
  56. void _PowerOn();
  57. void _PowerOff();
  58. void _InitDisplay();
  59. void _Init_Full();
  60. void _Init_Part();
  61. void _Update_Full();
  62. void _Update_Part();
  63. protected:
  64. bool _initial, _power_is_on, _hibernating;
  65. bool _paged, _second_phase;
  66. static const uint8_t bw2grey[];
  67. };
  68. #endif