求帮忙,在arduino中编译一个现成的程序,在库文件安装完成的情况下,编译报错,以下为报错信息
In file included from C:\Users\李祖祎\OneDrive\桌面\ESPCar_fashe\ESPCar_fashe.ino:13:0:
c:\Users\����t\OneDrive\�ĵ�\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:64:24: error: conflicting declaration 'typedef int8_t prog_int8_t'
typedef int8_t prog_int8_t;
^
In file included from C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/WString.h:29:0,
from C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/Arduino.h:146,
from C:\Users\����t\AppData\Local\Temp\arduino\sketches\B5716108DB741043B1770932FCA1086B\sketch\ESPCar_fashe.ino.cpp:1:
C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/pgmspace.h:25:14: note: previous declaration as 'typedef char prog_int8_t'
typedef char prog_int8_t;
^
In file included from C:\Users\李祖祎\OneDrive\桌面\ESPCar_fashe\ESPCar_fashe.ino:13:0:
c:\Users\����t\OneDrive\�ĵ�\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:68:25: error: conflicting declaration 'typedef int32_t prog_int32_t'
typedef int32_t prog_int32_t;
^
In file included from C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/WString.h:29:0,
from C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/Arduino.h:146,
from C:\Users\����t\AppData\Local\Temp\arduino\sketches\B5716108DB741043B1770932FCA1086B\sketch\ESPCar_fashe.ino.cpp:1:
C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/pgmspace.h:29:14: note: previous declaration as 'typedef long int prog_int32_t'
typedef long prog_int32_t;
^
In file included from C:\Users\李祖祎\OneDrive\桌面\ESPCar_fashe\ESPCar_fashe.ino:13:0:
c:\Users\����t\OneDrive\�ĵ�\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:69:26: error: conflicting declaration 'typedef uint32_t prog_uint32_t'
typedef uint32_t prog_uint32_t;
^
In file included from C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/WString.h:29:0,
from C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/Arduino.h:146,
from C:\Users\����t\AppData\Local\Temp\arduino\sketches\B5716108DB741043B1770932FCA1086B\sketch\ESPCar_fashe.ino.cpp:1:
C:\Users\����t\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.5\cores\esp32/pgmspace.h:30:23: note: previous declaration as 'typedef long unsigned int prog_uint32_t'
typedef unsigned long prog_uint32_t;
^
exit status 1
Compilation error: exit status 1
以下为源代码
```c
```c
//B站找 :arduino捣鼓室 欢迎大家评论区一起交流!如有不足请大家指正 共同进步!网址:https://space.bilibili.com/307396549
//根据需要下载要的库 可以根据编译查看结果
//所有的库打包在这个连接下方 https://www.bilibili.com/video/BV1r34y147SL?spm_id_from=333.999.0.0
#include <esp_now.h>
#include <WiFi.h>
//需要的安装库
#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
#include "Wire.h"
#endif
// MPU control/status vars
MPU6050 mpu;
bool dmpReady = false; //
uint8_t devStatus; //
uint8_t fifoBuffer[64]; //
Quaternion q; // [w, x, y, z]
VectorFloat gravity; // [x, y, z]
float ypr[3]; // [yaw, pitch, roll]
// 记录MAC地址 // E0:5A:1B:75:36:6C
uint8_t receiverMacAddress[] = { 0xE0, 0x5A, 0x1B, 0x75, 0x36, 0x6C };
struct PacketData {
byte xAxisValue;
byte yAxisValue;
byte zAxisValue;
};
PacketData data;
// callback when data is sent
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
//Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Message sent" : "Message failed");
}
void setupMPU() {
// join I2C bus (I2Cdev library doesn't do this automatically)
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
Wire.begin();
Wire.setClock(400000); // 400kHz I2C clock. Comment this line if having compilation difficulties
#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
Fastwire::setup(400, true);
#endif
mpu.initialize();
devStatus = mpu.dmpInitialize();
// make sure it worked (returns 0 if so)
if (devStatus == 0) {
// Calibration Time: generate offsets and calibrate our MPU6050
mpu.CalibrateAccel(6);
mpu.CalibrateGyro(6);
mpu.setDMPEnabled(true);
dmpReady = true;
}
}
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
// Init ESP-NOW
if (esp_now_init() != ESP_OK) {
Serial.println("Error initializing ESP-NOW");
return;
} else {
Serial.println("Succes: Initialized ESP-NOW");
}
esp_now_register_send_cb(OnDataSent);
// Register peer
esp_now_peer_info_t peerInfo;
memcpy(peerInfo.peer_addr, receiverMacAddress, 6);
peerInfo.channel = 0;
peerInfo.encrypt = false;
// Add peer
if (esp_now_add_peer(&peerInfo) != ESP_OK) {
Serial.println("Failed to add peer");
return;
} else {
Serial.println("Succes: Added peer");
}
//This is to set up MPU6050 sensor
setupMPU();
}
void loop() {
// if programming failed, don't try to do anything
if (!dmpReady) return;
// read a packet from FIFO. Get the Latest packet
if (mpu.dmpGetCurrentFIFOPacket(fifoBuffer)) {
mpu.dmpGetQuaternion(&q, fifoBuffer);
mpu.dmpGetGravity(&gravity, &q);
mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
int xAxisValue = constrain(ypr[2] * 180 / M_PI, -90, 90);
int yAxisValue = constrain(ypr[1] * 180 / M_PI, -90, 90);
int zAxisValue = constrain(ypr[0] * 180 / M_PI, -90, 90);
data.xAxisValue = map(xAxisValue, -90, 90, 0, 254);
data.yAxisValue = map(yAxisValue, -90, 90, 0, 254);
data.zAxisValue = map(zAxisValue, -90, 90, 0, 254);
esp_err_t result = esp_now_send(receiverMacAddress, (uint8_t *)&data, sizeof(data));
String inputData = inputData + "values " + xAxisValue + " " + yAxisValue + " " + zAxisValue;
Serial.println(inputData);
delay(50);
}
}
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/470373757976136.png "#left")
```