kinematics

This commit is contained in:
PROFERIS - Mi³osz Stocki
2026-07-08 13:12:12 +02:00
parent 92820e8a15
commit cf71803fc4
3 changed files with 23 additions and 14 deletions
+19 -6
View File
@@ -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>