All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
BatteryStateService

Detailed Description

Function Documentation

BatteryChargeState battery_state_service_peek ( void  )

Peek at the last known battery state.

Returns
a BatterChargeState containing the last known data
void battery_state_service_subscribe ( BatteryStateHandler  handler)

Subscribe to the battery state event service. Once subscribed, the handler gets called on every battery state change.

Parameters
handlerA callback to be executed on battery state change event
void battery_state_service_unsubscribe ( void  )

Unsubscribe from the battery state event service. Once unsubscribed, the previously registered handler will no longer be called.


Data Structure Documentation

struct BatteryChargeState

Structure for retrieval of the battery charge state.

Data Fields
uint8_t charge_percent A percentage (0-100) of how full the battery is.
bool is_charging True if the battery is currently being charged. False if not.
bool is_plugged True if the charger cable is connected. False if not.

Typedef Documentation

typedef void(* BatteryStateHandler)(BatteryChargeState charge)

Callback type for battery state change events.

Parameters
chargethe state of the battery BatteryChargeState