From 4b6cd37a2351ead3ab07bb084d0dec3d2b55c0d4 Mon Sep 17 00:00:00 2001 From: Jacob Dahl Date: Tue, 31 Mar 2026 14:49:07 -0800 Subject: [PATCH] fix(lps25h): correct timestamp_sample to integration midpoint The LPS25H one-shot measurement is integrated over a ~40ms window (at 25Hz-equivalent internal averaging). The read time corresponds to the end of the integration window. Correct timestamp_sample to the midpoint by subtracting CONVERSION_INTERVAL / 2. --- src/drivers/barometer/lps25h/LPS25H.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/drivers/barometer/lps25h/LPS25H.cpp b/src/drivers/barometer/lps25h/LPS25H.cpp index ed28d0b456..4a74b4be6f 100644 --- a/src/drivers/barometer/lps25h/LPS25H.cpp +++ b/src/drivers/barometer/lps25h/LPS25H.cpp @@ -151,8 +151,12 @@ int LPS25H::collect() int16_t t; } report{}; - /* get measurements from the device : MSB enables register address auto-increment */ - const hrt_abstime timestamp_sample = hrt_absolute_time(); + /* Correct for measurement integration delay: the one-shot conversion + * was started CONVERSION_INTERVAL ago, so the effective sample + * midpoint is half the conversion interval before now. */ + const hrt_abstime now = hrt_absolute_time(); + const hrt_abstime half_meas = LPS25H_CONVERSION_INTERVAL / 2; + const hrt_abstime timestamp_sample = (now > half_meas) ? (now - half_meas) : now; int ret = _interface->read(ADDR_STATUS_REG | (1 << 7), (uint8_t *)&report, sizeof(report)); if (ret != OK) {