Skip to content
Snippets Groups Projects
Commit 52a77700 authored by Alberto Nidasio's avatar Alberto Nidasio
Browse files

[Servo] Implemented position limitation

parent 5a5d5b5a
No related branches found
No related tags found
No related merge requests found
...@@ -61,6 +61,11 @@ void Servo::disable() {} ...@@ -61,6 +61,11 @@ void Servo::disable() {}
void Servo::setPosition(float position) void Servo::setPosition(float position)
{ {
if (position < 0)
position = 0;
else if (position > 1)
position = 1;
float pulse = minPulse + (maxPulse - minPulse) * position; float pulse = minPulse + (maxPulse - minPulse) * position;
float dutyCycle = pulse * frequency / 1000000.0f; float dutyCycle = pulse * frequency / 1000000.0f;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment