Skip to content

fuel_gauge: composite: more flexible data sourcing and channel querying #88397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

JordanYates
Copy link
Collaborator

@JordanYates JordanYates commented Apr 10, 2025

To ensure that data is consistent across multiple sequential calls to fuel_gauge_get_prop, sensor_fetch is only called if a certain time period has passed since the previous sampling. This emulates the tick-based sampling of most dedicated fuel-gauge devices.

Instead of explicitly specifying the source for the voltage and current channels, specify primary and secondary data sources. If the requested sensor channel does not exist on the primary source, the secondary source will be tried.

Choose whether the data sources should be queried by the generic sensor channels (SENSOR_CHAN_VOLTAGE, etc), or the fuel gauge specific channels (SENSOR_CHAN_GAUGE_*).

Add support for the FUEL_GAUGE_TEMPERATURE property.

More flexible alternative to #83859.
Depends on #88395

The motivation for this PR is the desire to access core functionality of the existing in-tree nPM1300 driver (which implements the sensor API using SENSOR_CHAN_GAUGE_* channels) through the fuel gauge API, together with extending it to support SoC lookup.

@JordanYates
Copy link
Collaborator Author

CI failure is unrelated: #88398

@JordanYates JordanYates force-pushed the 250410_fuel_gauge_comp_tick branch from f04e454 to a43f783 Compare April 22, 2025 02:35
To ensure that data is consistent across multiple sequential calls to
`fuel_gauge_get_prop`, sensor_fetch is only called if a certain time
period has passed since the previous sampling. This emulates the
tick-based sampling of most dedicated fuel-gauge devices.

Signed-off-by: Jordan Yates <[email protected]>

tick
Instead of explicitly specifying the source for the voltage and current
channels, specify primary and secondary data sources. If the requested
sensor channel does not exist on the primary source, the secondary
source will be tried.

Signed-off-by: Jordan Yates <[email protected]>
Choose whether the data sources should be queried by the generic sensor
channels (`SENSOR_CHAN_VOLTAGE`, etc), or the fuel guage specific
channels (`SENSOR_CHAN_GAUGE_*`).

Signed-off-by: Jordan Yates <[email protected]>
Add support for the `FUEL_GAUGE_TEMPERATURE` property.

Signed-off-by: Jordan Yates <[email protected]>
Query the configured data sources for capacity and soc information
before falling back to the composite fuel gauge configuration. This
means the battery properties are no longer required.

Signed-off-by: Jordan Yates <[email protected]>
@JordanYates JordanYates force-pushed the 250410_fuel_gauge_comp_tick branch from a43f783 to b34fe1a Compare May 2, 2025 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants