1.44-inch TFT display with Arduino
FunduinoLast updated on
Text, Linien und Formen auf dem ST7735 zeichnen
Wofür TFT-Displays gut sind
Das Display anschließen
Die Bibliothek installieren
1 / 2
Das Programm
Text, Linien, Kreise und Rechtecke zeichnen
// Pins zuordnen
# define TFT_PIN_CS 10
# define TFT_PIN_DC 9
# define TFT_PIN_RST 8
// Bibliotheken einbinden
# include "SPI.h"
# include "Adafruit_GFX.h"
# include "Adafruit_ST7735.h"
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_PIN_CS, TFT_PIN_DC, TFT_PIN_RST);
void setup()
{
Serial.begin(9600);
delay(500);
Serial.println("Bildschirm: " + String(tft.height()) + " x " + String(tft.width()));
tft.initR(INITR_REDTAB);
// Bildschirm um 180 Grad drehen
tft.setRotation(2);
// schwarzer Hintergrund
tft.fillScreen(ST7735_BLACK);
// verschiedene Schriftgrößen
tft.setTextSize(1);
tft.setCursor(1, 5);
tft.setTextColor(ST7735_BLUE);
tft.print("Text");
delay(500);
tft.setTextSize(2);
tft.setCursor(1, 20);
tft.setTextColor(ST7735_GREEN);
tft.print("Text");
delay(500);
tft.setTextSize(3);
tft.setCursor(1, 40);
tft.setTextColor(ST7735_RED);
tft.print("Text");
delay(500);
tft.setTextSize(4);
tft.setCursor(1, 70);
tft.setTextColor(ST7735_YELLOW);
tft.print("Text");
delay(2000);
// Linien ziehen
tft.fillScreen(ST7735_BLACK);
tft.drawLine(1, 1, tft.width(), 1, ST7735_ORANGE);
tft.drawLine(1, 30, tft.width(), 30, ST7735_ORANGE);
tft.drawLine(1, 60, tft.width(), 60, ST7735_ORANGE);
delay(2000);
// Kreise zeichnen
tft.fillScreen(ST7735_BLACK);
tft.fillCircle(60, 60, 50, ST7735_MAGENTA);
tft.fillCircle(60, 60, 30, ST7735_GREEN);
tft.fillCircle(60, 60, 30, ST7735_YELLOW);
delay(2000);
// Rechtecke zeichnen
tft.fillScreen(ST7735_BLACK);
tft.drawRect(1, 1, 50, 50, ST7735_ORANGE);
tft.drawRect(5, 5, 50, 50, ST7735_ORANGE);
tft.drawRect(10, 10, 50, 50, ST7735_ORANGE);
delay(2000);
// ausgefüllte Rechtecke zeichnen
tft.fillScreen(ST7735_BLACK);
tft.fillRect(5, 5, 50, 50, ST7735_GREEN);
tft.fillRect(10, 10, 70, 70, ST7735_BLUE);
tft.fillRect(15, 15, 90, 90, ST7735_RED);
}
void loop()
{
// nichts zu tun, das Programm
// läuft nur einmal
}Rate the instructions