Correct OSTC3 read/write of pressure sensor offset

The OSTC3 stores the pressure sensor offset as a signed 8-bit integer.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Anton Lundin 2014-10-18 13:58:02 +02:00 committed by Dirk Hohndel
parent 74f27a0a39
commit 839bcaaf70

View file

@ -408,7 +408,6 @@ void ReadSettingsThread::run()
READ_SETTING(OSTC3_SAFETY_STOP, setSafetyStop)
READ_SETTING(OSTC3_GF_HIGH, setGfHigh)
READ_SETTING(OSTC3_GF_LOW, setGfLow)
READ_SETTING(OSTC3_PRESSURE_SENSOR_OFFSET, setPressureSensorOffset)
READ_SETTING(OSTC3_PPO2_MIN, setPpO2Min)
READ_SETTING(OSTC3_PPO2_MAX, setPpO2Max)
READ_SETTING(OSTC3_FUTURE_TTS, setFutureTTS)
@ -423,6 +422,12 @@ void ReadSettingsThread::run()
#undef READ_SETTING
rc = hw_ostc3_device_config_read(m_data->device, OSTC3_PRESSURE_SENSOR_OFFSET, uData, sizeof(uData));
if (rc == DC_STATUS_SUCCESS) {
// OSTC3 stores the pressureSensorOffset in two-complement
m_deviceDetails->setPressureSensorOffset((signed char) uData[0]);
}
//read firmware settings
unsigned char fData[64] = {0};
rc = hw_ostc3_device_version (m_data->device, fData, sizeof (fData));
@ -636,7 +641,6 @@ void WriteSettingsThread::run()
WRITE_SETTING(OSTC3_SAFETY_STOP, safetyStop)
WRITE_SETTING(OSTC3_GF_HIGH, gfHigh)
WRITE_SETTING(OSTC3_GF_LOW, gfLow)
WRITE_SETTING(OSTC3_PRESSURE_SENSOR_OFFSET, pressureSensorOffset)
WRITE_SETTING(OSTC3_PPO2_MIN, ppO2Min)
WRITE_SETTING(OSTC3_PPO2_MAX, ppO2Max)
WRITE_SETTING(OSTC3_FUTURE_TTS, futureTTS)
@ -651,6 +655,10 @@ void WriteSettingsThread::run()
#undef WRITE_SETTING
// OSTC3 stores the pressureSensorOffset in two-complement
data[0] = (unsigned char) m_deviceDetails->pressureSensorOffset();
hw_ostc3_device_config_write(m_data->device, OSTC3_PRESSURE_SENSOR_OFFSET, data, sizeof(data));
//sync date and time
if (m_deviceDetails->syncTime()) {
QDateTime timeToSet = QDateTime::currentDateTime();