From b866ae9d4df76f908776688105c09b5f0481f1b9 Mon Sep 17 00:00:00 2001 From: osiu97 Date: Wed, 8 Jul 2026 21:22:07 +0200 Subject: [PATCH] fix erratic/hesitant --- web/js/motion-effects.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/web/js/motion-effects.js b/web/js/motion-effects.js index f0965fd..6058707 100644 --- a/web/js/motion-effects.js +++ b/web/js/motion-effects.js @@ -34,9 +34,20 @@ export const MotionEffects = { let delay = 0; let newHasHesitated = hasHesitated; - if (target.mode === 'hesitant' && target.fraction >= 0.45 && !hasHesitated) { - delay = 800; // Noticeably pause - newHasHesitated = true; + if (target.mode === 'hesitant') { + if (target.fraction >= 0.4 && hasHesitated === false) { + // Slow down massively instead of stopping + if (BLE.isConnected()) { + try { await BLE.write(`SPD:${Math.floor(Math.max(50, Settings.speed * 0.2))}`); } catch(e){} + } + newHasHesitated = true; // Started hesitation + } else if (target.fraction >= 0.7 && hasHesitated === true) { + // Speed back up + if (BLE.isConnected()) { + try { await BLE.write(`SPD:${Settings.speed}`); } catch(e){} + } + newHasHesitated = 2; // Finished hesitation + } } else if (target.mode === 'overshoot_settle') { delay = 200; // Brief pause before returning if (BLE.isConnected()) { @@ -48,9 +59,7 @@ export const MotionEffects = { // Called to determine blending behaviour during queue checks getQueueAction(mode, maxDist, blendThreshold) { - if (mode === 'erratic') { - if (maxDist <= 5) return { action: 'wait', delay: 100 }; - } else if (mode === 'jumpy') { + if (mode === 'jumpy') { if (maxDist <= 5) return { action: 'wait', delay: 100 }; } else { if (maxDist <= blendThreshold) return { action: 'blend' }; @@ -82,6 +91,8 @@ export const MotionEffects = { count = Math.max(count, Math.ceil(distance / 10)); // fine resolution for sine } else if (mode === 'erratic') { count = Math.max(count, Math.ceil(distance / 20)); // fewer, larger jumps + } else if (mode === 'hesitant') { + count = Math.max(count, Math.ceil(distance / 15)); // ensure we get middle waypoints for speed changes } return Math.max(1, count); },