some tests

This commit is contained in:
Florent
2025-04-24 22:37:06 +02:00
parent 36b981c9eb
commit 2a7e105c59
8 changed files with 3336 additions and 46 deletions

View File

@@ -2,15 +2,6 @@
#include "ST7789Display.h"
bool ST7789Display::i2c_probe(TwoWire& wire, uint8_t addr) {
return true;
/*
wire.beginTransmission(addr);
uint8_t error = wire.endTransmission();
return (error == 0);
*/
}
bool ST7789Display::begin() {
if(!_isOn) {
pinMode(PIN_TFT_VDD_CTL, OUTPUT);
@@ -19,13 +10,8 @@ bool ST7789Display::begin() {
digitalWrite(PIN_TFT_LEDA_CTL, LOW);
digitalWrite(PIN_TFT_RST, HIGH);
display.init(135, 240);
display.setRotation(2);
display.setSPISpeed(40000000);
display.fillScreen(ST77XX_BLACK);
display.setTextColor(ST77XX_WHITE);
display.setTextSize(2);
display.cp437(true); // Use full 256 char 'Code Page 437' font
display.init();
display.displayOn();
_isOn = true;
}
@@ -46,18 +32,33 @@ void ST7789Display::turnOff() {
}
void ST7789Display::clear() {
display.fillScreen(ST77XX_BLACK);
// display.fillScreen(ST77XX_BLACK);
display.clear();
}
void ST7789Display::startFrame(Color bkg) {
display.fillScreen(0x00);
display.setTextColor(ST77XX_WHITE);
display.setTextSize(2);
display.cp437(true); // Use full 256 char 'Code Page 437' font
display.clear();
// display.fillScreen(0x00);
// display.setTextColor(ST77XX_WHITE);
// display.setTextSize(2);
// display.cp437(true); // Use full 256 char 'Code Page 437' font
}
void ST7789Display::setTextSize(int sz) {
display.setTextSize(sz);
// display.setTextSize(sz);
switch(sz) {
case 1 :
display.setFont(ArialMT_Plain_10);
break;
case 2 :
display.setFont(ArialMT_Plain_16);
break;
case 3 :
display.setFont(ArialMT_Plain_24);
break;
default:
display.setFont(ArialMT_Plain_10);
}
}
void ST7789Display::setColor(Color c) {
@@ -87,31 +88,34 @@ void ST7789Display::setColor(Color c) {
_color = ST77XX_WHITE;
break;
}
display.setTextColor(_color);
display.setRGB(_color);
//display.setColor((OLEDDISPLAY_COLOR) 4);
}
void ST7789Display::setCursor(int x, int y) {
display.setCursor(x, y);
//display.setCursor(x, y);
_x = x;
_y = y;
}
void ST7789Display::print(const char* str) {
display.print(str);
display.drawString(_x, _y, str);
}
void ST7789Display::fillRect(int x, int y, int w, int h) {
display.fillRect(x, y, w, h, _color);
display.fillRect(x, y, w, h);
}
void ST7789Display::drawRect(int x, int y, int w, int h) {
display.drawRect(x, y, w, h, _color);
display.drawRect(x, y, w, h);
}
void ST7789Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
display.drawBitmap(x, y, bits, w, h, _color);
display.drawXbm(x, y, w, h, bits);
}
void ST7789Display::endFrame() {
// display.display();
display.display();
}
#endif