Read OSTC3 GasSetting Values

Implements the reading of OSTC3 Gas Settings. These are settings
0x10 to 0x14

Signed-off-by: Joseph W. Joshua <joejoshw@gmail.com>
Signed-off-by: Thiago Macieira <thiago@macieira.org>
This commit is contained in:
Joseph W. Joshua 2014-06-21 08:46:57 +03:00 committed by Thiago Macieira
parent 4f37602836
commit 8b39d2fc17
2 changed files with 63 additions and 3 deletions

View file

@ -2,6 +2,7 @@
#include "libdivecomputer/hw.h" #include "libdivecomputer/hw.h"
#include <QDebug> #include <QDebug>
#include <QDateTime> #include <QDateTime>
#include <QStringList>
ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data) ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data)
: QThread(parent), m_data(data) : QThread(parent), m_data(data)
@ -43,13 +44,48 @@ void ReadSettingsThread::run()
unsigned char gasData[4] = {0,0,0,0}; unsigned char gasData[4] = {0,0,0,0};
rc = hw_ostc3_device_config_read(m_data->device, 0x10, gasData, sizeof(gasData)); rc = hw_ostc3_device_config_read(m_data->device, 0x10, gasData, sizeof(gasData));
if (rc == DC_STATUS_SUCCESS) { if (rc == DC_STATUS_SUCCESS) {
//Gas 1 read successful //Gas data read successful
gas gas1;
gas1.depth = gasData[3]; gas1.depth = gasData[3];
gas1.oxygen = gasData[0]; gas1.oxygen = gasData[0];
gas1.helium = gasData[1]; gas1.helium = gasData[1];
gas1.type = gasData[2]; gas1.type = gasData[2];
} }
//Gas 2
rc = hw_ostc3_device_config_read(m_data->device, 0x11, gasData, sizeof(gasData));
if (rc == DC_STATUS_SUCCESS) {
//Gas data read successful
gas2.depth = gasData[3];
gas2.oxygen = gasData[0];
gas2.helium = gasData[1];
gas2.type = gasData[2];
}
//Gas 3
rc = hw_ostc3_device_config_read(m_data->device, 0x12, gasData, sizeof(gasData));
if (rc == DC_STATUS_SUCCESS) {
//Gas data read successful
gas3.depth = gasData[3];
gas3.oxygen = gasData[0];
gas3.helium = gasData[1];
gas3.type = gasData[2];
}
//Gas 4
rc = hw_ostc3_device_config_read(m_data->device, 0x13, gasData, sizeof(gasData));
if (rc == DC_STATUS_SUCCESS) {
//Gas data read successful
gas4.depth = gasData[3];
gas4.oxygen = gasData[0];
gas4.helium = gasData[1];
gas4.type = gasData[2];
}
//Gas 5
rc = hw_ostc3_device_config_read(m_data->device, 0x14, gasData, sizeof(gasData));
if (rc == DC_STATUS_SUCCESS) {
//Gas data read successful
gas5.depth = gasData[3];
gas5.oxygen = gasData[0];
gas5.helium = gasData[1];
gas5.type = gasData[2];
}
m_deviceDetails->setGas1(gas1); m_deviceDetails->setGas1(gas1);
m_deviceDetails->setGas2(gas2); m_deviceDetails->setGas2(gas2);
@ -57,7 +93,7 @@ void ReadSettingsThread::run()
m_deviceDetails->setGas4(gas4); m_deviceDetails->setGas4(gas4);
m_deviceDetails->setGas5(gas5); m_deviceDetails->setGas5(gas5);
//Read general settings //Read other settings
unsigned char uData[1] = {0}; unsigned char uData[1] = {0};
//DiveMode //DiveMode
rc = hw_ostc3_device_config_read(m_data->device, 0x20, uData, sizeof(uData)); rc = hw_ostc3_device_config_read(m_data->device, 0x20, uData, sizeof(uData));

View file

@ -208,6 +208,30 @@ void ConfigureDiveComputerDialog::reloadValues()
ui->ostc3GasTable->setItem(0,2, new QTableWidgetItem(QString::number(deviceDetails->gas1().helium))); ui->ostc3GasTable->setItem(0,2, new QTableWidgetItem(QString::number(deviceDetails->gas1().helium)));
ui->ostc3GasTable->setItem(0,3, new QTableWidgetItem(QString::number(deviceDetails->gas1().type))); ui->ostc3GasTable->setItem(0,3, new QTableWidgetItem(QString::number(deviceDetails->gas1().type)));
ui->ostc3GasTable->setItem(0,4, new QTableWidgetItem(QString::number(deviceDetails->gas1().depth))); ui->ostc3GasTable->setItem(0,4, new QTableWidgetItem(QString::number(deviceDetails->gas1().depth)));
//load gas 2 values
ui->ostc3GasTable->setItem(1,1, new QTableWidgetItem(QString::number(deviceDetails->gas2().oxygen)));
ui->ostc3GasTable->setItem(1,2, new QTableWidgetItem(QString::number(deviceDetails->gas2().helium)));
ui->ostc3GasTable->setItem(1,3, new QTableWidgetItem(QString::number(deviceDetails->gas2().type)));
ui->ostc3GasTable->setItem(1,4, new QTableWidgetItem(QString::number(deviceDetails->gas2().depth)));
//load gas 3 values
ui->ostc3GasTable->setItem(2,1, new QTableWidgetItem(QString::number(deviceDetails->gas3().oxygen)));
ui->ostc3GasTable->setItem(2,2, new QTableWidgetItem(QString::number(deviceDetails->gas3().helium)));
ui->ostc3GasTable->setItem(2,3, new QTableWidgetItem(QString::number(deviceDetails->gas3().type)));
ui->ostc3GasTable->setItem(2,4, new QTableWidgetItem(QString::number(deviceDetails->gas3().depth)));
//load gas 4 values
ui->ostc3GasTable->setItem(3,1, new QTableWidgetItem(QString::number(deviceDetails->gas4().oxygen)));
ui->ostc3GasTable->setItem(3,2, new QTableWidgetItem(QString::number(deviceDetails->gas4().helium)));
ui->ostc3GasTable->setItem(3,3, new QTableWidgetItem(QString::number(deviceDetails->gas4().type)));
ui->ostc3GasTable->setItem(3,4, new QTableWidgetItem(QString::number(deviceDetails->gas4().depth)));
//load gas 5 values
ui->ostc3GasTable->setItem(4,1, new QTableWidgetItem(QString::number(deviceDetails->gas5().oxygen)));
ui->ostc3GasTable->setItem(4,2, new QTableWidgetItem(QString::number(deviceDetails->gas5().helium)));
ui->ostc3GasTable->setItem(4,3, new QTableWidgetItem(QString::number(deviceDetails->gas5().type)));
ui->ostc3GasTable->setItem(4,4, new QTableWidgetItem(QString::number(deviceDetails->gas5().depth)));
} }