Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issues due to global variables wit Seeeduino Boards #10

Merged
merged 1 commit into from
Aug 2, 2023
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
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