@@ -105,6 +105,7 @@ Response CommandProcessor::HandleCommand(Command& command) const
105105 if (command.Verb == " FR" ) return HandleFR (command); // Read firmware version
106106 if (command.Verb == " GA" ) return HandleGA (command); // Goto Azimuth (rotator only)
107107 if (command.Verb == " GH" ) return HandleGH (command); // Goto Home Sensor (rotator only)
108+ if (command.Verb == " GS" ) return HandleGS (command); // Goto step position (rotator only)
108109 if (command.Verb == " HR" ) return HandleHR (command); // Home position Read (rotator only)
109110 if (command.Verb == " HW" ) return HandleHW (command); // Home position Write (rotator only)
110111 if (command.Verb == " SW" ) return HandleSW (command); // Stop motor (emergency stop)
@@ -134,19 +135,30 @@ Response CommandProcessor::HandleAR(Command& command) const
134135 }
135136
136137
138+ void CommandProcessor::rotateToMicrostepPosition (const int32_t target) const {
139+ const auto currentPosition = rotator.getCurrentPosition ();
140+ const auto delta = target - currentPosition;
141+ const auto direction = sgn (delta);
142+ if (abs (delta) >= settings.deadZone )
143+ {
144+ HomeSensor::cancelHoming ();
145+ sendDirection (direction);
146+ rotator.moveToPosition (target);
147+ }
148+ }
149+
137150Response CommandProcessor::HandleGA (Command& command) const
138151 {
139152 const auto microstepsPerDegree = settings.home .microstepsPerRotation / 360.0 ;
140153 const auto target = targetStepPosition (command.StepPosition * microstepsPerDegree);
141- const auto currentPosition = rotator.getCurrentPosition ();
142- const auto delta = target - currentPosition;
143- const auto direction = sgn (delta);
144- if (abs (delta) >= settings.deadZone )
145- {
146- HomeSensor::cancelHoming ();
147- sendDirection (direction);
148- rotator.moveToPosition (target);
149- }
154+ rotateToMicrostepPosition (target);
155+ return Response::FromSuccessfulCommand (command);
156+ }
157+
158+ Response CommandProcessor::HandleGS (Command& command) const
159+ {
160+ const auto target = targetStepPosition (stepsToMicrosteps (command.StepPosition ));
161+ rotateToMicrostepPosition (target);
150162 return Response::FromSuccessfulCommand (command);
151163 }
152164
0 commit comments