//=============================================================================
//=============================================================================
#include <ILI9488_t3.h>
#include <ILI9488_t3_font_Arial.h>
#include <ILI9488_t3_font_ArialBold.h>
#ifdef __MK66FX1M0__
#define __C64__ 1
#else
#endif
// Connection konfiguration of ILI9341 LCD TFT
#if defined(__C64__)
#define SCK 14
#define MISO 39
#define MOSI 28
#define TFT_RST 255
#define TFT_DC 20
#define TFT_CS 21
ILI9488_t3 tft = ILI9488_t3(TFT_CS, TFT_DC, TFT_RST, MOSI, SCK, MISO );
#else
#define TFT_RST 8
#define TFT_DC 9
#define TFT_CS 10
ILI9488_t3 tft = ILI9488_t3(TFT_CS, TFT_DC, TFT_RST);
#endif
//=============================================================================
// Setup
//=============================================================================
bool use_frame_buffer = true;
void setup()
{
while (!Serial && millis() < 4000 );
Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);
tft.begin();
tft.setRotation(3); // 180
delay(100);
tft.fillScreen(ILI9488_BLACK);
delay(250);
tft.fillScreen(ILI9488_RED);
delay(250);
tft.fillScreen(ILI9488_BLUE);
delay(250);
tft.fillScreen(ILI9488_GREEN);
delay(250);
tft.fillScreen(ILI9488_BLACK);
tft.useFrameBuffer(use_frame_buffer);
}
int ii = 0;
void drawColor(uint16_t x, uint16_t y, const char *psz, uint16_t color)
{
static uint16_t cLast = ILI9488_WHITE;
tft.setFontAdafruit();
tft.setTextColor(color);
tft.setTextSize(2);
tft.setCursor(x, y);
if ( 0 == ii % 10 ) tft.print(psz);
if ( 1 == ii % 10 ) tft.drawRect(x + 100, y, 50, 50, color);
if ( 2 == ii % 10 ) tft.fillRect(x + 110, y + 10, 30, 30, cLast);
if ( 7 == ii % 10 ) tft.drawLine(x + 100, y + 70, x + 200, y + 70, color);
if ( 4 == ii % 10 ) tft.drawLine(x + 220, y, x + 220, y + 70, color);
if ( 5 == ii % 10 ) tft.drawLine(x + 100, y + 70, x + 220, y, color);
if ( 6 == ii % 10 ) tft.drawCircle(x + 50, y + 50, 28, color);
if ( 3 == ii % 10 ) tft.fillCircle(x + 50, y + 50, 20, cLast);
tft.setFont(Arial_12_Bold);
tft.setCursor(x + 160, y + 50);
if ( 8 == ii % 10 ) tft.print(psz);
if ( 9 == ii % 10 ) tft.fillCircle(x + 50, y + 50, 20, color);
if ( 9 == ii % 10 ) tft.fillRect(x + 110, y + 10, 30, 30, color);
cLast = color;
}
//=============================================================================
// Loop
//=============================================================================
void loop()
{
tft.setFont(Arial_18_Bold);
tft.setCursor(0, 150);
if ( !(ii % 10) ) {
if (use_frame_buffer) {
tft.fillScreen(ILI9488_LIGHTGREY);
} else {
tft.fillScreen(ILI9488_BLACK);
}
}
drawColor(0, 0, "Red", ILI9488_RED);
drawColor(0, 80, "Green", ILI9488_GREEN);
drawColor(0, 160, "Blue", ILI9488_BLUE);
drawColor(0, 240, "White", ILI9488_WHITE);
drawColor(240, 0, "Yellow", ILI9488_YELLOW);
drawColor(240, 80, "Orange", ILI9488_ORANGE);
drawColor(240, 160, "Cyan", ILI9488_CYAN);
drawColor(240, 240, "Pink", ILI9488_PINK);
delay(110);
if ( !(ii % 10) ) {
if (use_frame_buffer) {
tft.updateScreen();
use_frame_buffer = false;
} else {
use_frame_buffer = true;
}
tft.useFrameBuffer(use_frame_buffer);
delay(2500);
}
ii++;
}