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

This commit is contained in:
Oleg Kalachev
2026-05-30 16:57:27 +03:00
parent faca48ced3
commit 1fafc27b39
+2
View File
@@ -20,6 +20,7 @@ void setupMotors() {
print("Setup Motors\n"); print("Setup Motors\n");
// Configure pins // Configure pins
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (motorPins[i] < 0) continue; // skip unassigned motors
ledcAttach(motorPins[i], pwmFrequency, pwmResolution); ledcAttach(motorPins[i], pwmFrequency, pwmResolution);
pwmFrequency = ledcChangeFrequency(motorPins[i], pwmFrequency, pwmResolution); // when reconfiguring pwmFrequency = ledcChangeFrequency(motorPins[i], pwmFrequency, pwmResolution); // when reconfiguring
} }
@@ -29,6 +30,7 @@ void setupMotors() {
void sendMotors() { void sendMotors() {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (motorPins[i] < 0) continue; // skip unassigned motors
ledcWrite(motorPins[i], getDutyCycle(motors[i])); ledcWrite(motorPins[i], getDutyCycle(motors[i]));
} }
} }