kinematics
This commit is contained in:
+19
-6
@@ -118,19 +118,32 @@ class CmdCallbacks : public BLECharacteristicCallbacks {
|
||||
|
||||
// ─── Command parser ───────────────────────────────────────────────
|
||||
void parseCommand(const String &cmd) {
|
||||
// S1+<n> or S1-<n>
|
||||
// S1+<n> or S1-<n> (Relative)
|
||||
if (cmd.startsWith("S1") && cmd.length() > 2) {
|
||||
long steps =
|
||||
cmd.substring(2).toInt(); // '+' or '-' prefix handled by toInt()
|
||||
long steps = cmd.substring(2).toInt();
|
||||
stepper1.move(steps);
|
||||
Serial.printf("[S1] Move %+ld steps\n", steps);
|
||||
Serial.printf("[S1] Move relative %+ld steps\n", steps);
|
||||
return;
|
||||
}
|
||||
// S2+<n> or S2-<n>
|
||||
// S2+<n> or S2-<n> (Relative)
|
||||
if (cmd.startsWith("S2") && cmd.length() > 2) {
|
||||
long steps = cmd.substring(2).toInt();
|
||||
stepper2.move(steps);
|
||||
Serial.printf("[S2] Move %+ld steps\n", steps);
|
||||
Serial.printf("[S2] Move relative %+ld steps\n", steps);
|
||||
return;
|
||||
}
|
||||
// X1:<n> (Absolute)
|
||||
if (cmd.startsWith("X1:")) {
|
||||
long target = cmd.substring(3).toInt();
|
||||
stepper1.moveTo(target);
|
||||
Serial.printf("[S1] Move absolute to %ld\n", target);
|
||||
return;
|
||||
}
|
||||
// X2:<n> (Absolute)
|
||||
if (cmd.startsWith("X2:")) {
|
||||
long target = cmd.substring(3).toInt();
|
||||
stepper2.moveTo(target);
|
||||
Serial.printf("[S2] Move absolute to %ld\n", target);
|
||||
return;
|
||||
}
|
||||
// SPD:<n>
|
||||
|
||||
Reference in New Issue
Block a user