added board control
This commit is contained in:
@@ -45,10 +45,23 @@ const PX_L2 = IK.ARM.l2 * SV.SCALE;
|
||||
const PX_D2 = IK.ARM.d2 * SV.SCALE;
|
||||
|
||||
// ── Section state ─────────────────────────────────────────────────
|
||||
let steps1 = IK.ARM.HOME_STEPS.m1;
|
||||
let steps2 = IK.ARM.HOME_STEPS.m2;
|
||||
let steps1 = 0;
|
||||
let steps2 = 0;
|
||||
let eventCleanup = [];
|
||||
|
||||
function syncStateFromStorage() {
|
||||
const isHomed = localStorage.getItem('wiji_homed') === 'true';
|
||||
steps1 = isHomed ? parseInt(localStorage.getItem('wiji_steps1') || IK.ARM.HOME_STEPS.m1) : IK.ARM.HOME_STEPS.m1;
|
||||
steps2 = isHomed ? parseInt(localStorage.getItem('wiji_steps2') || IK.ARM.HOME_STEPS.m2) : IK.ARM.HOME_STEPS.m2;
|
||||
}
|
||||
|
||||
function saveSteps() {
|
||||
if (localStorage.getItem('wiji_homed') === 'true') {
|
||||
localStorage.setItem('wiji_steps1', steps1);
|
||||
localStorage.setItem('wiji_steps2', steps2);
|
||||
}
|
||||
}
|
||||
|
||||
// ── SVG element refs ──────────────────────────────────────────────
|
||||
let svgEl;
|
||||
// Real arm elements
|
||||
@@ -135,6 +148,7 @@ function updateReadouts(t1, t2, ex, ey) {
|
||||
if (elTheta2) elTheta2.textContent = IK.radToDeg(t2).toFixed(1) + '°';
|
||||
if (elSteps1) elSteps1.textContent = steps1;
|
||||
if (elSteps2) elSteps2.textContent = steps2;
|
||||
saveSteps();
|
||||
}
|
||||
|
||||
// ── Ghost arm show/hide ───────────────────────────────────────────
|
||||
@@ -218,6 +232,7 @@ async function zeroMotor(motor) {
|
||||
if (motor === 'ALL') {
|
||||
steps1 = IK.ARM.HOME_STEPS.m1;
|
||||
steps2 = IK.ARM.HOME_STEPS.m2;
|
||||
localStorage.setItem('wiji_homed', 'true');
|
||||
} else if (motor === 1) {
|
||||
steps1 = IK.ARM.HOME_STEPS.m1;
|
||||
} else {
|
||||
@@ -616,6 +631,7 @@ function buildHTML() {
|
||||
|
||||
const StepperTestSection = {
|
||||
mount(container) {
|
||||
syncStateFromStorage();
|
||||
container.innerHTML = buildHTML();
|
||||
|
||||
// ── Cache refs ──────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user