#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define TFT_CS 10
#define TFT_RST 9
#define TFT_DC 8
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
tft.begin();
tft.setRotation(3); // Set the display rotation if necessary
tft.fillScreen(ILI9341_BLACK); // Clear the screen with black color
drawLine();
drawArrowLine();
drawRectangle();
drawTriangle();
drawCircle();
}
void loop() {
// put your main code here, to run repeatedly:
}
void drawLine() {
tft.drawLine(10, 10, 100, 10, ILI9341_WHITE); // Simple line from (10,10) to (100,10)
}
void drawArrowLine() {
int x0 = 20, y0 = 30, x1 = 120, y1 = 30;
tft.drawLine(x0, y0, x1, y1, ILI9341_GREEN); // Main line
// Draw arrowhead (simple version)
tft.drawLine(x1, y1, x1 - 10, y1 - 10, ILI9341_GREEN); // Left wing
tft.drawLine(x1, y1, x1 - 10, y1 + 10, ILI9341_GREEN); // Right wing
}
void drawRectangle() {
tft.drawRect(30, 50, 60, 30, ILI9341_RED); // Rectangle at (30,50) with width 60 and height 30
}
void drawTriangle() {
int x0 = 50, y0 = 100, x1 = 100, y1 = 140, x2 = 20, y2 = 140;
tft.drawTriangle(x0, y0, x1, y1, x2, y2, ILI9341_YELLOW);
}
void drawCircle() {
tft.drawCircle(60, 180, 20, ILI9341_BLUE); // Circle with center at (60,180) and radius 20
}