mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
tweak
This commit is contained in:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user