mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-27 01:56:14 +01:00
Remove unnecessary servo output demands.
If start and end position of a servo movement are identical, skip all but the last step.
This commit is contained in:
parent
ec503e7d3e
commit
5932b4d101
|
@ -196,6 +196,10 @@ void PCA9685::updatePosition(uint8_t pin) {
|
|||
struct ServoData *s = _servoData[pin];
|
||||
if (!s) return;
|
||||
if (s->numSteps == 0) return; // No animation in progress
|
||||
if (s->stepNumber == 0 && s->fromPosition == s->toPosition) {
|
||||
// No movement required, so go straight to final step
|
||||
s->stepNumber = s->numSteps;
|
||||
}
|
||||
if (s->stepNumber < s->numSteps) {
|
||||
// Animation in progress, reposition servo
|
||||
s->stepNumber++;
|
||||
|
|
Loading…
Reference in New Issue
Block a user