fix erratic/hesitant

This commit is contained in:
osiu97
2026-07-08 21:22:07 +02:00
parent bd3f5d304a
commit b866ae9d4d
+17 -6
View File
@@ -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);
},