I'm looking at implementing a virtual battery in the next DeviceEmulator release. How much control do you need over the virtual battery?
The straightforward way to emulate a battery is to have two controls:
- Is the emulated device on battery or A/C power?
- What is the battery charge as a percentage?
With those, you can simulate the transition from battery to A/C and back, and set the battery charge to values that trigger the low-battery and critical-battery events. Is there a need for more? The battery APIs return a SYSTEM_POWER_STATUS_EX2 structure which contains data about battery temperature, which kind of battery (NiCAD, Lithium-ion, etc.), number of seconds of runtime predicted. They also can return status about both a primary and backup battery.
Is that important to anyone?