Skip to content

Commit

Permalink
fix the SPL06's sign bit problem of Pressure Data and Temperature Data.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomascatlee committed Jun 25, 2024
1 parent 1e183f3 commit 74d7f3d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Espfc/src/Device/BaroSPL06.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ class BaroSPL06: public BaroDevice
float qua2, qua3;
float fPCompensate;

readMesurment();

fTsc = _raw_temp / (float)kt;
fPsc = _raw_pressure / (float)kp;
qua2 = _cal.c10 + fPsc * (_cal.c20 + fPsc* _cal.c30);
Expand Down Expand Up @@ -210,8 +212,12 @@ class BaroSPL06: public BaroDevice
{
uint8_t buffer[6] = {0, 0, 0, 0, 0, 0};
_bus->readFast(_addr, SPL06_PRESSURE_REG, 6, buffer);

_raw_pressure = buffer[2] | (buffer[1] << 8) | (buffer[0] << 16);
_raw_pressure = (_raw_pressure & 0x800000) ? (0xFF000000 | _raw_pressure) : _raw_pressure;

_raw_temp = buffer[5] | (buffer[4] << 8) | (buffer[3] << 16);
_raw_temp = (_raw_temp & 0x800000) ? (0xFF000000 | _raw_temp) : _raw_temp;
}

int8_t writeReg(uint8_t reg, uint8_t val)
Expand Down

0 comments on commit 74d7f3d

Please sign in to comment.