【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百一十八:1.3寸 TFT显示屏 ST7789VW 驱动240x240高清ips模块
程序六:点亮屏幕,显示不同颜色的字符
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百一十八:1.3寸 TFT显示屏 ST7789VW 驱动240x240高清ips模块
程序六:点亮屏幕,显示不同颜色的字符
*/
#define SCR_WD 240
#define SCR_HT 240
#include <SPI.h>
#include <Adafruit_GFX.h>
#if (__STM32F1__) // bluepill
#define TFT_DC PA1
#define TFT_RST PA0
//#include <Arduino_ST7789_STM.h>
#else
#define TFT_DC 7
#define TFT_RST 8
#include <Arduino_ST7789_Fast.h>
//#include <Arduino_ST7789.h>
#endif
Arduino_ST7789 lcd = Arduino_ST7789(TFT_DC, TFT_RST);
void setup() {
Serial.begin(9600);
lcd.init();
}
void loop(void) {
for (uint8_t rot = 0; rot < 4; rot++) {
testText(rot);
delay(2000);
}
}
unsigned long testText(int rot) {
lcd.setRotation(rot);
lcd.fillScreen(BLACK);
lcd.setCursor(0, 0);
lcd.setTextColor(BLUE);
lcd.setTextSize(3);
lcd.println("Hello World!");
lcd.setTextColor(WHITE);
lcd.print("Rotation = ");
lcd.println(rot);
lcd.setTextColor(YELLOW);
lcd.setTextSize(4);
lcd.println(1234.56);
lcd.setTextColor(RED);
lcd.setTextSize(5);
lcd.println(0xDEAD, HEX);
lcd.println();
lcd.setTextColor(GREEN);
lcd.setTextSize(6);
lcd.println("Hello");
}
|