init
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#include <Adafruit_ST7735.h>
|
||||
#include <Print.h> // Wichtig, um von der Print-Klasse erben zu können
|
||||
|
||||
#define TFT_CS 5
|
||||
#define TFT_RST 4
|
||||
#define TFT_DC 19
|
||||
#define TFT_MOSI 23
|
||||
#define TFT_SCLK 18
|
||||
|
||||
class TFT : public Print {
|
||||
public:
|
||||
void setup() {
|
||||
// Initialize the TFT display
|
||||
// Setup SPI and display parameters
|
||||
tft.initR(INITR_144GREENTAB); // Initialize a ST7735S chip, green tab
|
||||
tft.fillScreen(ST77XX_BLACK);
|
||||
tft.setRotation(1); // Landscape orientation
|
||||
tft.setTextColor(ST77XX_WHITE);
|
||||
tft.setTextSize(1);
|
||||
//tft.setScrollDefinition(0, tft.height(), 0);
|
||||
tft.setCursor(0, 0);
|
||||
}
|
||||
|
||||
|
||||
virtual size_t write(uint8_t c) override {
|
||||
return tft.write(c);
|
||||
}
|
||||
|
||||
Adafruit_ST7735& getGfx() {
|
||||
return tft;
|
||||
}
|
||||
|
||||
void checkCursor() {
|
||||
if (tft.getCursorY() >= tft.height()) {
|
||||
tft.setCursor(0, 0);
|
||||
tft.fillScreen(ST77XX_BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
void resetCursor() {
|
||||
tft.fillScreen(ST77XX_BLACK);
|
||||
tft.setCursor(0, 0);
|
||||
}
|
||||
private:
|
||||
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
|
||||
};
|
||||
|
||||
extern TFT tft; // Deine globale Instanz
|
||||
Reference in New Issue
Block a user