Commit Graph

16 Commits

Author SHA1 Message Date
MattHag bd00cc97ad
Estimate accurate battery level for some rechargable devices (#2745)
* battery: Extract battery level estimation into function

Test battery level estimation with sharp edges based on predefined
steps. Rename variable for clarity and add type hints.

Related #2744

* battery: Interpolate battery level for some rechargeable devices in percent

Estimate remaining battery based on measured battery voltage. Use linear
interpolation to achieve a smooth line instead of 10 percent jumps.

Fixes #2744
2025-01-02 10:58:07 -05:00
MattHag 5f5c7cdcce Fixes on top of refactoring 2025-01-01 10:46:04 -05:00
MattHag 1afcfe4b57
refactor: use IntEnum for firmware and cidgroup constances
* Refactor: test_named_ints_flag_names

Shorten test and clarify behavior using binary numbers.

* Introduce plain flag_names function

This replicates the NamedInts functionality as plain function.

* Refactor FeatureFlag to use IntFlag

Replace NamedInts implementation with IntFlag enum and plain flag_names
function.

Related #2273

* Refactor FirmwareKind to use IntEnum

- Move general FirmwareKind to common module.
- Replace NamedInts implementation with IntEnum.
- Harden related HIDPP 1.0 get_firmware test.

Related #2273

* Refactor CID_GROUP, CID_GROUP_BIT to use IntEnum

Related #2273
2024-10-23 16:25:35 -04:00
MattHag 0cd9c0c9b5 Refactor: Introduce Feature enum
Convert Feature NamedInts to SupportedFeature integer enum.

Related #2273
2024-10-14 07:28:09 -04:00
MattHag 741c0861c2 Clarify that fake hidpp is used
This module shouldn't be necessary on the long run. Remove pieces from
it whenever possible.
2024-10-08 14:35:16 -04:00
Matthias Hagmann c9dc232951 Refactor: Use dataclasses and enums
Replace unnecessary NamedInts in favour of default data types.
Simplify interfaces by reducing possible input from strings to members
of an enum.
2024-05-22 21:14:41 -04:00
Peter F. Patel-Schneider e64eec18e9 tests: extend testing of hidpp20 2024-04-13 18:38:44 -04:00
Peter F. Patel-Schneider c70e8b54bf tests: remove unused code 2024-03-27 18:02:55 -04:00
Peter F. Patel-Schneider 12f3f2e856 tests: adjust imports to always import installed version 2024-03-27 18:02:55 -04:00
Peter F. Patel-Schneider 88ac4c9f89 tests: use new test methods in test_hidpp20_simple 2024-03-23 10:11:30 -04:00
Peter F. Patel-Schneider 6164317a64 tests: improve hidpp20 coverage 2024-03-16 16:20:39 -04:00
Peter F. Patel-Schneider d76eed85f6 device: fix bug in setting configuration cookie due to bad documentation 2024-03-14 17:06:17 -04:00
Peter F. Patel-Schneider d5bdf2b0f5 tests: complete testing of common 2024-03-13 16:08:16 -04:00
Peter F. Patel-Schneider 4632c46e30 tests: expand coverage of hidpp20 2024-03-13 16:08:16 -04:00
Matthias Hagmann 5b09ace1f5 ruff: Apply single line import format
# Usage
pre-commit run --all-files

Related #2295
2024-03-13 15:41:21 -04:00
Peter F. Patel-Schneider 15ed26887b tests: tests for a few simple hidpp20 functions 2024-03-05 15:27:07 -05:00