Closed andrea-nistico closed 2 years ago
Hi andrea,
In the latest version of the driver the Press_raw_get
function exposes the data in uint32_t format left-aligned (not 24 bit), so an additional 8-bit shift is required: 4096.0f * 256 = 1048576.0f.
thanks for the opportunity for clarification
thanks for the answer, I solved with the following given your considerations:
typedef union {
struct {
uint32_t pressure32bit; /* pressure plus status register */
int16_t temperature16bit; /* temperature */
} p_and_t;
uint8_t u8bit[FIFO_DATA_SAMPLE_LEN];
} p_and_t_byte_t;
void hub_fifo_baro_axis_read(float_t *axis) {
static p_and_t_byte_t axisRaw;
lsm6dsox_fifo_out_raw_get(hub_ctx_ptr, axisRaw.u8bit);
axisRaw.p_and_t.pressure32bit <<= 8; // left byte shift for correct value
*axis = lps22hb_from_lsb_to_hpa(axisRaw.p_and_t.pressure32bit);
}
I haven't noticed the change since I am using fifo_raw_get with sensor hub which is different, thanks! Maybe it is worth mentioning this in the sensor hub examples?
I have been using this driver for a bit now, in some older version, the conversion between lsband hpa was the following:
In the last release we have:
with the first scale factor, I get correct values but with the second the results are off. Where the ''1048576.0f'' comes from?