#include <TFT_eSPI.h>
#include <SPI.h>
'''Node MCU32S LCD ILI9341 240*320'''
TFT_eSPI tft = TFT_eSPI();
int startPoints[12];
uint16_t colors[5];
void setup() {
tft.init();
randomSeed(analogRead(A0));
tft.fillScreen(TFT_BLACK);
for(int i = 0;i<12;i++)
{
int randTemp = random(0,18);
startPoints[i] = randTemp;
}
int stR = 158;
int stG = 255;
int stB = 169;
for(int i = 0;i<5;i++)
{
int tempR = (float)stR*map(i, 4, 0, 10, 4)/10;
int tempG = (float)stG*map(i, 4, 0, 10, 4)/10;
int tempB = (float)stB*map(i, 4, 0, 10, 4)/10;
uint16_t temp565 = tft.color565(tempR, tempG, tempB);
colors[i] = temp565;
}
tft.setTextFont(2);
}
void drawText(uint8_t i)
{
int start = startPoints[i]*18;
int xPos = i*20;
tft.fillRect(xPos,start,20,18,TFT_BLACK);
for(int j = 1;j<6;j++)
{
int yPos = start + j*18;
if (yPos>=320)yPos-=324;
uint16_t colorTemp = colors[j-1];
tft.setTextColor(colorTemp);
tft.fillRect(xPos,yPos,20,18,TFT_BLACK);
tft.drawChar((65 + random(0,2)*32 + random(0,25)), xPos, yPos, 2);
}
startPoints[i] = startPoints[i] + 1;
if(startPoints[i]>=18)startPoints[i] = 0;
}
void loop() {
// put your main code here, to run repeatedly:
drawText(0);
drawText(1);
drawText(2);
drawText(4);
drawText(5);
drawText(6);
drawText(8);
drawText(10);
drawText(11);
delay(150);
}
实现的是文字逐位下移的效果