mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
lock on charge, not on dock
This commit is contained in:
+3
-2
@@ -11,9 +11,10 @@
|
|||||||
|
|
||||||
## todo
|
## todo
|
||||||
<!-- 1. battery manager -->
|
<!-- 1. battery manager -->
|
||||||
2. pi-side sensor throttle (1/5th)
|
<!-- 2. pi-side sensor throttle (1/5th) -->
|
||||||
<!-- 3. convert rover roster to a reusable component, unbake it from telemetry and admin panels -->
|
<!-- 3. convert rover roster to a reusable component, unbake it from telemetry and admin panels -->
|
||||||
4. room cameras
|
<!-- 4. room cameras -->
|
||||||
|
4. fix gamepad input - add manual inversions?
|
||||||
5. home assistant controls
|
5. home assistant controls
|
||||||
6. nicknames
|
6. nicknames
|
||||||
7. discord bot
|
7. discord bot
|
||||||
|
|||||||
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
@@ -5,8 +5,8 @@
|
|||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>webui</title>
|
<title>webui</title>
|
||||||
<script type="module" crossorigin src="/assets/index-CzaSKh_t.js"></script>
|
<script type="module" crossorigin src="/assets/index-Bd5JgrUJ.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-DIvshFK3.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-Cc0W7UiH.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ function getState(roverId) {
|
|||||||
lastPercent: null,
|
lastPercent: null,
|
||||||
warned: false,
|
warned: false,
|
||||||
urgent: false,
|
urgent: false,
|
||||||
docked: false,
|
dockedCharging: false,
|
||||||
batteryLocked: false,
|
batteryLocked: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -62,20 +62,18 @@ function handleSensorEvent({ roverId, sensors, batteryState }) {
|
|||||||
|
|
||||||
const chargingState = sensors?.chargingState?.code;
|
const chargingState = sensors?.chargingState?.code;
|
||||||
const chargingSources = sensors?.chargingSources;
|
const chargingSources = sensors?.chargingSources;
|
||||||
const docked =
|
const onDock = Boolean(chargingSources?.homeBase);
|
||||||
Boolean(chargingSources?.homeBase) ||
|
const isCharging = chargingState === 1 || chargingState === 2 || chargingState === 3;
|
||||||
chargingState === 2 ||
|
const dockedCharging = onDock && isCharging;
|
||||||
chargingState === 3 ||
|
if (dockedCharging && !state.dockedCharging) {
|
||||||
chargingState === 4;
|
state.dockedCharging = true;
|
||||||
if (docked && !state.docked) {
|
|
||||||
state.docked = true;
|
|
||||||
publishEvent({
|
publishEvent({
|
||||||
source: 'batteryManager',
|
source: 'batteryManager',
|
||||||
type: 'battery.docked',
|
type: 'battery.docked',
|
||||||
payload: { roverId, batteryState },
|
payload: { roverId, batteryState },
|
||||||
});
|
});
|
||||||
} else if (!docked && state.docked) {
|
} else if (!dockedCharging && state.dockedCharging) {
|
||||||
state.docked = false;
|
state.dockedCharging = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fullThreshold =
|
const fullThreshold =
|
||||||
@@ -84,7 +82,7 @@ function handleSensorEvent({ roverId, sensors, batteryState }) {
|
|||||||
(batteryState?.charge != null && fullThreshold != null && batteryState.charge >= fullThreshold) ||
|
(batteryState?.charge != null && fullThreshold != null && batteryState.charge >= fullThreshold) ||
|
||||||
(batteryState?.percent != null && batteryState.percent >= 0.99);
|
(batteryState?.percent != null && batteryState.percent >= 0.99);
|
||||||
|
|
||||||
if (docked && lockable && !state.batteryLocked && !isFull) {
|
if (dockedCharging && lockable && !state.batteryLocked && !isFull) {
|
||||||
logger.info('Auto-locking rover for charging', { roverId });
|
logger.info('Auto-locking rover for charging', { roverId });
|
||||||
lockRover(roverId, true, { reason: 'battery' });
|
lockRover(roverId, true, { reason: 'battery' });
|
||||||
state.batteryLocked = true;
|
state.batteryLocked = true;
|
||||||
@@ -95,8 +93,8 @@ function handleSensorEvent({ roverId, sensors, batteryState }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.batteryLocked && (isFull || !docked)) {
|
if (state.batteryLocked && (isFull || !dockedCharging)) {
|
||||||
logger.info('Unlocking rover after charge', { roverId, isFull, docked });
|
logger.info('Unlocking rover after charge', { roverId, isFull, docked: dockedCharging });
|
||||||
lockRover(roverId, false, { reason: 'battery' });
|
lockRover(roverId, false, { reason: 'battery' });
|
||||||
state.batteryLocked = false;
|
state.batteryLocked = false;
|
||||||
publishEvent({
|
publishEvent({
|
||||||
|
|||||||
@@ -247,9 +247,9 @@ function OvercurrentOverlay({ motors }) {
|
|||||||
if (!motors?.length) return null;
|
if (!motors?.length) return null;
|
||||||
const labels = motors.map((name) => OVERCURRENT_LABELS[name] || name);
|
const labels = motors.map((name) => OVERCURRENT_LABELS[name] || name);
|
||||||
return (
|
return (
|
||||||
<div className="pointer-events-none absolute inset-0 flex items-center justify-center bg-red-900/60">
|
<div className="pointer-events-none absolute flex items-center justify-center bg-red-900/60 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 p-4">
|
||||||
<div className="text-center text-2xl font-semibold text-white animate-pulse">
|
<div className="text-center text-4xl font-semibold text-white animate-pulse">
|
||||||
<div>Overcurrent</div>
|
<div>OVERCURRENT</div>
|
||||||
<div className="mt-0.5 text-xl font-medium text-white">{labels.join(', ')}</div>
|
<div className="mt-0.5 text-xl font-medium text-white">{labels.join(', ')}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -270,10 +270,10 @@ function LowBatteryOverlay({ charge, config }) {
|
|||||||
const warnTriggered = urgent != null && charge <= urgent;
|
const warnTriggered = urgent != null && charge <= urgent;
|
||||||
if (!warnTriggered && !depleted) return null;
|
if (!warnTriggered && !depleted) return null;
|
||||||
|
|
||||||
const message = depleted ? 'BATTERY VERY LOW, PLEASE DOCK THE ROVER AND CHARGE IMMEDIATELY!!' : 'Battery low! please dock and charge the rover soon.';
|
const message = depleted ? 'Battery low! please dock and charge the rover soon.' : 'BATTERY VERY LOW, PLEASE DOCK THE ROVER AND CHARGE IMMEDIATELY!!';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="pointer-events-none absolute inset-0 flex items-center justify-center bg-amber-900/60">
|
<div className="pointer-events-none absolute flex items-center justify-center bg-amber-900/60 top-10 left-1/2 -translate-x-1/2 p-4">
|
||||||
<div className="text-center text-2xl font-semibold text-white animate-pulse">
|
<div className="text-center text-2xl font-semibold text-white animate-pulse">
|
||||||
<div>{message}</div>
|
<div>{message}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user