* ST7735Display: now applies SCALE_X, SCALE_Y
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
#define DISPLAY_ROTATION 2
|
#define DISPLAY_ROTATION 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SCALE_X 1.25f // 160 / 128
|
||||||
|
#define SCALE_Y 1.25f // 80 / 64
|
||||||
|
|
||||||
bool ST7735Display::i2c_probe(TwoWire& wire, uint8_t addr) {
|
bool ST7735Display::i2c_probe(TwoWire& wire, uint8_t addr) {
|
||||||
return true;
|
return true;
|
||||||
@@ -99,7 +101,7 @@ void ST7735Display::setColor(Color c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ST7735Display::setCursor(int x, int y) {
|
void ST7735Display::setCursor(int x, int y) {
|
||||||
display.setCursor(x, y);
|
display.setCursor(x*SCALE_X, y*SCALE_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ST7735Display::print(const char* str) {
|
void ST7735Display::print(const char* str) {
|
||||||
@@ -107,22 +109,22 @@ void ST7735Display::print(const char* str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ST7735Display::fillRect(int x, int y, int w, int h) {
|
void ST7735Display::fillRect(int x, int y, int w, int h) {
|
||||||
display.fillRect(x, y, w, h, _color);
|
display.fillRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, _color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ST7735Display::drawRect(int x, int y, int w, int h) {
|
void ST7735Display::drawRect(int x, int y, int w, int h) {
|
||||||
display.drawRect(x, y, w, h, _color);
|
display.drawRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, _color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ST7735Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
|
void ST7735Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
|
||||||
display.drawBitmap(x, y, bits, w, h, _color);
|
display.drawBitmap(x*SCALE_X, y*SCALE_Y, bits, w, h, _color);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t ST7735Display::getTextWidth(const char* str) {
|
uint16_t ST7735Display::getTextWidth(const char* str) {
|
||||||
int16_t x1, y1;
|
int16_t x1, y1;
|
||||||
uint16_t w, h;
|
uint16_t w, h;
|
||||||
display.getTextBounds(str, 0, 0, &x1, &y1, &w, &h);
|
display.getTextBounds(str, 0, 0, &x1, &y1, &w, &h);
|
||||||
return w;
|
return w / SCALE_X;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ST7735Display::endFrame() {
|
void ST7735Display::endFrame() {
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ class ST7735Display : public DisplayDriver {
|
|||||||
bool i2c_probe(TwoWire& wire, uint8_t addr);
|
bool i2c_probe(TwoWire& wire, uint8_t addr);
|
||||||
public:
|
public:
|
||||||
#ifdef USE_PIN_TFT
|
#ifdef USE_PIN_TFT
|
||||||
ST7735Display() : DisplayDriver(80, 160), display(PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_SDA, PIN_TFT_SCL, PIN_TFT_RST) { _isOn = false; }
|
ST7735Display() : DisplayDriver(128, 64), display(PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_SDA, PIN_TFT_SCL, PIN_TFT_RST) { _isOn = false; }
|
||||||
#else
|
#else
|
||||||
ST7735Display() : DisplayDriver(80, 160), display(&SPI1, PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_RST) { _isOn = false; }
|
ST7735Display() : DisplayDriver(128, 64), display(&SPI1, PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_RST) { _isOn = false; }
|
||||||
#endif
|
#endif
|
||||||
bool begin();
|
bool begin();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user