|
PebbleOS
|
Battery state of charge, charger state and power state handling. More...
Modules | |
| Battery curve | |
| Conversion between battery voltage, charge percentage and time remaining. | |
| Battery monitor | |
| Power state control in response to battery state changes. | |
Data Structures | |
| struct | PreciseBatteryChargeState |
| Structure for retrieval of the exact battery charge state. More... | |
Functions | |
| BatteryChargeState | battery_get_charge_state (void) |
| Get the current battery charge state. | |
| void | battery_state_force_update (void) |
| Sample the battery now instead of waiting for the next periodic update. | |
| void | battery_state_init (void) |
| Initialize battery state tracking and take the first sample. | |
| void | battery_state_handle_connection_event (bool is_connected) |
| Handle a charger connection change. | |
| void | battery_state_reset_filter (void) |
| Reset the voltage filter to the current reading. | |
| uint16_t | battery_state_get_voltage (void) |
| Get the last recorded battery voltage. | |
| int32_t | battery_state_get_temperature (void) |
| Get the last recorded battery temperature. | |
| TimerID | battery_state_get_periodic_timer_id (void) |
| Get the periodic sampling timer, for unit tests. | |
Battery state of charge, charger state and power state handling.
The battery state module samples the battery through the driver, filters the readings and emits a PEBBLE_BATTERY_STATE_CHANGE_EVENT when the state changes; it is implemented either on a voltage curve or on the nRF fuel gauge, selected at build time. The battery monitor reacts to those changes with low power mode and standby.
| struct PreciseBatteryChargeState |
Structure for retrieval of the exact battery charge state.
| Data Fields | ||
|---|---|---|
| uint32_t | charge_percent | The battery's percentage as a ratio32. |
| bool | is_charging | WARNING: This maps to battery_charge_controller_thinks_we_are_charging() as opposed to the user-facing definition of whether we're charging (100% battery). |
| bool | is_plugged | True if the charger cable is connected. |
| uint8_t | pct | The battery percentage 0-100. |
| BatteryChargeState battery_get_charge_state | ( | void | ) |
Get the current battery charge state.
| void battery_state_force_update | ( | void | ) |
Sample the battery now instead of waiting for the next periodic update.
The update is scheduled from a timer, so the new state is not available on return.
| TimerID battery_state_get_periodic_timer_id | ( | void | ) |
Get the periodic sampling timer, for unit tests.
| int32_t battery_state_get_temperature | ( | void | ) |
Get the last recorded battery temperature.
| uint16_t battery_state_get_voltage | ( | void | ) |
Get the last recorded battery voltage.
| void battery_state_handle_connection_event | ( | bool | is_connected | ) |
Handle a charger connection change.
Schedules an update after a short delay, to let the readings settle and debounce reconnection.
| is_connected | true if the charger was connected. |
| void battery_state_init | ( | void | ) |
Initialize battery state tracking and take the first sample.
| void battery_state_reset_filter | ( | void | ) |
Reset the voltage filter to the current reading.
Voltage curve backend only.