mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
battery warning overlay
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
@@ -5,8 +5,8 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>webui</title>
|
||||
<script type="module" crossorigin src="/assets/index-DpqYGJw5.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-D_R7IqbV.css">
|
||||
<script type="module" crossorigin src="/assets/index-JjoB2amU.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-q-OzpN6g.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -159,6 +159,7 @@ export default function VideoTile({ sessionInfo, label, forceMute = false, telem
|
||||
/>
|
||||
<HudOverlay frame={telemetryFrame} label={label}/>
|
||||
<OvercurrentOverlay motors={overcurrentMotors} />
|
||||
<LowBatteryOverlay charge={batteryCharge} config={batteryConfig} />
|
||||
</div>
|
||||
<BatteryBar charge={batteryCharge} config={batteryConfig} status={renderedStatus} />
|
||||
</div>
|
||||
@@ -254,3 +255,28 @@ function OvercurrentOverlay({ motors }) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// low battery overlay, change text based on warn / urgent. use percentage calculated same as BatteryBar. change text based on warn or urgent.
|
||||
function LowBatteryOverlay({ charge, config }) {
|
||||
if (charge == null || config == null) return null;
|
||||
const full = config.Full;
|
||||
const warn = config.Warn;
|
||||
const urgent = config.Urgent ?? null;
|
||||
const span = full - warn;
|
||||
if (span <= 0) return null;
|
||||
const normalized = (charge - warn) / span;
|
||||
const percent = Math.min(1, Math.max(0, normalized));
|
||||
const depleted = normalized <= 0;
|
||||
const warnTriggered = urgent != null && charge <= urgent;
|
||||
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.';
|
||||
|
||||
return (
|
||||
<div className="pointer-events-none absolute inset-0 flex items-center justify-center bg-amber-900/60">
|
||||
<div className="text-center text-2xl font-semibold text-white animate-pulse">
|
||||
<div>{message}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user