#include <Teensy_Parallel_GFX.h>
#include "NT35510_t4x_p.h"
#define NT35510X NT35510
#define NT35510X_SPEED_MHZ 20
#ifdef ARDUINO_TEENSY41
#define TFT_DC 10
#define TFT_CS 8
#define TFT_RST 9
#elif defined(ARDUINO_TEENSY40)
#define TFT_DC 0
#define TFT_CS 1
#define TFT_RST 2
#elif defined(ARDUINO_TEENSY_DEVBRD4) || defined(ARDUINO_TEENSY_DEVBRD5)
extern "C" bool sdram_begin(uint8_t external_sdram_size, uint8_t clock, uint8_t useDQS);
#define TFT_DC 10
#define TFT_CS 11
#define TFT_RST 12
#else // micromod?
#define TFT_DC 4
#define TFT_CS 5
#define TFT_RST 3
#endif
NT35510_t4x_p tft = NT35510_t4x_p(TFT_DC, TFT_CS, TFT_RST); //(dc, cs, rst)
#ifndef BLUE
#define BLUE 0x001F
#define BLACK 0x0000
#define WHITE 0xFFFF
#define GREEN 0x07E0
#define RED 0xf800
#endif
void setup(void) {
while (!Serial && millis() < 3000)
;
Serial.println("*** start up NT35510 ***");
tft.begin(NT35510X, NT35510X_SPEED_MHZ);
tft.setBitDepth(24);
tft.setRotation(1);
tft.fillScreen(RED);
delay(500);
tft.fillScreen(GREEN);
delay(500);
tft.fillScreen(BLUE);
delay(500);
}
void fillScreenOneColorRange(uint32_t color_start, uint32_t color_end) {
uint8_t r, g, b;
uint8_t rs, gs, bs, re, ge, be;
tft.color888toRGB(color_start, rs, gs, bs);
tft.color888toRGB(color_end, re, ge, be);
for (uint16_t i = 0; i < 256; i++) {
r = rs + (((uint32_t)(re - rs)) * i) / 256;
g = gs + (((uint32_t)(ge - gs)) * i) / 256;
b = bs + (((uint32_t)(be - bs)) * i) / 256;
tft.fillRect(i * 3 + 16, 1, 3, 239, tft.color565(r, g, b));
tft.fillRect24BPP(i * 3 + 16, 240, 3, 239, tft.color888(r, g, b));
}
}
uint32_t colors[] = { tft.color888(255, 0, 0), tft.color888(0, 255, 0), tft.color888(0, 0, 255),
tft.color888(255, 255, 0), tft.color888(255, 0, 255), tft.color888(0, 255, 255), tft.color888(255, 255, 255) };
uint8_t color_index = 0xff;
void loop() {
Serial.println("Press any key to continue");
while (Serial.read() == -1) {}
while (Serial.read() != -1) {}
color_index++;
if (color_index == (sizeof(colors) / sizeof(colors[0]))) color_index = 0;
fillScreenOneColorRange(tft.color888(0, 0, 0), colors[color_index]);
}