horn scroll and lower limits!!

This commit is contained in:
legop3
2026-05-17 23:51:43 -04:00
parent f9c4249086
commit 84e5cbc787
6 changed files with 151 additions and 136 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-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>
+16 -3
View File
@@ -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>
+2 -1
View File
@@ -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]);
+1
View File
@@ -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;