文章目录
- 1 字体
- 2 刷新问题
- 3 字库
- 补充于2022-8-28
- 4 [https://www.bilibili.com/video/BV1za411Y7AZ?spm_id_from=333.337.search-card.all.click&vd_source=a6d06bb7ed83a3c6257c173b2700e89c](https://www.bilibili.com/video/BV1za411Y7AZ?spm_id_from=333.337.search-card.all.click&vd_source=a6d06bb7ed83a3c6257c173b2700e89c)
1 字体
这是自带的字体,可以用
tft.setTextSize(1);
tft.drawString("1234", 0, 60, 7);// Print the string name of the font 其中7 是所选的字体
#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts// Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded
// this will save ~20kbytes of FLASH
#define SMOOTH_FONT
2 刷新问题
这是输出的时间
如果如果字体是红色黑底,在loop函数中,不用每次清屏,就可以输出变化的时间;
**setup函数中**tft.setTextColor(TFT_RED,TFT_BLACK);//字体是红色黑底**loop函数中**
timeClient.update();
tft.drawString(timeClient.getFormattedTime(),10,60,7);
Serial.println(timeClient.getFormattedTime());delay(1000);
如果字体是红色 透明的,在loop函数中,要每次清屏,就会有一卡一卡的啦
**setup函数中**tft.setTextColor(TFT_RED );// 字体是红色**loop函数中**
tft.fillScreen(TFT_BLACK);//要刷新屏幕,不然数字不更新,会重叠
timeClient.update();
tft.drawString(timeClient.getFormattedTime(),10,60,7);
Serial.println(timeClient.getFormattedTime());
delay(1000);
3 字库
在这个网站上 把.vlw文件转变成byte array,粘贴到 一个头文件中;
最好头文件的名字和fontname 一样;
/* The font vlw file can be converted to a byte array using:https://tomeko.net/online_tools/file_to_hex.php?lang=enPaste the byte array into a sketch tab and add two linesat the start with a unique font name and }; at the end:const uint8_t fontName[] PROGMEM = {Insert byte array here};See example below. Include the tab in the main sketch, e.g.:#include "fontName.h"
*/
补充于2022-8-28
4 https://www.bilibili.com/video/BV1za411Y7AZ?spm_id_from=333.337.search-card.all.click&vd_source=a6d06bb7ed83a3c6257c173b2700e89c
这个博主的代码里面有如何镜像显示的;