TFT_eSPI的库下载地址点击进入
一、起因
最近在做一个温度图像显示的项目,需要用到TFT屏幕显示图像和摄像头图像,在搜索下来发现这个优秀的github库、让复杂的图像处理变得简化
这个库支持非常多的操作,支持多个平台,并且使用c++进行开发
这里我们使用Arduino平台,基于esp32单片机进行开发,由于是arduino平台、开源框架非常多所以操作起来会非常的方便、但是到具体的图像显示还是需要自己搭建。关于库的安装、配置和使用教程,网上有非常多的教程、这里就不再赘述
TFT_eSPI入门教程——》教程
基于TFT_eSPI库自定义中文字库的制作——》笔记
基于TFT-eSPI库实现触摸显示屏——》笔记
- 相关API
-
tft.init(); //初始化
初始化屏幕, 如果是ST7735,可以往里面传一个参数, 具体用到时再看
-
tft.fillScreen(TFT_BLACK); //填充全屏幕
填充全屏幕, 后面是颜色值,
tft.fillScreen(uint32_t color);
-
屏幕旋转
// 设置屏幕显示的旋转角度,参数为:0, 1, 2, 3 // 分别代表 0°、90°、180°、270° void setRotation(uint8_t r);
-
屏幕反色
//反转显示颜色i = 1反转,i = 0正常 tft.invertDisplay(bool i);
- 文字相关API
1.
tft.setCursor(20, 10, 4); //设置打字起始坐标位置和字号
// 设置文本显示坐标,默认以文本左上角为参考点,可以改变参考点
void setCursor(int16_t x, int16_t y);
// 设置文本显示坐标,和文本的字体
void setCursor(int16_t x, int16_t y, uint8_t font);
2.
tft.setTextColor(2); //设置字体颜色
// 设置文本颜色
void setTextColor(uint16_t color);
// 设置文本颜色与背景色
void setTextColor(uint16_t fgcolor, uint16_t bgcolor);
设置背景颜色可以有效的防止数字叠在一起
tft.setTextSize(2); //设置字体大小
设置文本大小可以放大字体的显示,但是字体的"分辨率"是不会变的
// 设置文本大小,文本大小范围为 1~7 的整数
void setTextSize(uint8_t size);
4.
tft.print("Hello World!"); // 显示字体
tft.print("Hello World!");
5.
tft.printf, tft.println //显示字体
特别注意: 字库7是仿7段数码屏的样式
绘制文字相关API
- 绘制字符串(居左)
int16_t drawString(const String &string, int32_t x, int32_t y)
int16_t drawString(const char *string, int32_t x, int32_t y)
int16_t drawString(const String &string, int32_t x, int32_t y, uint8_t font)
int16_t drawString(const char *string, int32_t x, int32_t y, uint8_t font)
- 绘制字符串(居中)
int16_t drawCentreString(const char *string, int32_t x, int32_t y, uint8_t font) int16_t drawCentreString(const String &string, int32_t x, int32_t y, uint8_t font)
- 绘制字符串(居右)
int16_t drawRightString(const char *string, int32_t x, int32_t y, uint8_t font) int16_t drawRightString(const String &string, int32_t x, int32_t y, uint8_t font)
- 绘制字符
int16_t drawChar(uint16_t uniCode, int32_t x, int32_t y) int16_t drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t font) void drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32_t bg, uint8_tsize)
- 绘制浮点数
int16_t TFT_eSPI::drawFloat(float floatNumber, uint8_t decimal, int32_t x, int32_t y) int16_t TFT_eSPI::drawFloat(float floatNumber, uint8_t decimal, int32_t x, int32_t y, uint8_t font) tft.drawFloat(3.124, 4, 0,0,4);
- 绘制数字
int16_t drawNumber(long intNumber, int32_t x, int32_t y) int16_t drawNumber(long intNumber, int32_t x, int32_t y, uint8_t font)
绘制几何图形
- 画点
void drawPixel(int32_t x, int32_t y, uint32_t color)
2.画线
void drawLine(int32_t xs, int32_t ys, int32_t xe, int32_t ye, uint32_t color)
3.画横线(快速)
void drawFastHLine(int32_t x, int32_t y, int32_t w, uint32_t color)
4.画竖线(快速)
void drawFastVLine(int32_t x, int32_t y, int32_t h, uint32_t color)
- 画空心圆
tft.drawCircle(100,100,50,TFT_RED);
- 画实心圆
void fillCircle(int32_t x, int32_t y, int32_t r, uint32_t color)
- 画空心椭圆
tft.drawEllipse(100,100,100,60,TFT_GREENYELLOW);
- 画实心椭圆
void drawRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
- 画空心矩形
void drawRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
- 画实心矩形
void fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
- 画空心圆角矩形
void drawRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint32_t color)
- 画实心圆角矩形
void fillRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint32_t color)
- 画空心三角形
void drawTriangle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3, int32_t y3, uint32_t color)
- 画实心三角形
void fillTriangle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3, int32_t y3, uint32_t color)
图片显示相关
- 显示BMP图片
void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor) void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor, uint16_t bgcolor)
- XBM
xbm是一种简单的双色图片位图格式,在早期的cgi中运用较多,目前多用于计数器上在线XBM制作工具:
https://www.online-utility.org/image/convert/to/XBMvoid drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor) void drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t fgcolor, uint16_t bgcolor)
- 显示图片
void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data) void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data) void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint16_t *data, uint16_t transparent) void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t *data, uint16_t transparent) void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *data, bool bpp8 = true, uint16_t *cmap = (uint16_t *)nullptr) void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t *data, uint8_t transparent, bo
3 To Do’s Before Opening A New Bank Account 다바오 키즈 호텔
cheap finasteride pills – alfuzosin price buy generic alfuzosin 10 mg
lasix online pharmacy
can i buy albuterol
The casino floor is split over two floors with a smoking casino on the ground floor and a non-smoking mezzanine floor too. The casino is modern, lively, colourful, and packed full of music and movie memorabilia like all Hard Rock resorts. The fun is just a touch screen away when you play on the Grande Vegas mobile casino. This mobile casino has a full array of all the best games, specially adapted for your phone and or tablet. No matter what your favorite game is, this top casino sites mobile version has what you’re looking for. Whatever you win is added to your casino bonus balance. Miami Club Casino offers a variety of convenient deposit and withdrawal options for players. For making deposits, players can choose from methods such as Cheque, EcoCard, EcoPayz, Neteller, and Skrill. When it comes to withdrawals, players have the option to use Bank Wire Transfer, Cheque, ECO Card, Neteller, or Skrill. These options provide flexibility and ease of use for managing funds at the casino.
http://forum.dmec.vn/index.php?members/launehence1984.66626/
High 5 Casino is another free online casino that allows you to redeem real money prizes. It boasts a game library with over 1200 free slots and other casino games, that you can play without depositing a single dollar. GSN Casino Slots Free Coins: GSN Casino free coins for sweet slots and awesome bingo games! Also play poker and dozens of other free casino games that promises fun at your fingertips. Mobile for Android and iOS. Play on Facebook! Yes! You come to the right fansite that is friendly, a one-stop source of your HOF needs. The fansite ultimate goal is to satisfy your gaming by giving away HOF freebies, daily free coins and free spins, free gifts, bonus and rewards among others, that comes frequently all through the day. What more is we also provided legitmate information and updates about HOF. We make sure to update regularly the House of Freebies links and other related freebies that are posted on this fansite. We also gives relevant information that may be helpful in your favorite game.
lyrica drug
augmentin 250 5 mg
roche accutane
terazosin 5mg usa – purchase hytrin generic priligy price
valtrex online purchase
accutane.com
baclofen 10mg tab cost
drug flomax
buy brand name synthroid online
propecia tablets for sale
how much is over the counter diflucan
buy oxcarbazepine without prescription – oxcarbazepine 600mg uk purchase synthroid sale
diflucan for sale
where can i get vermox
order imusporin eye drops – order colcrys for sale buy gloperba for sale
buy calcort medication – order brimonidine online where to buy brimonidine without a prescription
pp wa keren perempuan
Hello there! Do you use Twitter? I’d like to follow you if that would be ok.
I’m undoubtedly enjoying your blog and look forward
to new updates.
Профессиональный сервисный центр по ремонту бытовой техники с выездом на дом.
Мы предлагаем: сервисные центры в москве
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
It was a surprise to him that a realm that had not been broken through after 10, 000 years of cultivation actually broke through at this time priligy over the counter Gamal and Brotherhood leaders put the death toll much higher, with more than 120 dead
Hi there to all, the contents existing at this web
page are in fact remarkable for people experience, well,
keep up the good work fellows.
Профессиональный сервисный центр по ремонту компьютеров и ноутбуков в Москве.
Мы предлагаем: ремонт ноутбуков apple москва
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
I’m not sure why but this blog is loading extremely slow for me.
Is anyone else having this issue or is it a problem on my end?
I’ll check back later on and see if the problem still exists.
Snasdxxxax.Snasdxxxax
This article offers clear idea designed for the new users of blogging, that truly
how to do blogging and site-building.
I really appreciate this post. I have been looking all over for this! Thank goodness I found it on Bing. You have made my day! Thanks again!
We recommend exploring the best quotes collections: Unconditional Love Quotes From Great People