Skip to content

armgit / flix

Public Imported from GitHub
0

Making an ESP32-based quadcopter from scratch

Fix getDutyCycle return type to make it possible to increase resolution

Oleg Kalachev3088ade74344
diff --git a/flix/motors.ino b/flix/motors.ino
index 84f0908..770a0fb 100644
--- a/flix/motors.ino
+++ b/flix/motors.ino
@@ -27,7 +27,7 @@ void setupMotors() {
Serial.println("Motors initialized");
}
-uint8_t getDutyCycle(float value) {
+int getDutyCycle(float value) {
value = constrain(value, 0, 1);
float pwm = mapff(value, 0, 1, PWM_MIN, PWM_MAX);
float duty = mapff(pwm, 0, 1000000 / PWM_FREQUENCY, 0, (1 << PWM_RESOLUTION) - 1);