2

我正在尝试使用Arduino 的 CapSense 库。但是,我无法运行包中包含的名为“CapSenseSketch”的示例。当我尝试打开文件并运行它时(我已经尝试过 Arduino 1.0 和 1.0.1),我收到一个编译器错误,上面写着“CapSense 没有命名类型”,而且

CapSenseSketch.cpp:1:22: error: CapSense.h: No such file or directory
CapSenseSketch:11: error: 'CapSense' does not name a type
CapSenseSketch:12: error: 'CapSense' does not name a type
CapSenseSketch:13: error: 'CapSense' does not name a type
CapSenseSketch.cpp: In function 'void setup()':
CapSenseSketch:17: error: 'cs_4_2' was not declared in this scope
CapSenseSketch.cpp: In function 'void loop()':
CapSenseSketch:24: error: 'cs_4_2' was not declared in this scope
CapSenseSketch:25: error: 'cs_4_6' was not declared in this scope
CapSenseSketch:26: error: 'cs_4_8' was not declared in this scope

代码顶部有一个包含语句,

#include <CapSense.h>

我认为这会是问题所在,所以我将括号改为引号,但仍然出现错误提示“编译错误”并且:

CapSenseSketch.cpp.o: In function `__static_initialization_and_destruction_0':
CapSenseSketch.cpp:15: undefined reference to `CapSense::CapSense(unsigned char, unsigned char)'
CapSenseSketch.cpp:16: undefined reference to `CapSense::CapSense(unsigned char, unsigned char)'
CapSenseSketch.cpp:17: undefined reference to `CapSense::CapSense(unsigned char, unsigned char)'
CapSenseSketch.cpp.o: In function `loop':
CapSenseSketch.cpp:28: undefined reference to `CapSense::capSense(unsigned char)'
CapSenseSketch.cpp:29: undefined reference to `CapSense::capSense(unsigned char)'
CapSenseSketch.cpp:30: undefined reference to `CapSense::capSense(unsigned char)'
CapSenseSketch.cpp.o: In function `setup':
CapSenseSketch.cpp:21: undefined reference to `CapSense::set_CS_AutocaL_Millis(unsigned long)'

有任何想法吗?我曾在另一台计算机上使用 CapSense 并将括号更改为引号当时效果很好,但现在它似乎并没有做太多。

4

1 回答 1

3

显然,包括外部文件在 arduino ide 中的工作方式有点不同。仅仅在代码顶部有一个包含语句是不够的,您必须手动转到草图>为要使用的每个外部文件添加文件。就我而言,我只对我尝试使用的两个文件中的一个进行了此操作。

于 2012-07-26T13:55:51.187 回答