feat: prevent full rotation to preserve mecanic
This commit is contained in:
parent
5f0235eec7
commit
397eed8080
17
turret.cpp
17
turret.cpp
|
|
@ -1,5 +1,6 @@
|
||||||
#include "turret.h"
|
#include "turret.h"
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
#include "math.h"
|
||||||
#include "maths.h"
|
#include "maths.h"
|
||||||
#include <kissStepper.h>
|
#include <kissStepper.h>
|
||||||
|
|
||||||
|
|
@ -138,9 +139,19 @@ Turret &Turret::moveTo(double x, double y, double z, Unit unit) {
|
||||||
angleToStep(_step_ratio, vec2<double>(degToRad(x), degToRad(y)), step);
|
angleToStep(_step_ratio, vec2<double>(degToRad(x), degToRad(y)), step);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO min(valueI, -_homeI);
|
long maxDeltaStepX = _step_ratio.x * M_PI_2;
|
||||||
_stepper.x.prepareMove(_zero.x + step.x);
|
long maxDeltaStepY = _step_ratio.y * M_PI_2;
|
||||||
_stepper.y.prepareMove(_zero.y + step.y);
|
|
||||||
|
// force move from -90° to 90° avoiding backside,
|
||||||
|
// if move > 180° skip the full turn a start at -90°,
|
||||||
|
// same in the other direction
|
||||||
|
long stepX = constrain(step.x % maxDeltaStepX, -(maxDeltaStepX >> 2),
|
||||||
|
(maxDeltaStepX >> 2));
|
||||||
|
long stepY = constrain(step.y % maxDeltaStepY, -(maxDeltaStepY >> 2),
|
||||||
|
(maxDeltaStepY >> 2));
|
||||||
|
|
||||||
|
_stepper.x.prepareMove(_zero.x + stepX);
|
||||||
|
_stepper.y.prepareMove(_zero.y + stepY);
|
||||||
|
|
||||||
bool xStop = false;
|
bool xStop = false;
|
||||||
bool yStop = false;
|
bool yStop = false;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue