kin
This commit is contained in:
@@ -198,13 +198,11 @@ async function moveToXY(targetX, targetY) {
|
||||
const newSteps1 = IK.radToSteps(theta1);
|
||||
const newSteps2 = IK.radToSteps(theta2);
|
||||
|
||||
const cmd1 = `X1:${newSteps1}`;
|
||||
const cmd2 = `X2:${newSteps2}`;
|
||||
const cmd = `X:${newSteps1},${newSteps2}`;
|
||||
|
||||
if (BLE.isConnected()) {
|
||||
try {
|
||||
await BLE.write(cmd1);
|
||||
await BLE.write(cmd2);
|
||||
await BLE.write(cmd);
|
||||
// Do not update steps1/steps2 here; let the P: notify handler update the UI smoothly
|
||||
} catch (e) {
|
||||
UI.log(`BLE error: ${e.message}`, 'error');
|
||||
@@ -213,7 +211,7 @@ async function moveToXY(targetX, targetY) {
|
||||
steps1 = newSteps1;
|
||||
steps2 = newSteps2;
|
||||
renderArm(theta1, theta2);
|
||||
const simMsg = `[sim] IK→ θ1=${IK.radToDeg(theta1).toFixed(1)}° θ2=${IK.radToDeg(theta2).toFixed(1)}° | ${cmd1} ${cmd2}`;
|
||||
const simMsg = `[sim] IK→ θ1=${IK.radToDeg(theta1).toFixed(1)}° θ2=${IK.radToDeg(theta2).toFixed(1)}° | ${cmd}`;
|
||||
console.log(simMsg);
|
||||
UI.log(simMsg, 'info');
|
||||
}
|
||||
|
||||
@@ -67,15 +67,13 @@ export default {
|
||||
const newSteps1 = IK.radToSteps(res.theta1);
|
||||
const newSteps2 = IK.radToSteps(res.theta2);
|
||||
|
||||
const cmd1 = `X1:${newSteps1}`;
|
||||
const cmd2 = `X2:${newSteps2}`;
|
||||
const cmd = `X:${newSteps1},${newSteps2}`;
|
||||
|
||||
UI.log(`Seq step: ${label}`, 'info');
|
||||
|
||||
if (BLE.isConnected()) {
|
||||
try {
|
||||
await BLE.write(cmd1);
|
||||
await BLE.write(cmd2);
|
||||
await BLE.write(cmd);
|
||||
} catch (e) {
|
||||
UI.log(`BLE error: ${e.message}`, 'error');
|
||||
isRunning = false;
|
||||
@@ -88,7 +86,7 @@ export default {
|
||||
if (onStepComplete) {
|
||||
onStepComplete(steps1, steps2);
|
||||
}
|
||||
console.log(`[sim] ${cmd1} ${cmd2}`);
|
||||
console.log(`[sim] ${cmd}`);
|
||||
}
|
||||
|
||||
// Wait for delay
|
||||
|
||||
Reference in New Issue
Block a user