improved logging

This commit is contained in:
PROFERIS - Mi³osz Stocki
2026-07-07 15:04:24 +02:00
parent 2e6530f354
commit c56dd1fbe7
2 changed files with 18 additions and 8 deletions
+3 -1
View File
@@ -300,7 +300,9 @@ async function executeMove(spot) {
UI.log(`BLE error: ${e.message}`, 'error');
}
} else {
UI.log(`[sim] ${cmd1} ${cmd2}`, 'info');
const simMsg = `[sim] ${cmd1} ${cmd2}`;
console.log(simMsg);
UI.log(simMsg, 'info');
}
}
+15 -7
View File
@@ -209,7 +209,9 @@ async function moveToXY(targetX, targetY) {
UI.log(`BLE error: ${e.message}`, 'error');
}
} else {
UI.log(`[sim] IK→ θ1=${IK.radToDeg(theta1).toFixed(1)}° θ2=${IK.radToDeg(theta2).toFixed(1)}° | ${cmd1} ${cmd2}`, 'info');
const simMsg = `[sim] IK→ θ1=${IK.radToDeg(theta1).toFixed(1)}° θ2=${IK.radToDeg(theta2).toFixed(1)}° | ${cmd1} ${cmd2}`;
console.log(simMsg);
UI.log(simMsg, 'info');
}
return true;
}
@@ -223,9 +225,12 @@ async function jogMotor(motor, delta) {
else steps2 += delta;
renderArmFromSteps();
const cmd = `S${motor}${delta >= 0 ? '+' : ''}${delta}`;
BLE.isConnected()
? await BLE.write(cmd).catch(e => UI.log(e.message, 'error'))
: UI.log(`[sim] ${cmd}`, 'info');
if (BLE.isConnected()) {
await BLE.write(cmd).catch(e => UI.log(e.message, 'error'));
} else {
console.log(`[sim] ${cmd}`);
UI.log(`[sim] ${cmd}`, 'info');
}
}
async function zeroMotor(motor) {
@@ -240,9 +245,12 @@ async function zeroMotor(motor) {
}
renderArmFromSteps();
const cmd = motor === 'ALL' ? 'HOMEALL' : `HOME${motor}`;
BLE.isConnected()
? await BLE.write(cmd).catch(e => UI.log(e.message, 'error'))
: UI.log(`[sim] ${cmd}`, 'info');
if (BLE.isConnected()) {
await BLE.write(cmd).catch(e => UI.log(e.message, 'error'));
} else {
console.log(`[sim] ${cmd}`);
UI.log(`[sim] ${cmd}`, 'info');
}
}
// ─────────────────────────────────────────────────────────────────