mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
awa
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
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -78,7 +78,7 @@
|
||||
<script defer src="https://analytics.otter.land/script.js" data-website-id="82dd56a5-db44-4279-bd1e-a4d9fee39af7" data-domains="rover.otter.land"></script>
|
||||
<script defer src="https://analytics.otter.land/recorder.js" data-website-id="82dd56a5-db44-4279-bd1e-a4d9fee39af7" data-domains="rover.otter.land" data-sample-rate="0.15" data-mask-level="moderate" data-max-duration="300000"></script>
|
||||
<title>Roomba Rover</title>
|
||||
<script type="module" crossorigin src="/assets/index-DrIw695l.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-CnZfvwYB.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DwpUkSbG.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -88,6 +88,27 @@ function isReplayEnabled() {
|
||||
return cameraConfig.replayEnabled === undefined ? DEFAULT_REPLAY_ENABLED : Boolean(cameraConfig.replayEnabled);
|
||||
}
|
||||
|
||||
function spotlightCameraStateForLogicalOn(logicalOn) {
|
||||
return Boolean(logicalOn) ? 1 : 0;
|
||||
}
|
||||
|
||||
function isSpotlightOn(light = {}) {
|
||||
const raw = light?.state;
|
||||
let rawOn = false;
|
||||
if (typeof raw === 'string') {
|
||||
const normalized = raw.trim().toLowerCase();
|
||||
rawOn = !['', '0', 'off', 'false'].includes(normalized);
|
||||
} else {
|
||||
rawOn = Boolean(Number(raw));
|
||||
}
|
||||
return rawOn;
|
||||
}
|
||||
|
||||
function normalizeSpotlightState(light) {
|
||||
if (!light || typeof light !== 'object') return light || null;
|
||||
return { ...light, on: isSpotlightOn(light) };
|
||||
}
|
||||
|
||||
function passesMode(socket) {
|
||||
const mode = getMode();
|
||||
if (mode === MODES.LOCKDOWN) return isLockdownAdmin(socket);
|
||||
@@ -274,7 +295,7 @@ async function refreshVendorState() {
|
||||
client.api('GetWhiteLed', { channel: 0 }).catch((err) => ({ error: err.message })),
|
||||
client.api('GetIrLights', { channel: 0 }).catch((err) => ({ error: err.message })),
|
||||
]);
|
||||
state.light = white?.WhiteLed || white || null;
|
||||
state.light = normalizeSpotlightState(white?.WhiteLed || white || null);
|
||||
state.ir = ir?.IrLights || ir || null;
|
||||
}
|
||||
|
||||
@@ -486,11 +507,13 @@ async function setSpotlight(socket, payload = {}) {
|
||||
requireOperator(socket);
|
||||
return serializeVendorState(async () => {
|
||||
const client = await ensureReolinkClient();
|
||||
const current = (await client.api('GetWhiteLed', { channel: 0 })).WhiteLed || {};
|
||||
const current = normalizeSpotlightState((await client.api('GetWhiteLed', { channel: 0 })).WhiteLed || {});
|
||||
const logicalOn = payload.state === undefined ? !current.on : Boolean(payload.state);
|
||||
const next = {
|
||||
...current,
|
||||
channel: 0,
|
||||
state: payload.state === undefined ? (current.state ? 0 : 1) : Number(Boolean(payload.state)),
|
||||
state: spotlightCameraStateForLogicalOn(logicalOn),
|
||||
on: logicalOn,
|
||||
};
|
||||
if (Number.isFinite(Number(payload.bright))) {
|
||||
next.bright = Math.max(0, Math.min(100, Number(payload.bright)));
|
||||
|
||||
Reference in New Issue
Block a user