Seeed Studio XIAO ESP32S3 Sense display on 2.4" TFT 240×320 ST7789V using Adafruit_ST7789 lib in Arduino framework.
Exercise running on Seeed Studio XIAO ESP32S3 Sense, to display on
2.4" TFT 240×320 ST7789V
using Adafruit_ST7789 lib in Arduino framework.
Board and library installed:
esp32 by Espressif System
(arduino-esp32) 3.0.3
Adafruit ST7735 and ST7789 Library 1.10.4
Connection:
XiaoS3_ST7789_SPI_240x320_color.ino
/**************************************************************************
XIAO ESP32S3 Connect display on
2.4" IPS 240x320 SPI (ST7789V)
: Color Test
Connection:
ST7789 XIAO ESP32S3
1 GND GND
2 VCC 3V3
3 SCL GPIO7 (hardware SPI SCK)
4 SDA GPIO9 (hardware SPI MOSI)
5 RST GPIO2
6 DC GPIO3
7 CS GPIO4
8 BL 3V3
**************************************************************************/
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>
#define TFT_RST 2
#define TFT_DC 3
#define TFT_CS 4
// For ST7789, using hardware SPI (SCK=GPIO7, MOSI=GPIO9):
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
void setup(void) {
delay(500);
Serial.begin(115200);
delay(500);
Serial.print(F("240x320 IPS ST7789V SPI"));
Serial.println();
Serial.print("MOSI: ");
Serial.println(MOSI);
Serial.print("SCK: ");
Serial.println(SCK);
// using a 2.4" IPS 240x320 SPI (ST7789V):
tft.init(240, 320); // Init ST7789 240x320
tft.setRotation(0);
tft.fillScreen(ST77XX_BLACK);
Serial.println(F("Initialized"));
Serial.println(tft.width());
Serial.println(tft.height());
delay(1000);
}
void loop() {
tft.fillScreen(ST77XX_BLACK);
tft.setTextSize(3);
drawtext("BLACK", ST77XX_WHITE, 10, 10);
tft.drawRect(0, 0, tft.width(), tft.height(), ST77XX_WHITE);
delay(3000);
tft.fillScreen(ST77XX_WHITE);
tft.setTextSize(3);
drawtext("WHITE", ST77XX_BLACK, 10, 10);
tft.drawRect(1, 1, tft.width()-2, tft.height()-2, ST77XX_BLACK);
delay(3000);
tft.fillScreen(ST77XX_RED);
tft.setTextSize(3);
drawtext("RED", ST77XX_WHITE, 10, 10);
delay(3000);
tft.fillScreen(ST77XX_GREEN);
tft.setTextSize(3);
drawtext("GREEN", ST77XX_WHITE, 10, 10);
delay(3000);
tft.fillScreen(ST77XX_BLUE);
tft.setTextSize(3);
drawtext("BLUE", ST77XX_WHITE, 10, 10);
delay(3000);
}
void drawtext(char *text, uint16_t color, int16_t x, int16_t y) {
tft.setCursor(x, y);
tft.setTextColor(color);
tft.setTextWrap(true);
tft.print(text);
}
next:
~ Adafruit_GFX/ImageReader exercises to load bmp images from MicroSD and display on 240×320 ST7789 SPI TFT, run on Seeed Studio XIAO ESP32S3 Sense (Arduino Platform).
Comments
Post a Comment