From 839bcaaf70b763590509031208b6786288910bc3 Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Sat, 18 Oct 2014 13:58:02 +0200 Subject: [PATCH] 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 Signed-off-by: Dirk Hohndel --- configuredivecomputerthreads.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp index a8465d7a4..70b6d1b6e 100644 --- a/configuredivecomputerthreads.cpp +++ b/configuredivecomputerthreads.cpp @@ -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();