mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
horn scroll and lower limits!!
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -11,7 +11,7 @@
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
<meta name="apple-mobile-web-app-title" content="Roomba Rover" />
|
||||
<title>Roomba Rover</title>
|
||||
<script type="module" crossorigin src="/assets/index-GngyFkpc.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-B2-u-cpw.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-LJWnKvT4.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useSettingsNamespace } from '../../settings/index.js';
|
||||
import { HORN_SETTINGS_DEFAULTS } from '../../settings/namespaces.js';
|
||||
import { HORN_MAX_FREQUENCY } from '../../controls/constants.js';
|
||||
|
||||
function clampFreq(value) {
|
||||
const num = Number(value);
|
||||
if (!Number.isFinite(num)) return 0;
|
||||
if (num <= 0) return 0;
|
||||
return Math.min(5000, Math.round(num));
|
||||
return Math.min(HORN_MAX_FREQUENCY, Math.round(num));
|
||||
}
|
||||
|
||||
export default function HornControl({
|
||||
@@ -99,6 +100,16 @@ export default function HornControl({
|
||||
[saveHornSettings],
|
||||
);
|
||||
|
||||
const handleFreqWheel = useCallback(
|
||||
(index) => (event) => {
|
||||
event.preventDefault();
|
||||
const direction = event.deltaY < 0 ? 1 : -1;
|
||||
const current = Number(freqs[index]) || 0;
|
||||
updateFreq(index, current + direction);
|
||||
},
|
||||
[freqs, updateFreq],
|
||||
);
|
||||
|
||||
const handlePointerDown = (event) => {
|
||||
if (disabled) return;
|
||||
const tag = event.target?.tagName?.toLowerCase();
|
||||
@@ -195,10 +206,11 @@ export default function HornControl({
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
max={5000}
|
||||
max={HORN_MAX_FREQUENCY}
|
||||
step={1}
|
||||
value={freq}
|
||||
onChange={(event) => updateFreq(idx, event.target.value)}
|
||||
onWheel={handleFreqWheel(idx)}
|
||||
className="w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"
|
||||
/>
|
||||
</label>
|
||||
@@ -224,10 +236,11 @@ export default function HornControl({
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
max={5000}
|
||||
max={HORN_MAX_FREQUENCY}
|
||||
step={1}
|
||||
value={freq}
|
||||
onChange={(event) => updateFreq(idx, event.target.value)}
|
||||
onWheel={handleFreqWheel(idx)}
|
||||
className="w-full rounded border border-slate-700 bg-slate-900 px-1 py-[2px] text-right text-[0.65rem] font-mono text-slate-100"
|
||||
/>
|
||||
</label>
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
HORN_HEAT_COOL_PER_SEC,
|
||||
HORN_HEAT_RESUME_THRESHOLD,
|
||||
HORN_HEAT_UP_PER_SEC,
|
||||
HORN_MAX_FREQUENCY,
|
||||
HORN_MAX_MS,
|
||||
MANUAL_DOCK_ASSIST_MAX_SPEED,
|
||||
SONG_DEFAULT_NOTE,
|
||||
@@ -424,7 +425,7 @@ export function ControlSystemProvider({ children }) {
|
||||
.map((value) => {
|
||||
const num = Number(value);
|
||||
if (!Number.isFinite(num)) return 0;
|
||||
return num <= 0 ? 0 : Math.min(5000, Math.round(num));
|
||||
return num <= 0 ? 0 : Math.min(HORN_MAX_FREQUENCY, Math.round(num));
|
||||
});
|
||||
return { waveform, freqs: normalized };
|
||||
}, [hornSettings]);
|
||||
|
||||
@@ -22,6 +22,7 @@ export const SONG_DEFAULT_DURATION = 8;
|
||||
export const SONG_REPEAT_MS = 250;
|
||||
|
||||
export const HORN_MAX_MS = 4000;
|
||||
export const HORN_MAX_FREQUENCY = 2000;
|
||||
export const HORN_HEAT_UP_PER_SEC = 0.4;
|
||||
export const HORN_HEAT_COOL_PER_SEC = 0.2;
|
||||
export const HORN_HEAT_RESUME_THRESHOLD = 0.8;
|
||||
|
||||
Reference in New Issue
Block a user