ST7789Display.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma once
  2. #include "DisplayDriver.h"
  3. #include <Wire.h>
  4. #include <SPI.h>
  5. #include <Adafruit_GFX.h>
  6. #include "ST7789Spi.h"
  7. class ST7789Display : public DisplayDriver {
  8. ST7789Spi display;
  9. bool _isOn;
  10. uint16_t _color;
  11. int _x=0, _y=0;
  12. bool i2c_probe(TwoWire& wire, uint8_t addr);
  13. public:
  14. #ifdef HELTEC_VISION_MASTER_T190
  15. ST7789Display() : DisplayDriver(128, 64), display(&SPI, PIN_TFT_RST, PIN_TFT_DC, PIN_TFT_CS, GEOMETRY_RAWMODE, 320, 170,PIN_TFT_SDA,-1,PIN_TFT_SCL) {_isOn = false;}
  16. #else
  17. ST7789Display() : DisplayDriver(128, 64), display(&SPI1, PIN_TFT_RST, PIN_TFT_DC, PIN_TFT_CS, GEOMETRY_RAWMODE, 240, 135) {_isOn = false;}
  18. #endif
  19. bool begin();
  20. bool isOn() override { return _isOn; }
  21. void turnOn() override;
  22. void turnOff() override;
  23. void clear() override;
  24. void startFrame(Color bkg = DARK) override;
  25. void setTextSize(int sz) override;
  26. void setColor(Color c) override;
  27. void setCursor(int x, int y) override;
  28. void print(const char* str) override;
  29. void printWordWrap(const char* str, int max_width) override;
  30. void fillRect(int x, int y, int w, int h) override;
  31. void drawRect(int x, int y, int w, int h) override;
  32. void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override;
  33. uint16_t getTextWidth(const char* str) override;
  34. void endFrame() override;
  35. };