使用PowerPoint_to_sketch生成的ino文件编译ESP32时出错求助
ESP32 搭配320x240 TFT触摸屏编译PPT生成代码报错
我用PowerPoint_to_sketch宏从演示文件生成了ino文件,按样例规则操作成功生成,但编译用于ESP32和320x240 TFT触摸屏时出现无法解决的错误(已确认TFT_eSPI库配置正确)。
错误信息
Indexing .pio\build\esp32doit-devkit-v1\lib37e\libTFT_eSPI.a src/main.cpp:31:33: error: no matching function for call to 'TFT_eSPI_ext::TFT_eSPI_ext()' TFT_eSPI_ext tft = TFT_eSPI_ext(); ^ In file included from lib/PowerPoint_to_sketch/ILI9341_t3.h:2, from lib/PowerPoint_to_sketch/font_Arial.h:4, from src/main.cpp:24: lib/PowerPoint_to_sketch/TFT_eSPI_ext.h:36:3: note: candidate: 'TFT_eSPI_ext::TFT_eSPI_ext(TFT_eSPI*)' TFT_eSPI_ext(TFT_eSPI *tft) ^~~~~~~~~~~~ lib/PowerPoint_to_sketch/TFT_eSPI_ext.h:36:3: note: candidate expects 1 argument, 0 provided lib/PowerPoint_to_sketch/TFT_eSPI_ext.h:29:7: note: candidate: 'TFT_eSPI_ext::TFT_eSPI_ext(const TFT_eSPI_ext&)' class TFT_eSPI_ext : public TFT_eSPI ^~~~~~~~~~~~ lib/PowerPoint_to_sketch/TFT_eSPI_ext.h:29:7: note: candidate expects 1 argument, 0 provided src/main.cpp: In function 'void setup()': src/main.cpp:75:44: warning: unsigned conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} changes value from '65536' to '0' [-Woverflow] Button4.initButton(&tft,154, 54, 222, 5, 0x10000, 0xFFFF, 0xFFFF, buttonLabel4, 2); ^~~~~~~ src/main.cpp:76:46: warning: unsigned conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} changes value from '65536' to '0' [-Woverflow] Button5.initButton(&tft,154, 112, 193, 31, 0x10000, 0xC2C2, 0xFFFF, buttonLabel5, 2); ^~~~~~~ src/main.cpp:77:46: warning: unsigned conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} changes value from '65536' to '0' [-Woverflow] Button6.initButton(&tft,154, 168, 193, 31, 0x10000, 0xC2C2, 0xFFFF, buttonLabel6, 2); ^~~~~~~ src/main.cpp:78:44: warning: unsigned conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} changes value from '65536' to '0' [-Woverflow] Button7.initButton(&tft,294, 24, 37, 35, 0x10000, 0xF800, 0xFFFF, buttonLabel7, 2); ^~~~~~~ src/main.cpp:79:45: warning: unsigned conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} changes value from '65536' to '0' [-Woverflow] Button8.initButton(&tft,93, 110, 110, 31, 0x10000, 0xC2C2, 0xFFFF, buttonLabel8, 2); ^~~~~~~ src/main.cpp:80:46: warning: unsigned conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} changes value from '65536' to '0' [-Woverflow] Button9.initButton(&tft,215, 112, 110, 31, 0x10000, 0xC2C2, 0xFFFF, buttonLabel9, 2); ^~~~~~~ src/main.cpp:81:46: warning: unsigned conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} changes value from '65536' to '0' [-Woverflow] Button10.initButton(&tft,93, 170, 110, 31, 0x10000, 0xC2C2, 0xFFFF, buttonLabel10, 2); ^~~~~~~ src/main.cpp:82:47: warning: unsigned conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} changes value from '65536' to '0' [-Woverflow] Button11.initButton(&tft,215, 170, 110, 31, 0x10000, 0xC2C2, 0xFFFF, buttonLabel11, 2); ^~~~~~~ src/main.cpp:83:45: warning: unsigned conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} changes value from '65536' to '0' [-Woverflow] Button12.initButton(&tft,154, 54, 222, 5, 0x10000, 0xFFFF, 0xFFFF, buttonLabel12, 2); ^~~~~~~ src/main.cpp:84:45: warning: unsigned conversion from 'int' to 'uint16_t' {aka 'short unsigned int'} changes value from '65536' to '0' [-Woverflow] Button13.initButton(&tft,294, 24, 37, 35, 0x10000, 0xF800, 0xFFFF, buttonLabel13, 2); ^~~~~~~ src/main.cpp: In function 'void loop()': src/main.cpp:92:3: error: 'Screen1' was not declared in this scope Screen1(); ^~~~~~~ src/main.cpp:92:3: note: suggested alternative: '_reent' Screen1(); ^~~~~~~ _reent src/main.cpp:97:3: error: 'Screen2' was not declared in this scope Screen2(); ^~~~~~~ src/main.cpp:97:3: note: suggested alternative: '_reent' Screen2(); ^~~~~~~ _reent src/main.cpp:102:3: error: 'Screen3' was not declared in this scope Screen3(); ^~~~~~~ src/main.cpp:102:3: note: suggested alternative: '_reent' Screen3(); ^~~~~~~ _reent Compiling .pio\build\esp32doit-devkit-v1\libc11\PowerPoint_to_sketch\font_ArialBold.c.o *** [.pio\build\esp32doit-devkit-v1\src\main.cpp.o] Error 1
相关代码片段
#include <font_Arial.h> #include <font_ArialBold.h> #include <font_ArialItalic.h> #include <font_ArialBoldItalic.h> #include <SPI.h> #include <TFT_eSPI_ext.h> TFT_eSPI_ext tft = TFT_eSPI_ext();
解决步骤
1. 修复TFT_eSPI_ext初始化错误
TFT_eSPI_ext没有无参构造函数,必须传入一个TFT_eSPI对象指针。修改代码:
#include <font_Arial.h> #include <font_ArialBold.h> #include <font_ArialItalic.h> #include <font_ArialBoldItalic.h> #include <SPI.h> #include <TFT_eSPI.h> #include <TFT_eSPI_ext.h> TFT_eSPI tft_base = TFT_eSPI(); TFT_eSPI_ext tft = TFT_eSPI_ext(&tft_base);
2. 修复颜色值溢出警告
0x10000超出了uint16_t(16位无符号整数)的最大值0xFFFF,会被自动转为0。将所有0x10000替换为合法的16位颜色值,比如黑色0x0000:
Button4.initButton(&tft,154, 54, 222, 5, 0x0000, 0xFFFF, 0xFFFF, buttonLabel4, 2);
3. 修复Screen函数未定义错误
检查生成的代码是否包含Screen1()、Screen2()、Screen3()的函数定义:
- 若宏生成时遗漏,重新运行PowerPoint_to_sketch宏并确保所有幻灯片对应的屏幕函数被生成
- 若代码拆分到多个文件,需将包含这些函数的文件正确引入到项目中
内容的提问来源于stack exchange,提问作者Sina M
相关产品推荐
相关产品推荐

