short tap fix

This commit is contained in:
legop3
2026-01-31 16:29:36 -05:00
parent 01cad4515f
commit 79da247dbe
4 changed files with 136 additions and 121 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -11,7 +11,7 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="Multi Roomba Rover" /> <meta name="apple-mobile-web-app-title" content="Multi Roomba Rover" />
<title>Multi Roomba Rover</title> <title>Multi Roomba Rover</title>
<script type="module" crossorigin src="/assets/index-CS8PcGyi.js"></script> <script type="module" crossorigin src="/assets/index-Dwtt2qxg.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-Bi3rvCda.css"> <link rel="stylesheet" crossorigin href="/assets/index-Bi3rvCda.css">
</head> </head>
<body> <body>
+16 -1
View File
@@ -382,6 +382,7 @@ export function ControlSystemProvider({ children }) {
pipeline.sendHorn({ action: 'start', ...normalizedHornSettings }); pipeline.sendHorn({ action: 'start', ...normalizedHornSettings });
dispatch({ type: 'control/set-horn-active', payload: true }); dispatch({ type: 'control/set-horn-active', payload: true });
hornStartAtRef.current = now; hornStartAtRef.current = now;
hornHeatTickRef.current = now;
if (hornAutoStopRef.current) { if (hornAutoStopRef.current) {
clearTimeout(hornAutoStopRef.current); clearTimeout(hornAutoStopRef.current);
hornAutoStopRef.current = null; hornAutoStopRef.current = null;
@@ -401,8 +402,22 @@ export function ControlSystemProvider({ children }) {
clearTimeout(hornAutoStopRef.current); clearTimeout(hornAutoStopRef.current);
hornAutoStopRef.current = null; hornAutoStopRef.current = null;
} }
const now = Date.now();
const startedAt = hornStartAtRef.current || now;
const holdMs = Math.max(0, now - startedAt);
hornStartAtRef.current = 0; hornStartAtRef.current = 0;
}, [dispatch, pipeline]); if (holdMs > 0) {
const currentHeat = state.horn?.heat ?? 0;
const added = (holdMs / 1000) * HORN_HEAT_UP_PER_SEC;
let nextHeat = Math.max(0, Math.min(1, currentHeat + added));
let nextOverheated = state.horn?.overheated ?? false;
if (nextHeat >= 1) {
nextHeat = 1;
nextOverheated = true;
}
dispatch({ type: 'control/set-horn-heat', payload: { heat: nextHeat, overheated: nextOverheated } });
}
}, [dispatch, pipeline, state.horn?.heat, state.horn?.overheated, HORN_HEAT_UP_PER_SEC]);
useEffect(() => { useEffect(() => {
const tickMs = 100; const tickMs = 100;