Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Below is a simple example of using an IPS 1.54 Inch Display with an SPI ST7789 Chipset. This will use the Adafruit_ST7789 library to control the display. In this example, it assumes the following connections:
- SCLK => GPIO18
- MOSI => GPIO23
- CS => GPIO5
- DC => GPIO16
- RST => GPIO17
- BLK => GPIO19
- Please replace the pin definitions with your actual hardware connections. The example code will display the text "Hello, world!" in white and "from ESP32!" in red on the display.
- */
- #include <Adafruit_GFX.h>
- #include <Adafruit_ST7789.h>
- #include <SPI.h>
- #define TFT_CLK 18 // SCLK
- #define TFT_MOSI 23 // MOSI
- #define TFT_CS 5 // CS
- #define TFT_DC 16 // DC
- #define TFT_RST 17 // RST
- #define TFT_BLK 19 // BLK
- Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST, TFT_CLK, TFT_MOSI, -1);
- void setup() {
- pinMode(TFT_BLK, OUTPUT);
- digitalWrite(TFT_BLK, HIGH); // turn backlight on
- tft.init(240, 240, SPI_MODE2); // Init ST7789 240x240
- tft.setRotation(2);
- tft.fillScreen(ST77XX_BLACK);
- delay(500);
- // text display tests
- tft.setCursor(0, 0);
- tft.setTextColor(ST77XX_WHITE);
- tft.setTextSize(1);
- tft.println("Hello, world!");
- delay(500);
- tft.setTextColor(ST77XX_RED);
- tft.setTextSize(2);
- tft.println("from ESP32!");
- }
- void loop() {
- // put your main code here, to run repeatedly:
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement