🎨 Clamp servo pwm
This commit is contained in:
@@ -92,10 +92,7 @@ class ServoController : public StatefulService<ServoSettings> {
|
||||
auto &servo = state().servos[i];
|
||||
float angle = servo.direction * angles[i] + servo.centerAngle;
|
||||
uint16_t pwm = angle * servo.conversion + servo.centerPwm;
|
||||
if (pwm < 125 || pwm > 600) {
|
||||
continue;
|
||||
}
|
||||
pwms[i] = pwm;
|
||||
pwms[i] = pwm = std::clamp<uint16_t>(pwm, 125, 600);
|
||||
}
|
||||
_pca.setMultiplePWM(pwms, 12);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user