#include <SPI.h>
#include <TFT_eSPI.h>
// Note: this library doesn't require further configuration
#include <XPT2046_Touchscreen.h>
// Create a TFT_eSPI instance:
TFT_eSPI tft = TFT_eSPI();
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#define FONT_SIZE 2
void setup() {
Serial.begin(115200);
// Start the tft display
tft.init();
// Set the TFT display rotation in landscape mode, 1 will flip display 180 degrees
tft.setRotation(3);
// There are 24 predefined colors, see file TFT_eSPI.h in library folder for list of colors
// Can also create your own color by using an RGB hex number, example: 0x0C70
// Use this command to refresh screen by wiping with white or black
tft.fillScreen(0x0C70); // TFT_RED
// There are predefined fonts, see file User_Setup.h in library folder for list of fonts
// Takes up to 2 arguments: (text-color, text-bkg-color)
tft.setTextColor(TFT_BLACK);
// Takes up to 4 arguments: (string, x cord, y cord, text-size)
tft.drawString("Hello Craig", 10, 10); // defalult font used
tft.drawString("Font 1", 10, 20, 1);
tft.setTextColor(TFT_RED);
tft.drawString("Font 2", 10, 30, 2);
tft.setTextColor(TFT_YELLOW);
tft.drawString("Font 4", 10, 50, 4);
tft.drawString("1234", 10, 80, 6); // numbers only
tft.drawString("1234", 10, 120, 7); // numbers only
tft.drawString("1234", 10, 170, 8); // numbers only
tft.setTextColor(TFT_YELLOW, TFT_BLUE);
delay(2000);
}
void loop() {
for (int i = 0; i < 99; i++) {
tft.fillScreen(TFT_WHITE);
tft.drawString(String(i), 40, 80, 7);
delay(250);
}
delay(500);
}
Loading
ili9341-cap-touch
ili9341-cap-touch