tft应用

10 篇文章 0 订阅

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=en

   Paste the byte array into a sketch tab and add two lines
   at 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

这个博主的代码里面有如何镜像显示的;

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值