diff --git a/crates/openlogi-hid/src/mappings.rs b/crates/openlogi-hid/src/mappings.rs index 18ab81cb..f6f456c5 100644 --- a/crates/openlogi-hid/src/mappings.rs +++ b/crates/openlogi-hid/src/mappings.rs @@ -104,10 +104,14 @@ pub(crate) fn map_battery_level(level: HidppBatteryLevel) -> BatteryLevel { pub(crate) fn map_battery_status(status: HidppBatteryStatus) -> BatteryStatus { match status { HidppBatteryStatus::Discharging => BatteryStatus::Discharging, - HidppBatteryStatus::Charging => BatteryStatus::Charging, + HidppBatteryStatus::Charging | HidppBatteryStatus::ChargingNearlyFull => { + BatteryStatus::Charging + } HidppBatteryStatus::ChargingSlow => BatteryStatus::ChargingSlow, HidppBatteryStatus::Full => BatteryStatus::Full, - HidppBatteryStatus::Error => BatteryStatus::Error, + HidppBatteryStatus::InvalidBattery + | HidppBatteryStatus::ThermalError + | HidppBatteryStatus::ChargingError => BatteryStatus::Error, _ => BatteryStatus::Unknown, } } diff --git a/crates/openlogi-hidpp/src/feature/unified_battery/mod.rs b/crates/openlogi-hidpp/src/feature/unified_battery/mod.rs index 26faf521..c6104129 100755 --- a/crates/openlogi-hidpp/src/feature/unified_battery/mod.rs +++ b/crates/openlogi-hidpp/src/feature/unified_battery/mod.rs @@ -183,7 +183,8 @@ pub enum BatteryLevel { Full = 1 << 3, } -/// Represents the charging status of the battery. +/// Represents the charging status of the battery, as reported in the `0x1004` +/// `getStatus` battery-status byte. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, IntoPrimitive, TryFromPrimitive)] #[cfg_attr(feature = "serde", derive(serde::Serialize))] #[non_exhaustive] @@ -193,12 +194,18 @@ pub enum BatteryStatus { Discharging = 0, /// Battery is charging. Charging = 1, - /// Battery is charging slowly. - ChargingSlow = 2, - /// Battery is full. + /// Battery is charging and in its final stage (nearly full). + ChargingNearlyFull = 2, + /// Battery charge is complete. Full = 3, - /// Battery subsystem reported an error. - Error = 4, + /// Battery is recharging below optimal speed. + ChargingSlow = 4, + /// The battery type is invalid. + InvalidBattery = 5, + /// The battery subsystem reported a thermal error. + ThermalError = 6, + /// The battery subsystem reported a charging error. + ChargingError = 7, } /// Represents an event emitted by the [`UnifiedBatteryFeature`] feature.