Skip to content

armgit / flix

Public Imported from GitHub
0

Making an ESP32-based quadcopter from scratch

Make it possible to unassign motor pin using -1 parameter value

Oleg Kalachev1fafc27b393c
diff --git a/flix/motors.ino b/flix/motors.ino
index b1a1206..1540ac4 100644
--- a/flix/motors.ino
+++ b/flix/motors.ino
@@ -20,6 +20,7 @@ void setupMotors() {
print("Setup Motors\n");
// Configure pins
for (int i = 0; i < 4; i++) {
+ if (motorPins[i] < 0) continue; // skip unassigned motors
ledcAttach(motorPins[i], pwmFrequency, pwmResolution);
pwmFrequency = ledcChangeFrequency(motorPins[i], pwmFrequency, pwmResolution); // when reconfiguring
}
@@ -29,6 +30,7 @@ void setupMotors() {
void sendMotors() {
for (int i = 0; i < 4; i++) {
+ if (motorPins[i] < 0) continue; // skip unassigned motors
ledcWrite(motorPins[i], getDutyCycle(motors[i]));
}
}