mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
hopefully fixed discord dock / undock alerts?
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-DAo0n__B.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-BjMfmH4X.css">
|
||||
<script type="module" crossorigin src="/assets/index-Dsw_Z9n0.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-CCqAmxiE.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -20,6 +20,7 @@ function getState(roverId) {
|
||||
lastPercent: null,
|
||||
warned: false,
|
||||
urgent: false,
|
||||
onDock: false,
|
||||
dockedCharging: false,
|
||||
charging: false,
|
||||
batteryLocked: false,
|
||||
@@ -64,6 +65,21 @@ function handleSensorEvent({ roverId, sensors, batteryState }) {
|
||||
const chargingState = sensors?.chargingState?.code;
|
||||
const chargingSources = sensors?.chargingSources;
|
||||
const onDock = Boolean(chargingSources?.homeBase);
|
||||
if (onDock && !state.onDock) {
|
||||
state.onDock = true;
|
||||
publishEvent({
|
||||
source: 'batteryManager',
|
||||
type: 'battery.docked',
|
||||
payload: { roverId, batteryState },
|
||||
});
|
||||
} else if (!onDock && state.onDock) {
|
||||
state.onDock = false;
|
||||
publishEvent({
|
||||
source: 'batteryManager',
|
||||
type: 'battery.undocked',
|
||||
payload: { roverId, batteryState },
|
||||
});
|
||||
}
|
||||
const isCharging = chargingState === 1 || chargingState === 2 || chargingState === 3;
|
||||
if (isCharging && !state.charging) {
|
||||
state.charging = true;
|
||||
@@ -83,18 +99,8 @@ function handleSensorEvent({ roverId, sensors, batteryState }) {
|
||||
const dockedCharging = onDock && isCharging;
|
||||
if (dockedCharging && !state.dockedCharging) {
|
||||
state.dockedCharging = true;
|
||||
publishEvent({
|
||||
source: 'batteryManager',
|
||||
type: 'battery.docked',
|
||||
payload: { roverId, batteryState },
|
||||
});
|
||||
} else if (!dockedCharging && state.dockedCharging) {
|
||||
state.dockedCharging = false;
|
||||
publishEvent({
|
||||
source: 'batteryManager',
|
||||
type: 'battery.undocked',
|
||||
payload: { roverId, batteryState },
|
||||
});
|
||||
}
|
||||
|
||||
const fullThreshold =
|
||||
|
||||
Reference in New Issue
Block a user