Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions crates/openlogi-hid/src/mappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
19 changes: 13 additions & 6 deletions crates/openlogi-hidpp/src/feature/unified_battery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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.
Expand Down
Loading