Skip to content

Commit

Permalink
replace the environment commands for t_fine
Browse files Browse the repository at this point in the history
  • Loading branch information
mnr committed Dec 4, 2023
1 parent 22cc6c0 commit 8216c53
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vignettes/articles/i2cbme280.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ rpi_i2c_set(
# Output value of "5123" equals 51.23 DegC
cppFunction('int BME280_compensate_T_int32(long signed int adc_T, int dig_T1, int dig_T2, int dig_T3)
{
long signed int var1, var2, T;
long signed int var1, var2, T, t_fine;
Environment env = Environment::global_env();
long signed int t_fine = env["t_fine"];
long signed int t_fine;
var1 = ((((adc_T>>3) - ((long signed int)dig_T1<<1))) * ((long signed int)dig_T2)) >> 11;
var2 = (((((adc_T>>4) - ((long signed int)dig_T1)) * ((adc_T>>4) - ((long signed int)dig_T1))) >> 12) *((long signed int)dig_T3)) >> 14;
Expand Down Expand Up @@ -143,6 +143,9 @@ print(paste("temperature (c):", temperature_celsius))
cppFunction('long unsigned int BME280_compensate_P_int32(long signed int adc_P, int dig_P1, int dig_P2, int dig_P3, int dig_P4, int dig_P5, int dig_P6)
{
long long unsigned int var1, var2, p;
Environment env = Environment::global_env();
long signed int t_fine = env["t_fine"];
var1 = ((long long unsigned int)t_fine) - 128000;
var2 = var1 * var1 * (long long unsigned int)dig_P6;
var2 = var2 + (var1*((long long unsigned int)dig_P5)<<17);
Expand Down

0 comments on commit 8216c53

Please sign in to comment.