mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-15 03:02:17 -05:00
ui race condition fix
This commit is contained in:
@@ -37,27 +37,6 @@ const EMPTY_MAIN_BRUSH_AUDIO = Object.freeze({
|
||||
mainBrushOvercurrent: false,
|
||||
});
|
||||
|
||||
// These labels represent an active charging relationship reported by the
|
||||
// Roomba. That is independently useful dock evidence: some already-docked
|
||||
// rovers report charging before the home-base contact bit changes again.
|
||||
const DOCKED_CHARGING_STATES = new Set([
|
||||
'reconditioning charging',
|
||||
'full charging',
|
||||
'trickle charging',
|
||||
'waiting',
|
||||
]);
|
||||
|
||||
export function isDockedChargingState(chargingStateLabel) {
|
||||
return DOCKED_CHARGING_STATES.has(String(chargingStateLabel || '').trim().toLowerCase());
|
||||
}
|
||||
|
||||
export function resolveDocked(dockTelemetry) {
|
||||
// Dock contact and active charging are complementary sensor evidence, not
|
||||
// fallback state. Treating either as sufficient prevents UI controls from
|
||||
// claiming a charging rover should be driven onto a dock it already occupies.
|
||||
return Boolean(dockTelemetry?.homeBase) || isDockedChargingState(dockTelemetry?.chargingStateLabel);
|
||||
}
|
||||
|
||||
function bucketNumber(value, step) {
|
||||
// Visual widgets do not benefit from repainting for tiny analog jitter. The
|
||||
// bucket step intentionally applies only to display selectors; raw telemetry
|
||||
@@ -147,6 +126,9 @@ export function selectDockTelemetry(frame) {
|
||||
return {
|
||||
oiModeLabel: sensors.oiMode?.label || 'Unknown',
|
||||
chargingStateLabel: sensors.chargingState?.label || '',
|
||||
// OI packet 34 is the authoritative charging-sources packet. Charging
|
||||
// state describes the battery charger state and must not stand in for the
|
||||
// physical home-base contact bit.
|
||||
homeBase: Boolean(sensors.chargingSources?.homeBase),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user