libhal-google / libhal

A collection of interfaces and abstractions for embedded peripherals and devices using modern C++
Apache License 2.0
86 stars 17 forks source link

Add `hal::state_of_charge` interface #678

Open kammce opened 1 year ago

kammce commented 1 year ago

This interface represents a batteries state of charge, meaning the percentage of charge left before the battery is no longer usable.

The interface could look something like this:

class state_of_charge {
  /** Returns a percentage value. Negative values are possible and these 
   * represent under charge conditions beyond a safe point for a charge 
   * storing device. Above +1.0 (100%) means over charge above a safe 
   * point for a charge storing device.
   */
  result<float> read() { /* ... */ }
};