#include <Arduino_GFX_Library.h>
#include <Adafruit_ILI9341.h>
#include <SPI.h>
#include <Wire.h>
// Pin Definitions
#define TFT_CS 5
#define TFT_RST 4
#define TFT_DC 2
#define TFT_MOSI 23
#define TFT_CLK 18
#define TFT_MISO 19
// Create TFT Display Object
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void TaskDisplay(void *pvParameters);
void setup() {
Serial.begin(115200);
tft.begin();
tft.setRotation(3);
tft.fillScreen(ILI9341_BLACK);
// Create a task to run the display update
xTaskCreatePinnedToCore(
TaskDisplay, // Task function
"TaskDisplay", // Name of the task
10000, // Stack size
NULL, // Task parameter
1, // Task priority
NULL, // Task handle
0 // Core number (0 or 1)
);
}
void loop() {
// Do nothing here, everything is done in tasks
}
void TaskDisplay(void *pvParameters) {
while (1) {
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(10, 10);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.print("Hello, World!");
vTaskDelay(2000 / portTICK_PERIOD_MS);
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(10, 10);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.print("FreeRTOS on ESP32!");
vTaskDelay(2000 / portTICK_PERIOD_MS);
}
}