This commit is contained in:
legop3
2025-12-26 23:19:55 -05:00
parent 1a6ca5ce73
commit bd862bf3f2
4 changed files with 21 additions and 15 deletions
+8 -2
View File
@@ -1,6 +1,7 @@
import { useEffect, useMemo, useState } from 'react';
const HOLD_MS = 700;
const HOLD_MS = 650;
const RECENT_MS = 400; // how fresh a hit must be to count toward activation
const DOCK_CODES = {
161: { red: true }, // Red buoy
@@ -84,8 +85,13 @@ export function useDockIr(sensors, options = {}) {
const left = withWindow(state.left);
const right = withWindow(state.right);
const omni = withWindow(state.omni);
const visible = left.active || right.active || omni.active;
const forceDetected = left.force || right.force || omni.force;
const leftColor = left.red || left.green;
const rightColor = right.red || right.green;
const leftFresh = leftColor && left.age != null && left.age <= RECENT_MS;
const rightFresh = rightColor && right.age != null && right.age <= RECENT_MS;
// Require either force field (close range) or both sides freshly seeing buoys.
const visible = forceDetected || (leftFresh && rightFresh);
const bias =
left.active && !right.active
? 'right'