Skip to content

Commit

Permalink
Merge pull request #10 from Schm1tz1/Seeduino-Fix-#8
Browse files Browse the repository at this point in the history
Fixed issues due to global variables wit Seeeduino Boards
  • Loading branch information
Schm1tz1 authored Aug 2, 2023
2 parents 496f2f1 + 8774172 commit 5d30b53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/MS5611.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ MS5611::MS5611(TwoWire *aWire) : MS5xxx(aWire){
}

void MS5611::Readout() {
unsigned long D1=0, D2=0;
unsigned long l_D1=0, l_D2=0;

double dT;
double OFF;
double SENS;

D2=read_adc(MS5xxx_CMD_ADC_D2+MS5xxx_CMD_ADC_4096);
D1=read_adc(MS5xxx_CMD_ADC_D1+MS5xxx_CMD_ADC_4096);
l_D2=read_adc(MS5xxx_CMD_ADC_D2+MS5xxx_CMD_ADC_4096);
l_D1=read_adc(MS5xxx_CMD_ADC_D1+MS5xxx_CMD_ADC_4096);

// calculate 1st order pressure and temperature (MS5611 1st order algorithm)
dT=D2-C[5]*pow(2,8);
dT=l_D2-C[5]*pow(2,8);
OFF=C[2]*pow(2,16)+dT*C[4]/pow(2,7);
SENS=C[1]*pow(2,15)+dT*C[3]/pow(2,8);
TEMP=(2000+(dT*C[6])/pow(2,23));
P=(((D1*SENS)/pow(2,21)-OFF)/pow(2,15));
P=(((l_D1*SENS)/pow(2,21)-OFF)/pow(2,15));

// perform higher order corrections
double T2=0., OFF2=0., SENS2=0.;
Expand All @@ -57,6 +57,6 @@ void MS5611::Readout() {
TEMP-=T2;
OFF-=OFF2;
SENS-=SENS2;
P=(((D1*SENS)/pow(2,21)-OFF)/pow(2,15));
P=(((l_D1*SENS)/pow(2,21)-OFF)/pow(2,15));
}

12 changes: 6 additions & 6 deletions src/MS5xxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,21 +144,21 @@ unsigned long MS5xxx::read_adc(unsigned char aCMD)
}

void MS5xxx::Readout() {
unsigned long D1=0, D2=0;
unsigned long l_D1=0, l_D2=0;

double dT;
double OFF;
double SENS;

D2=read_adc(MS5xxx_CMD_ADC_D2+MS5xxx_CMD_ADC_4096);
D1=read_adc(MS5xxx_CMD_ADC_D1+MS5xxx_CMD_ADC_4096);
l_D2 = read_adc(MS5xxx_CMD_ADC_D2+MS5xxx_CMD_ADC_4096);
l_D1 = read_adc(MS5xxx_CMD_ADC_D1+MS5xxx_CMD_ADC_4096);

// calculate 1st order pressure and temperature (MS5607 1st order algorithm)
dT=D2-C[5]*pow(2,8);
dT=l_D2-C[5]*pow(2,8);
OFF=C[2]*pow(2,17)+dT*C[4]/pow(2,6);
SENS=C[1]*pow(2,16)+dT*C[3]/pow(2,7);
TEMP=(2000+(dT*C[6])/pow(2,23));
P=(((D1*SENS)/pow(2,21)-OFF)/pow(2,15));
P=(((l_D1*SENS)/pow(2,21)-OFF)/pow(2,15));

// perform higher order corrections
double T2=0., OFF2=0., SENS2=0.;
Expand All @@ -175,7 +175,7 @@ void MS5xxx::Readout() {
TEMP-=T2;
OFF-=OFF2;
SENS-=SENS2;
P=(((D1*SENS)/pow(2,21)-OFF)/pow(2,15));
P=(((l_D1*SENS)/pow(2,21)-OFF)/pow(2,15));
}

double MS5xxx::GetTemp() {
Expand Down

0 comments on commit 5d30b53

Please sign in to comment.