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
buy bactrim 480mg online cheap – bactrim online buy tobrex drops
how much is flomax
Hello, Neat post. There’s a problem together with your web
site in internet explorer, may check this? IE still is
the market chief and a big element of other folks will omit your
great writing because of this problem.
buy amoxil no prescription
sildalis
buy acyclovir over the counter
order eukroma without prescription – where can i buy hydroquinone purchase dydrogesterone generic
provigil price canada
order dapagliflozin pills – buy cheap generic sinequan acarbose tablet
flomax generic for sale
order griseofulvin 250 mg generic – fulvicin generic order lopid 300 mg generic
tadacip 10 mg price
how much is vermox
A segurança e a confiabilidade deste site são incomparáveis. É um alívio saber que posso contar com ele para minhas necessidades online. Obrigado por manter os mais altos padrões!
buy enalapril 10mg generic – order doxazosin 2mg online cheap buy latanoprost online cheap
baclofen 10 mg tab
dramamine uk – order dramamine for sale buy generic actonel
uk pharmacy online modafinil
etodolac order online – purchase pletal pills order pletal 100mg online
feldene 20mg uk – exelon us oral exelon 3mg
buy 20 mg tadacip
purchase cipro
generic for valtrex
order propecia online no prescription
ciprofloxacin 250mg
buy clomiphene citrate online uk
diflucan otc canada
vermox uk price
augmentin 500 online
furosemide 40 mg price in india
valtrex best prices
order piracetam 800mg for sale – order sinemet 20mg generic sinemet online order
I’m not sure exactly why but this web site is loading very slow for
me. Is anyone else having this issue or is it a issue on my
end? I’ll check back later on and see if the problem still exists.
how much is diflucan over the counter
lyrica cap 100mg
buy dexamethasone without prescription
order hydrea – buy pentoxifylline no prescription buy generic robaxin
medication finasteride 5mg
Having read this I believed it was extremely
enlightening. I appreciate you taking the time and effort to put this short article together.
I once again find myself spending a significant amount of time both reading and posting comments.
But so what, it was still worthwhile!
Hey there! I know this is somewhat off topic but I was wondering if you knew where I could find a captcha
plugin for my comment form? I’m using the same blog platform as yours and I’m having problems finding one?
Thanks a lot! https://adsbookmark.com/story17455189/%D0%9F%D1%80%D0%BE%D1%81%D0%BC%D0%BE%D1%82%D1%80-%D0%BF%D1%80%D0%BE%D1%84%D0%B8%D0%BB%D1%8Fml
This Week’s Most Popular Stories About Best CSGO Opening Site counter-Strike Cases
modafinil buy in canada
albuterol cost in mexico
Sweet blog! I found it while browsing on Yahoo News. Do you have any tips on how to get listed in Yahoo News?
I’ve been trying for a while but I never seem to get there!
Appreciate it
buy generic divalproex for sale – mefloquine medication topamax medication
cialis pharmacy australia
disopyramide phosphate price – buy lyrica 150mg pills how to get chlorpromazine without a prescription
propecia us
order cyclophosphamide online – order cytoxan sale cheap vastarel without prescription
spironolactone online buy – buy revia medication buy revia 50 mg generic