From 8aa7fddb22cd6ab4d533082598be04649bb1ff21 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Sat, 21 Jun 2014 10:22:47 +0300 Subject: Add read/write support for OSTC 3 SetPoint settings Implements support for reading, writing and backup/restore of set point settings for the OSTC 3. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- configuredivecomputerthreads.cpp | 73 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'configuredivecomputerthreads.cpp') diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp index c20d58a0b..66506affd 100644 --- a/configuredivecomputerthreads.cpp +++ b/configuredivecomputerthreads.cpp @@ -152,6 +152,52 @@ void ReadSettingsThread::run() m_deviceDetails->setDil4(dil4); m_deviceDetails->setDil5(dil5); + //Read set point Values + setpoint sp1; + setpoint sp2; + setpoint sp3; + setpoint sp4; + setpoint sp5; + + unsigned char spData[2] = {0,0}; + + //Sp 1 + rc = hw_ostc3_device_config_read(m_data->device, 0x1A, spData, sizeof(spData)); + if (rc == DC_STATUS_SUCCESS) { + //Data read successful + sp1.sp = dilData[0]; + sp1.depth = dilData[1]; + } + //Sp 2 + rc = hw_ostc3_device_config_read(m_data->device, 0x1B, spData, sizeof(spData)); + if (rc == DC_STATUS_SUCCESS) { + //Data read successful + sp2.sp = dilData[0]; + sp2.depth = dilData[1]; + } + //Sp 3 + rc = hw_ostc3_device_config_read(m_data->device, 0x1C, spData, sizeof(spData)); + if (rc == DC_STATUS_SUCCESS) { + //Data read successful + sp3.sp = dilData[0]; + sp3.depth = dilData[1]; + } + //Sp 4 + rc = hw_ostc3_device_config_read(m_data->device, 0x1D, spData, sizeof(spData)); + if (rc == DC_STATUS_SUCCESS) { + //Data read successful + sp4.sp = dilData[0]; + sp4.depth = dilData[1]; + } + //Sp 5 + rc = hw_ostc3_device_config_read(m_data->device, 0x1E, spData, sizeof(spData)); + if (rc == DC_STATUS_SUCCESS) { + //Data read successful + sp5.sp = dilData[0]; + sp5.depth = dilData[1]; + } + + //Read other settings unsigned char uData[1] = {0}; //DiveMode @@ -280,6 +326,33 @@ void WriteSettingsThread::run() //gas 5 hw_ostc3_device_config_write(m_data->device, 0x14, gas5Data, sizeof(gas5Data)); + //write set point values + unsigned char sp1Data[2] = {m_deviceDetails->sp1().sp, + m_deviceDetails->sp1().depth}; + + unsigned char sp2Data[2] = {m_deviceDetails->sp2().sp, + m_deviceDetails->sp2().depth}; + + unsigned char sp3Data[2] = {m_deviceDetails->sp3().sp, + m_deviceDetails->sp3().depth}; + + unsigned char sp4Data[2] = {m_deviceDetails->sp4().sp, + m_deviceDetails->sp4().depth}; + + unsigned char sp5Data[2] = {m_deviceDetails->sp5().sp, + m_deviceDetails->sp5().depth}; + + //sp 1 + hw_ostc3_device_config_write(m_data->device, 0x1A, sp1Data, sizeof(sp1Data)); + //sp 2 + hw_ostc3_device_config_write(m_data->device, 0x1B, sp2Data, sizeof(sp2Data)); + //sp 3 + hw_ostc3_device_config_write(m_data->device, 0x1C, sp3Data, sizeof(sp3Data)); + //sp 4 + hw_ostc3_device_config_write(m_data->device, 0x1D, sp4Data, sizeof(sp4Data)); + //sp 5 + hw_ostc3_device_config_write(m_data->device, 0x1E, sp5Data, sizeof(sp5Data)); + //write dil values unsigned char dil1Data[4] = {m_deviceDetails->dil1().oxygen, m_deviceDetails->dil1().helium, -- cgit v1.2.3-70-g09d2