Adafruit_GFX.h 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. // Minimal stand-in for the parts of Adafruit_GFX that GxEPD2_BW.h/
  3. // GxEPD2_3C.h's wrapper templates actually use (constructor(w,h), width()/
  4. // height(), rotation, fillScreen() looping drawPixel(), drawPixel() left
  5. // pure virtual for the wrapper to override). Not vendoring the real
  6. // Adafruit_GFX (fonts, shape-drawing, etc.) - none of that is exercised by
  7. // driving one full-screen update through firstPage()/nextPage().
  8. #include <cstdint>
  9. class Adafruit_GFX {
  10. public:
  11. Adafruit_GFX(int16_t w, int16_t h) : width_(w), height_(h) {}
  12. virtual ~Adafruit_GFX() = default;
  13. int16_t width() const { return rotation_ & 1 ? height_ : width_; }
  14. int16_t height() const { return rotation_ & 1 ? width_ : height_; }
  15. uint8_t getRotation() const { return rotation_; }
  16. void setRotation(uint8_t r) { rotation_ = r & 3; }
  17. virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
  18. void fillScreen(uint16_t color) {
  19. for (int16_t y = 0; y < height(); y++)
  20. for (int16_t x = 0; x < width(); x++)
  21. drawPixel(x, y, color);
  22. }
  23. protected:
  24. int16_t width_, height_;
  25. uint8_t rotation_{0};
  26. };