error: expected ')' before numeric constant 6 | #定义 TFT_RST 8 6

问题描述 投票:0回答:0

在新的 pc.win 10 pro 上安装了 arduino 2.04。 添加了我的草图所需的所有库。 具体来说,Adafruit HX8357 v 1.1.15 Teensy 4 已连接到此显示器 https://www.adafruit.com/?q=hxd8357&sort=BestMatch

开始编写代码。

#include "Adafruit_HX8357.h"
#include <Bounce.h>

#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST 8 6
Adafruit_HX8357 tft = Adafruit_HX8357 (TFT_CS, TFT_DC, TFT_RST);

对此进行了验证/编译。 得到这个错误:

C:\Users\Stefan\AppData\Local\Temp\.arduinoIDE-unsaved202331-9772-phra3o.j87e8\sketch_apr1a\sketch_apr1a.ino:7:39: error: expected primary-expression before '(' token
    7 | Adafruit_HX8357 tft = Adafruit_HX8357 (TFT_CS, TFT_DC, TFT_RST);
      |                                       ^
C:\Users\Stefan\AppData\Local\Temp\.arduinoIDE-unsaved202331-9772-phra3o.j87e8\sketch_apr1a\sketch_apr1a.ino:6:19: error: expected ')' before numeric constant
    6 | #define TFT_RST 8 6
      |                   ^
C:\Users\Stefan\AppData\Local\Temp\.arduinoIDE-unsaved202331-9772-phra3o.j87e8\sketch_apr1a\sketch_apr1a.ino:7:56: note: in expansion of macro 'TFT_RST'
    7 | Adafruit_HX8357 tft = Adafruit_HX8357 (TFT_CS, TFT_DC, TFT_RST);
      |                                                        ^~~~~~~
C:\Users\Stefan\AppData\Local\Temp\.arduinoIDE-unsaved202331-9772-phra3o.j87e8\sketch_apr1a\sketch_apr1a.ino:7:39: note: to match this '('
    7 | Adafruit_HX8357 tft = Adafruit_HX8357 (TFT_CS, TFT_DC, TFT_RST);
      |                                       ^

exit status 1

Compilation error: expected primary-expression before '(' token

也许语法变了? 同样的代码在之前的机器上用 Arduino 1.89 编译得很好

编辑: 将#define TFT_RS 8 6 替换为#define TFT_RST 8, 6 给出这个错误:

c:/users/stefan/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Stefan\AppData\Local\Temp\arduino\sketches\FAF4EC7B25DF20D04735FE9464C6799E/..\..\cores\teensy_avr_teensy41_usb_serialhid,speed_600,opt_o2std,keys_en-us_300b8394b6e6311256a6e28440722b2d\core.a(main.cpp.o): in function `main':
C:\Users\Stefan\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.0\cores\teensy4/main.cpp:51: undefined reference to `setup'
c:/users/stefan/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Stefan\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.0\cores\teensy4/main.cpp:53: undefined reference to `loop'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

用#define TFT_RST (8, 6) 替换#define TFT_RS 8 6 给出这个错误:

C:\Users\Stefan\AppData\Local\Temp\.arduinoIDE-unsaved202331-9772-phra3o.j87e8\sketch_apr1a\sketch_apr1a.ino:6:18: warning: left operand of comma operator has no effect [-Wunused-value]
    6 | #define TFT_RST (8, 6)
      |                  ^
C:\Users\Stefan\AppData\Local\Temp\.arduinoIDE-unsaved202331-9772-phra3o.j87e8\sketch_apr1a\sketch_apr1a.ino:7:56: note: in expansion of macro 'TFT_RST'
    7 | Adafruit_HX8357 tft = Adafruit_HX8357 (TFT_CS, TFT_DC, TFT_RST);
      |                                                        ^~~~~~~
c:/users/stefan/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Stefan\AppData\Local\Temp\arduino\sketches\FAF4EC7B25DF20D04735FE9464C6799E/..\..\cores\teensy_avr_teensy41_usb_serialhid,speed_600,opt_o2std,keys_en-us_300b8394b6e6311256a6e28440722b2d\core.a(main.cpp.o): in function `main':
C:\Users\Stefan\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.0\cores\teensy4/main.cpp:51: undefined reference to `setup'
c:/users/stefan/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Stefan\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.58.0\cores\teensy4/main.cpp:53: undefined reference to `loop'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1
arduino-ide
© www.soinside.com 2019 - 2024. All rights reserved.