#include <SPI.h>
#include <Adafruit_ILI9341.h>
// Pin definitions for the display
#define TFT_CS 10
#define TFT_RST 9
#define TFT_DC 8
// Create display object
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
Serial.begin(9600);
tft.begin();
// Call test functions
Serial.println(testFilledCircles(10, ILI9341_MAGENTA));
Serial.println(testCircles(10, ILI9341_WHITE));
Serial.println(testTriangles());
Serial.println(testFilledTriangles());
Serial.println(testRoundRects());
Serial.println(testFilledRoundRects());
}
void loop() {
// Do nothing here
}
// Define missing functions
long unsigned int testFilledCircles(uint8_t radius, uint16_t color) {
tft.fillScreen(ILI9341_BLACK);
for (int x = radius; x < tft.width(); x += radius * 2) {
for (int y = radius; y < tft.height(); y += radius * 2) {
tft.fillCircle(x, y, radius, color);
}
}
return millis();
}
long unsigned int testCircles(uint8_t radius, uint16_t color) {
tft.fillScreen(ILI9341_BLACK);
for (int x = 0; x < tft.width() + radius; x += radius * 2) {
for (int y = 0; y < tft.height() + radius; y += radius * 2) {
tft.drawCircle(x, y, radius, color);
}
}
return millis();
}
long unsigned int testTriangles() {
tft.fillScreen(ILI9341_BLACK);
int w = tft.width() / 2;
int h = tft.height() / 2;
for (int i = 0; i < w; i += 5) {
tft.drawTriangle(w, h - i, w - i, h + i, w + i, h + i, ILI9341_RED);
}
return millis();
}
long unsigned int testFilledTriangles() {
tft.fillScreen(ILI9341_BLACK);
int w = tft.width() / 2;
int h = tft.height() / 2;
for (int i = 0; i < w; i += 5) {
tft.fillTriangle(w, h - i, w - i, h + i, w + i, h + i, ILI9341_GREEN);
}
return millis();
}
long unsigned int testRoundRects() {
tft.fillScreen(ILI9341_BLACK);
for (int i = 0; i < tft.height(); i += 5) {
tft.drawRoundRect(i, i, tft.width() - 2 * i, tft.height() - 2 * i, 10, ILI9341_BLUE);
}
return millis();
}
long unsigned int testFilledRoundRects() {
tft.fillScreen(ILI9341_BLACK);
for (int i = 0; i < tft.height(); i += 5) {
tft.fillRoundRect(i, i, tft.width() - 2 * i, tft.height() - 2 * i, 10, ILI9341_YELLOW);
}
return millis();
}
long unsigned int testFilledRects(uint16_t color1, uint16_t color2) {
tft.fillScreen(ILI9341_BLACK);
int n, i, i2, cx = tft.width() / 2 - 1, cy = tft.height() / 2 - 1;
for (n = 0; n < tft.width(); n += 6) {
i = n;
i2 = n + 6;
tft.fillRect(cx - i, cy - i, i2, i2, color1);
tft.fillRect(cx - i - 3, cy - i - 3, i2 - 6, i2 - 6, color2);
}
return millis();
}