diff --git a/lib/logitech_receiver/hidpp20.py b/lib/logitech_receiver/hidpp20.py index 3713d9a1..0b9430b5 100644 --- a/lib/logitech_receiver/hidpp20.py +++ b/lib/logitech_receiver/hidpp20.py @@ -44,7 +44,6 @@ from .common import BatteryLevelApproximation from .common import BatteryStatus from .common import FirmwareKind from .common import NamedInt -from .hidpp20_constants import CHARGE_STATUS from .hidpp20_constants import DEVICE_KIND from .hidpp20_constants import ChargeLevel from .hidpp20_constants import ChargeType @@ -117,6 +116,13 @@ class MappingFlag(Flag): DIVERTED = 0x01 +class ChargeStatus(Flag): + CHARGING = 0x00 + FULL = 0x01 + NOT_CHARGING = 0x02 + ERROR = 0x07 + + class FeaturesArray(dict): def __init__(self, device): assert device is not None @@ -1879,10 +1885,10 @@ def decipher_battery_voltage(report: bytes): charge_type = ChargeType.STANDARD if flags & (1 << 7): status = BatteryStatus.RECHARGING - charge_sts = CHARGE_STATUS[flags & 0x03] + charge_sts = ChargeStatus(flags & 0x03) if charge_sts is None: charge_sts = ErrorCode.UNKNOWN - elif charge_sts == CHARGE_STATUS.full: + elif ChargeStatus.FULL in charge_sts: charge_lvl = ChargeLevel.FULL status = BatteryStatus.FULL if flags & (1 << 3): diff --git a/lib/logitech_receiver/hidpp20_constants.py b/lib/logitech_receiver/hidpp20_constants.py index 9071dfb8..bb345218 100644 --- a/lib/logitech_receiver/hidpp20_constants.py +++ b/lib/logitech_receiver/hidpp20_constants.py @@ -179,16 +179,6 @@ class OnboardMode(IntEnum): MODE_HOST = 0x02 -CHARGE_STATUS = NamedInts(charging=0x00, full=0x01, not_charging=0x02, error=0x07) - - -class ChargeStatus(IntEnum): - CHARGING = 0x00 - FULL = 0x01 - NOT_CHARGING = 0x02 - ERROR = 0x07 - - class ChargeLevel(IntEnum): AVERAGE = 50 FULL = 90