Skip to content

Take only one measurement for altitude readings - #39

Open
Solarboaters wants to merge 1 commit into
pimoroni:mainfrom
Solarboaters:fix/single-altitude-measurement
Open

Solarboaters wants to merge 1 commit into
pimoroni:mainfrom
Solarboaters:fix/single-altitude-measurement

Conversation

@Solarboaters

Copy link
Copy Markdown

get_altitude() calls update_sensor() and then get_pressure(), which updates the sensor again. In forced mode this starts two measurements for one altitude request. Use the existing pressure accessor as the single update, as suggested in #16.

Extended the existing altitude regression across normal and forced modes using the project's simulated I2C registers and calibration fixture. It checks the same altitude result, one data-register read, and exactly one forced-measurement write (none in normal mode). Both cases fail before the change because two data reads occur; all nine tests pass afterward. No physical BME280 or Raspberry Pi was tested.

Wheel/sdist build and Twine checks pass, as do import ordering, spelling, changed-test Ruff and git diff --check. Whole-tree Ruff reports seven existing findings; the four findings in the changed production module reproduce on the original file. This PR deliberately leaves those unrelated findings unchanged.

Fixes #16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Double call of update_sensor() when getting altitude

1 participant