Making an ESP32-based quadcopter from scratch
Python arduinoautopilotcontrol-theorydroneesp32flight-controlflight-controllermavlinkquadcopterquadcopter-firmwareuav
Update ESP32 Arduino Core to v3.0.3
Oleg Kalacheve993dde3552b
diff --git a/Makefile b/Makefileindex 45a1edf..c88cd4c 100644--- a/Makefile+++ b/Makefile@@ -13,7 +13,7 @@ monitor:dependencies .dependencies:arduino-cli core update-index --config-file arduino-cli.yaml- arduino-cli core install esp32:[email protected] --config-file arduino-cli.yaml+ arduino-cli core install esp32:[email protected] --config-file arduino-cli.yamlarduino-cli lib update-indexarduino-cli lib install "FlixPeriph"arduino-cli lib install "MAVLink"@2.0.1diff --git a/flix/motors.ino b/flix/motors.inoindex 9d35445..27897c4 100644--- a/flix/motors.ino+++ b/flix/motors.ino@@ -20,17 +20,11 @@void setupMotors() {Serial.println("Setup Motors");- // configure PWM channels- ledcSetup(0, PWM_FREQUENCY, PWM_RESOLUTION);- ledcSetup(1, PWM_FREQUENCY, PWM_RESOLUTION);- ledcSetup(2, PWM_FREQUENCY, PWM_RESOLUTION);- ledcSetup(3, PWM_FREQUENCY, PWM_RESOLUTION);-- // attach channels to motor pins- ledcAttachPin(MOTOR_0_PIN, 0);- ledcAttachPin(MOTOR_1_PIN, 1);- ledcAttachPin(MOTOR_2_PIN, 2);- ledcAttachPin(MOTOR_3_PIN, 3);+ // configure pins+ ledcAttach(MOTOR_0_PIN, PWM_FREQUENCY, PWM_RESOLUTION);+ ledcAttach(MOTOR_1_PIN, PWM_FREQUENCY, PWM_RESOLUTION);+ ledcAttach(MOTOR_2_PIN, PWM_FREQUENCY, PWM_RESOLUTION);+ ledcAttach(MOTOR_3_PIN, PWM_FREQUENCY, PWM_RESOLUTION);sendMotors();Serial.println("Motors initialized");@@ -51,10 +45,10 @@ uint8_t pwmToDutyCycle(uint16_t pwm) {}void sendMotors() {- ledcWrite(0, pwmToDutyCycle(getPWM(motors[0], 0)));- ledcWrite(1, pwmToDutyCycle(getPWM(motors[1], 1)));- ledcWrite(2, pwmToDutyCycle(getPWM(motors[2], 2)));- ledcWrite(3, pwmToDutyCycle(getPWM(motors[3], 3)));+ ledcWrite(MOTOR_0_PIN, pwmToDutyCycle(getPWM(motors[0], 0)));+ ledcWrite(MOTOR_1_PIN, pwmToDutyCycle(getPWM(motors[1], 1)));+ ledcWrite(MOTOR_2_PIN, pwmToDutyCycle(getPWM(motors[2], 2)));+ ledcWrite(MOTOR_3_PIN, pwmToDutyCycle(getPWM(motors[3], 3)));}void fullMotorTest(int n, bool reverse) {diff --git a/flix/rc.ino b/flix/rc.inoindex 69f7574..4d846de 100644--- a/flix/rc.ino+++ b/flix/rc.ino@@ -9,7 +9,7 @@int channelNeutral[] = {995, 883, 200, 972, 512, 512};int channelMax[] = {1651, 1540, 1713, 1630, 1472, 1472};-SBUS RC(Serial2);+SBUS RC(Serial2, 16, 17); // NOTE: remove pin numbers (16, 17) if you use the new default pins for Serial2 (4, 25)void setupRC() {Serial.println("Setup RC");diff --git a/gazebo/SBUS.h b/gazebo/SBUS.hindex 8d56d45..f97fa12 100644--- a/gazebo/SBUS.h+++ b/gazebo/SBUS.h@@ -12,6 +12,7 @@ struct SBUSData {class SBUS {public:SBUS(HardwareSerial& bus, const bool inv = true) {};+ SBUS(HardwareSerial& bus, const int8_t rxpin, const int8_t txpin, const bool inv = true) {};void begin() {};bool read() { return joystickGet(); };SBUSData data() {