mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
let song commands through
This commit is contained in:
@@ -64,7 +64,8 @@ io.on('connection', (socket) => {
|
|||||||
if (!roverId) {
|
if (!roverId) {
|
||||||
throw new Error('roverId required');
|
throw new Error('roverId required');
|
||||||
}
|
}
|
||||||
if (!roverManager.canDrive(roverId, socket)) {
|
const isSongCommand = type === 'song';
|
||||||
|
if (!isSongCommand && !roverManager.canDrive(roverId, socket)) {
|
||||||
throw new Error('Not your turn or no control');
|
throw new Error('Not your turn or no control');
|
||||||
}
|
}
|
||||||
const payload = data ? { ...data } : {};
|
const payload = data ? { ...data } : {};
|
||||||
|
|||||||
@@ -104,22 +104,12 @@ export default function VideoTile({
|
|||||||
return Math.max(0, Math.min(1, 1 - Math.min(driveCap, auxCap)));
|
return Math.max(0, Math.min(1, 1 - Math.min(driveCap, auxCap)));
|
||||||
}, [limiterCaps]);
|
}, [limiterCaps]);
|
||||||
const limiterActive = Boolean(overcurrentLimiter?.isActive);
|
const limiterActive = Boolean(overcurrentLimiter?.isActive);
|
||||||
const limiterLabels = useMemo(() => {
|
const overlayMotors = overcurrentMotors.length
|
||||||
if (!limiterCaps) return [];
|
? overcurrentMotors
|
||||||
const labels = [];
|
: limiterActive
|
||||||
const driveCap = Number.isFinite(limiterCaps?.drive?.cap) ? limiterCaps.drive.cap : 1;
|
? ['limiter']
|
||||||
const auxCap = Number.isFinite(limiterCaps?.aux?.cap) ? limiterCaps.aux.cap : 1;
|
|
||||||
if (Boolean(limiterGroups?.drive) || driveCap < 0.999) labels.push('Drive wheels');
|
|
||||||
if (Boolean(limiterGroups?.aux) || auxCap < 0.999) labels.push('Aux motors');
|
|
||||||
return labels;
|
|
||||||
}, [limiterCaps, limiterGroups]);
|
|
||||||
const overlayActive = Boolean(overcurrentMotors.length || limiterActive);
|
|
||||||
const overlayLabelsRaw = overcurrentMotors.length
|
|
||||||
? overcurrentMotors.map((name) => OVERCURRENT_LABELS[name] || name)
|
|
||||||
: limiterLabels.length
|
|
||||||
? limiterLabels
|
|
||||||
: [];
|
: [];
|
||||||
const overlayLabels = overlayLabelsRaw.length ? overlayLabelsRaw : ['Overcurrent'];
|
const overlayFill = limiterFill ?? (overcurrentMotors.length ? 1 : 0);
|
||||||
|
|
||||||
const scheduleRestart = useCallback(() => {
|
const scheduleRestart = useCallback(() => {
|
||||||
clearTimeout(restartTimer.current);
|
clearTimeout(restartTimer.current);
|
||||||
@@ -446,12 +436,7 @@ export default function VideoTile({
|
|||||||
labelScale={hudLabelScale}
|
labelScale={hudLabelScale}
|
||||||
/>
|
/>
|
||||||
<HudChatInput compact={mobileHud} />
|
<HudChatInput compact={mobileHud} />
|
||||||
<OvercurrentOverlay
|
<OvercurrentOverlay motors={overlayMotors} fill={overlayFill} compact={mobileHud} />
|
||||||
labels={overlayLabels}
|
|
||||||
fill={limiterFill ?? (overcurrentMotors.length ? 1 : 0)}
|
|
||||||
visible={overlayActive}
|
|
||||||
compact={mobileHud}
|
|
||||||
/>
|
|
||||||
<LowBatteryOverlay charge={batteryCharge} config={batteryConfig} compact={mobileHud} />
|
<LowBatteryOverlay charge={batteryCharge} config={batteryConfig} compact={mobileHud} />
|
||||||
{showVerticalBattery && batteryVisual.available ? (
|
{showVerticalBattery && batteryVisual.available ? (
|
||||||
<BatteryBarVertical visual={batteryVisual} />
|
<BatteryBarVertical visual={batteryVisual} />
|
||||||
@@ -749,11 +734,12 @@ const OVERCURRENT_LABELS = {
|
|||||||
rightWheel: 'Right wheel',
|
rightWheel: 'Right wheel',
|
||||||
mainBrush: 'Main brush',
|
mainBrush: 'Main brush',
|
||||||
sideBrush: 'Side brush',
|
sideBrush: 'Side brush',
|
||||||
|
limiter: 'Overcurrent limit',
|
||||||
};
|
};
|
||||||
|
|
||||||
function OvercurrentOverlay({ labels, fill = 0, visible = false, compact = false }) {
|
function OvercurrentOverlay({ motors, fill = 0, compact = false }) {
|
||||||
if (!visible) return null;
|
if (!motors?.length) return null;
|
||||||
const safeLabels = Array.isArray(labels) && labels.length ? labels : ['Overcurrent'];
|
const safeLabels = motors.map((name) => OVERCURRENT_LABELS[name] || name);
|
||||||
const containerClass = compact ? 'p-2' : 'p-4';
|
const containerClass = compact ? 'p-2' : 'p-4';
|
||||||
const textClass = compact ? 'text-lg' : 'text-4xl';
|
const textClass = compact ? 'text-lg' : 'text-4xl';
|
||||||
const subTextClass = compact ? 'text-xs' : 'text-xl';
|
const subTextClass = compact ? 'text-xs' : 'text-xl';
|
||||||
|
|||||||
Reference in New Issue
Block a user