/*
Приклад використання TFT дисплею на драйвері ILI9341 LCD
tft.drawTriangle( x1, y1, x2, y2, x3, y3, tft.color565(0, i*10, i*10));
tft.fillTriangle(x1, y1, x2, y2, x3, y3, tft.color565(0, i*10, i*10));
tft.drawRoundRect(x, y, w, h, i/8, tft.color565(i, 0, 0));
tft.fillRoundRect(x, y, w, h, i/8, tft.color565(i, 0, 0));
tft.drawCircle(x, y, radius, color);
tft.fillCircle(x, y, radius, color);
tft.drawRect(x, y, w, h, color2);
tft.drawFastHLine(0, y, w, color1);
tft.drawFastVLine(x, 0, h, color2);
tft.drawLine(x1, y1, x2, y2, color);
Вбудовані кольори (використати цей масив)
const uint32_t colors[] = {
ILI9341_RED,
ILI9341_GREEN,
ILI9341_BLUE,
ILI9341_CYAN,
ILI9341_MAGENTA,
ILI9341_YELLOW,
ILI9341_ORANGE,
};
*/
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <SPI.h>
// Pin definitions for ESP32
#define TFT_DC 2
#define TFT_CS 15
#define TFT_RST 4
// Initialize the display using the defined pins
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
Serial.begin(115200);
// Initialize the display
tft.begin();
// Clear the display
tft.fillScreen(ILI9341_BLACK);
// Draw a red rectangle on the screen
tft.fillRect(10, 10, 150, 50, ILI9341_RED);
// Draw a white line from (0,0) to (240,320)
tft.drawLine(0, 0, 240, 320, ILI9341_WHITE);
//tft.drawLine(0, 240, 0, 320, ILI9341_WHITE);
// Display some text on the screen
tft.setTextSize(2);
tft.setCursor(10, 200);
tft.setTextColor(ILI9341_GREEN);
tft.println("4AP");
}
int n = 0; // лічильник
void loop() {
// Nothing to do in loop
n = n + 1;
tft.setTextSize(3);
tft.setCursor(10, 260);
tft.setTextColor(ILI9341_GREEN);
tft.println("n=");
tft.fillRect(5, 250, 300, 380, ILI9341_MAGENTA); // ajy
tft.setTextSize(4);
tft.setCursor(50, 260);
tft.setTextColor(ILI9341_GREEN);
tft.println(n);
delay(100);
}