Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0


## [Unreleased]
Fix casting issue for tick calculation for RH/T compensation in Raspberry-Pi example

## [3.2.2] - 2022-12-05

Expand Down
5 changes: 3 additions & 2 deletions examples/raspberry-pi/algorithm_example_usage.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include "sensirion_gas_index_algorithm.h"
#include <stdio.h> // printf
#include <math.h>

#include "sensirion_common.h"
#include "sensirion_i2c_hal.h"
Expand Down Expand Up @@ -66,8 +67,8 @@ void read_compensation_values(uint16_t* compensation_rh,
// interface NOTE: in case you read RH and T raw signals check out the
// ticks specification in the datasheet, as they can be different for
// different sensors
*compensation_rh = (uint16_t)s_rh * 65535 / 100;
*compensation_t = (uint16_t)(s_temperature + 45) * 65535 / 175;
*compensation_rh = (uint16_t)lround(s_rh * 65535 / 100);
*compensation_t = (uint16_t)lround((s_temperature + 45) * 65535 / 175);
}
}

Expand Down
5 changes: 3 additions & 2 deletions examples/raspberry-pi/low_power_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include "sensirion_gas_index_algorithm.h"
#include <stdio.h> // printf
#include <math.h>

#include "sensirion_common.h"
#include "sensirion_i2c_hal.h"
Expand Down Expand Up @@ -137,7 +138,7 @@ void read_compensation_values(uint16_t* compensation_rh,
// NOTE: in case you read RH and T raw signals check out the
// ticks specification in the datasheet, as they can be different for
// different sensors
*compensation_rh = (uint16_t)s_rh * 65535 / 100;
*compensation_t = (uint16_t)(s_temperature + 45) * 65535 / 175;
*compensation_rh = (uint16_t)lround(s_rh * 65535 / 100);
*compensation_t = (uint16_t)lround((s_temperature + 45) * 65535 / 175);
}
}