GxEPD2_GFX.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. //
  6. // Author: Jean-Marc Zingg
  7. //
  8. // Version: see library.properties
  9. //
  10. // Library: https://github.com/ZinggJM/GxEPD2
  11. #ifndef _GxEPD2_GFX_H_
  12. #define _GxEPD2_GFX_H_
  13. #include <Adafruit_GFX.h>
  14. class GxEPD2_GFX : public Adafruit_GFX
  15. {
  16. public:
  17. GxEPD2_GFX(GxEPD2_EPD& _epd2, int16_t w, int16_t h) : Adafruit_GFX(w, h), epd2(_epd2) {};
  18. virtual uint16_t pages() = 0;
  19. virtual uint16_t pageHeight() = 0;
  20. virtual bool mirror(bool m) = 0;
  21. virtual void init(uint32_t serial_diag_bitrate = 0) = 0; // serial_diag_bitrate = 0 : disabled
  22. virtual void fillScreen(uint16_t color) = 0; // 0x0 black, >0x0 white, to buffer
  23. virtual void display(bool partial_update_mode = false) = 0;
  24. virtual void setFullWindow() = 0;
  25. // setPartialWindow, use parameters according to actual rotation.
  26. // x and w should be multiple of 8, for rotation 0 or 2,
  27. // y and h should be multiple of 8, for rotation 1 or 3,
  28. // else window is increased as needed,
  29. // this is an addressing limitation of the e-paper controllers
  30. virtual void setPartialWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) = 0;
  31. virtual void firstPage() = 0;
  32. virtual bool nextPage() = 0;
  33. virtual void drawPaged(void (*drawCallback)(const void*), const void* pv) = 0;
  34. virtual void drawInvertedBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color) = 0;
  35. // Support for Bitmaps (Sprites) to Controller Buffer and to Screen
  36. virtual void clearScreen(uint8_t value = 0xFF) = 0; // init controller memory and screen (default white)
  37. virtual void writeScreenBuffer(uint8_t value = 0xFF) = 0; // init controller memory (default white)
  38. // write to controller memory, without screen refresh; x and w should be multiple of 8
  39. virtual 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) = 0;
  40. virtual void writeImage(const uint8_t* black, const uint8_t* color, int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm) = 0;
  41. // write to controller memory, with screen refresh; x and w should be multiple of 8
  42. virtual 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) = 0;
  43. virtual void drawImage(const uint8_t* black, const uint8_t* color, int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm) = 0;
  44. virtual void refresh(bool partial_update_mode = false) = 0; // screen refresh from controller memory to full screen
  45. virtual void refresh(int16_t x, int16_t y, int16_t w, int16_t h) = 0; // screen refresh from controller memory, partial screen
  46. virtual void powerOff() = 0; // turns off generation of panel driving voltages, avoids screen fading over time
  47. virtual void hibernate() = 0; // turns powerOff() and sets controller to deep sleep for minimum power use, ONLY if wakeable by RST (rst >= 0)
  48. public:
  49. GxEPD2_EPD& epd2;
  50. };
  51. #endif