gpt4 book ai didi

c++ - 不能使用 platformio 在库中包含 i2s.h

转载 作者:行者123 更新时间:2023-11-30 03:15:43 32 4
gpt4 key购买 nike

如果我尝试在库中执行它,我无法包含它,但如果我在 main.cpp

中执行它,它工作正常

这里是树的输出(文件夹结构)

.
├── include
│ └── README
├── lib
│ ├── Microphone
│ │ ├── Microphone.cpp
│ │ └── Microphone.h
│ └── README
├── platformio.ini
├── src
│ └── main.cpp
└── test
└── README

这里是main.cpp

#include <Arduino.h>

#include "Microphone.h"

void setup() {
// put your setup code here, to run once:
}

void loop() {
// put your main code here, to run repeatedly:
}

这里是 lib/Microphone.h

#include <i2s.h>

这里是lib/Microphone.cpp

#include "Microphone.h"

这里是platformio.ini

[env:d1_mini_lite]
platform = espressif8266
board = d1_mini_lite
framework = arduino

这是我在构建时遇到的错误

Processing d1_mini_lite (platform: espressif8266; board: d1_mini_lite; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini_lite.html
PLATFORM: Espressif 8266 2.2.2 > WeMos D1 mini Lite
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
PACKAGES: toolchain-xtensa 2.40802.190218 (4.8.2), tool-esptool 1.413.0 (4.13), tool-esptoolpy 1.20600.0 (2.6.0), framework-arduinoespressif8266 2.20502.0 (2.5.2)
LDF: Library Dependency Finder -> http://bit .ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 29 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Microphone>
Compiling .pio\build\d1_mini_lite\src\main.cpp.o
Generating LD script .pio\build\d1_mini_lite\ld\local.eagle.app.v6.common.ld
Compiling .pio\build\d1_mini_lite\libcaf\Microphone\Microphone.cpp.o
Archiving .pio\build\d1_mini_lite\libFrameworkArduinoVariant.a
Compiling .pio\build\d1_mini_lite\FrameworkArduino\Esp-frag.cpp.o
In file included from lib\Microphone\Microphone.h:1:0,
from lib\Microphone\Microphone.cpp:1:
C:\Users\Joe\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/i2s.h:46:19: error: variable or field 'i2s_set_rate' declared void
void i2s_set_rate(uint32_t rate);//Sample Rate in Hz (ex 44100, 48000)
^
C:\Users\Joe\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/i2s.h:46:19: error: 'uint32_t' was not declared in this scope
C:\Users\Joe\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/i2s.h:47:23: error: variable or field 'i2s_set_dividers' declared void
void i2s_set_dividers(uint8_t div1, uint8_t div2);//Direct control over output rate

...
Compiling .pio\build\d1_mini_lite\FrameworkArduino\Esp.cpp.o
Compiling .pio\build\d1_mini_lite\FrameworkArduino\FS.cpp.o
*** [.pio\build\d1_mini_lite\libcaf\Microphone\Microphone.cpp.o] Error 1
=============================================================================================== [ERROR] Took 1.67 seconds ===============================================================================================
The terminal process terminated with exit code: 1

我的设置

Name: PlatformIO IDE
Id: platformio.platformio-ide
Description: Development environment for IoT, Arduino, ARM mbed, Espressif (ESP8266/ESP32), AVR, RISC-V, STM32, PIC32, nRF51/nRF52, MSP430, MCS-51 (8051), FPGA, FreeRTOS, ESP-IDF, CMSIS, SPL
Version: 1.7.1
Publisher: PlatformIO
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=platformio.platformio-ide

为什么我无法从自定义库中导入?

最佳答案

我能够通过添加 #include <Arduino.h> 来解决它之前#include <i2s.h>Microphone.h并且工作得很好

关于c++ - 不能使用 platformio 在库中包含 i2s.h,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56829886/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com