[PATCH 2/5] Probe and expose OSTC3 model information

Anton Lundin glance at acc.umu.se
Thu Sep 24 15:59:03 PDT 2015


This looks at the OSTC3 hw descriptor and exposes that model info as a
read-only line edit, so you can see in clear text the name of the model
of computer.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 configuredivecomputerthreads.cpp      |  36 ++++-
 qt-ui/configuredivecomputerdialog.cpp |   1 +
 qt-ui/configuredivecomputerdialog.ui  | 256 ++++++++++++++++++----------------
 3 files changed, 171 insertions(+), 122 deletions(-)

diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp
index 2c6583e..00ab07f 100644
--- a/configuredivecomputerthreads.cpp
+++ b/configuredivecomputerthreads.cpp
@@ -55,6 +55,13 @@
 #define OSTC3_GRAPHICAL_SPEED_INDICATOR	0x40
 #define OSTC3_ALWAYS_SHOW_PPO2		0x41
 
+#define OSTC3_HW_OSTC_3			0x0A
+#define OSTC3_HW_OSTC_3P		0x1A
+#define OSTC3_HW_OSTC_CR		0x05
+#define OSTC3_HW_OSTC_SPORT		0x12
+#define OSTC3_HW_OSTC_2			0x11
+
+
 #define SUUNTO_VYPER_MAXDEPTH             0x1e
 #define SUUNTO_VYPER_TOTAL_TIME           0x20
 #define SUUNTO_VYPER_NUMBEROFDIVES        0x22
@@ -401,7 +408,34 @@ static dc_status_t read_ostc3_settings(dc_device_t *device, DeviceDetails *m_dev
 	dc_status_t rc;
 	dc_event_progress_t progress;
 	progress.current = 0;
-	progress.maximum = 51;
+	progress.maximum = 52;
+	unsigned char hardware[1];
+
+	//Read hardware type
+	rc = hw_ostc3_device_hardware (device, hardware, sizeof (hardware));
+	if (rc != DC_STATUS_SUCCESS)
+		return rc;
+	EMIT_PROGRESS();
+
+	// FIXME: can we grab this info from libdivecomputer descriptor
+	// instead of hard coded here?
+	switch(hardware[0]) {
+	case OSTC3_HW_OSTC_3:
+		m_deviceDetails->model = "3";
+		break;
+	case OSTC3_HW_OSTC_3P:
+		m_deviceDetails->model = "3+";
+		break;
+	case OSTC3_HW_OSTC_CR:
+		m_deviceDetails->model = "CR";
+		break;
+	case OSTC3_HW_OSTC_SPORT:
+		m_deviceDetails->model = "Sport";
+		break;
+	case OSTC3_HW_OSTC_2:
+		m_deviceDetails->model = "2";
+		break;
+	}
 
 	//Read gas mixes
 	gas gas1;
diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp
index a6017e9..eb790e6 100644
--- a/qt-ui/configuredivecomputerdialog.cpp
+++ b/qt-ui/configuredivecomputerdialog.cpp
@@ -802,6 +802,7 @@ void ConfigureDiveComputerDialog::reloadValuesOSTC3()
 	ui.serialNoLineEdit->setText(deviceDetails->serialNo);
 	ui.firmwareVersionLineEdit->setText(deviceDetails->firmwareVersion);
 	ui.customTextLlineEdit->setText(deviceDetails->customText);
+	ui.modelLineEdit->setText(deviceDetails->model);
 	ui.diveModeComboBox->setCurrentIndex(deviceDetails->diveMode);
 	ui.saturationSpinBox->setValue(deviceDetails->saturation);
 	ui.desaturationSpinBox->setValue(deviceDetails->desaturation);
diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui
index f7820f7..0986d71 100644
--- a/qt-ui/configuredivecomputerdialog.ui
+++ b/qt-ui/configuredivecomputerdialog.ui
@@ -253,7 +253,7 @@
             <string>Basic settings</string>
            </attribute>
            <layout class="QGridLayout" name="gridLayout">
-            <item row="1" column="4">
+            <item row="2" column="4">
              <widget class="QComboBox" name="languageComboBox">
               <item>
                <property name="text">
@@ -277,7 +277,7 @@
               </item>
              </widget>
             </item>
-            <item row="5" column="4">
+            <item row="6" column="4">
              <widget class="QComboBox" name="unitsComboBox">
               <item>
                <property name="text">
@@ -331,30 +331,7 @@
               </property>
              </widget>
             </item>
-            <item row="1" column="0">
-             <widget class="QLabel" name="label_4">
-              <property name="text">
-               <string>Custom text</string>
-              </property>
-              <property name="buddy">
-               <cstring>customTextLlineEdit</cstring>
-              </property>
-             </widget>
-            </item>
-            <item row="1" column="1" colspan="2">
-             <widget class="QLineEdit" name="customTextLlineEdit">
-              <property name="sizePolicy">
-               <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
-                <horstretch>1</horstretch>
-                <verstretch>0</verstretch>
-               </sizepolicy>
-              </property>
-              <property name="maxLength">
-               <number>60</number>
-              </property>
-             </widget>
-            </item>
-            <item row="1" column="3">
+            <item row="2" column="3">
              <widget class="QLabel" name="label_5">
               <property name="text">
                <string>Language</string>
@@ -364,60 +341,45 @@
               </property>
              </widget>
             </item>
-            <item row="2" column="1">
-             <widget class="QComboBox" name="diveModeComboBox">
-              <item>
-               <property name="text">
-                <string>OC</string>
-               </property>
-              </item>
+            <item row="3" column="4">
+             <widget class="QComboBox" name="dateFormatComboBox">
               <item>
                <property name="text">
-                <string>CC</string>
+                <string>MMDDYY</string>
                </property>
               </item>
               <item>
                <property name="text">
-                <string>Gauge</string>
+                <string>DDMMYY</string>
                </property>
               </item>
               <item>
                <property name="text">
-                <string>Apnea</string>
+                <string>YYMMDD</string>
                </property>
               </item>
              </widget>
             </item>
-            <item row="2" column="0">
-             <widget class="QLabel" name="label">
-              <property name="text">
-               <string>Dive mode</string>
-              </property>
-              <property name="buddy">
-               <cstring>diveModeComboBox</cstring>
-              </property>
-             </widget>
-            </item>
-            <item row="2" column="4">
-             <widget class="QComboBox" name="dateFormatComboBox">
+            <item row="5" column="4">
+             <widget class="QComboBox" name="brightnessComboBox">
               <item>
                <property name="text">
-                <string>MMDDYY</string>
+                <string>Eco</string>
                </property>
               </item>
               <item>
                <property name="text">
-                <string>DDMMYY</string>
+                <string>Medium</string>
                </property>
               </item>
               <item>
                <property name="text">
-                <string>YYMMDD</string>
+                <string>High</string>
                </property>
               </item>
              </widget>
             </item>
-            <item row="2" column="3">
+            <item row="3" column="3">
              <widget class="QLabel" name="label_6">
               <property name="text">
                <string>Date format</string>
@@ -427,26 +389,7 @@
               </property>
              </widget>
             </item>
-            <item row="4" column="4">
-             <widget class="QComboBox" name="brightnessComboBox">
-              <item>
-               <property name="text">
-                <string>Eco</string>
-               </property>
-              </item>
-              <item>
-               <property name="text">
-                <string>Medium</string>
-               </property>
-              </item>
-              <item>
-               <property name="text">
-                <string>High</string>
-               </property>
-              </item>
-             </widget>
-            </item>
-            <item row="4" column="3">
+            <item row="5" column="3">
              <widget class="QLabel" name="label_10">
               <property name="text">
                <string>Brightness</string>
@@ -456,7 +399,7 @@
               </property>
              </widget>
             </item>
-            <item row="5" column="3">
+            <item row="6" column="3">
              <widget class="QLabel" name="label_12">
               <property name="text">
                <string>Units</string>
@@ -466,7 +409,7 @@
               </property>
              </widget>
             </item>
-            <item row="6" column="3">
+            <item row="7" column="3">
              <widget class="QLabel" name="label_14">
               <property name="text">
                <string>Salinity (0-5%)</string>
@@ -476,7 +419,7 @@
               </property>
              </widget>
             </item>
-            <item row="6" column="4">
+            <item row="7" column="4">
              <widget class="QSpinBox" name="salinitySpinBox">
               <property name="suffix">
                <string>%</string>
@@ -486,21 +429,7 @@
               </property>
              </widget>
             </item>
-            <item row="4" column="1">
-             <widget class="QComboBox" name="samplingRateComboBox">
-              <item>
-               <property name="text">
-                <string>2s</string>
-               </property>
-              </item>
-              <item>
-               <property name="text">
-                <string>10s</string>
-               </property>
-              </item>
-             </widget>
-            </item>
-            <item row="7" column="4">
+            <item row="8" column="4">
              <widget class="QComboBox" name="compassGainComboBox">
               <property name="sizePolicy">
                <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@@ -550,7 +479,7 @@
               </item>
              </widget>
             </item>
-            <item row="8" column="2">
+            <item row="9" column="2">
              <spacer name="verticalSpacer1">
               <property name="orientation">
                <enum>Qt::Vertical</enum>
@@ -563,47 +492,121 @@
               </property>
              </spacer>
             </item>
-            <item row="4" column="0">
-             <widget class="QLabel" name="label_11">
+            <item row="11" column="3" colspan="2">
+             <widget class="QPushButton" name="resetButton">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
               <property name="text">
-               <string>Sampling rate</string>
+               <string>Reset device to default settings</string>
+              </property>
+             </widget>
+            </item>
+            <item row="8" column="3">
+             <widget class="QLabel" name="label_15">
+              <property name="text">
+               <string>Compass gain</string>
               </property>
               <property name="buddy">
-               <cstring>samplingRateComboBox</cstring>
+               <cstring>compassGainComboBox</cstring>
               </property>
              </widget>
             </item>
-            <item row="5" column="1">
-             <widget class="QComboBox" name="diveModeColour">
+            <item row="1" column="0">
+             <widget class="QLabel" name="label_4">
+              <property name="text">
+               <string>Custom text</string>
+              </property>
+              <property name="buddy">
+               <cstring>customTextLlineEdit</cstring>
+              </property>
+             </widget>
+            </item>
+            <item row="1" column="1" colspan="2">
+             <widget class="QLineEdit" name="customTextLlineEdit">
+              <property name="sizePolicy">
+               <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+                <horstretch>1</horstretch>
+                <verstretch>0</verstretch>
+               </sizepolicy>
+              </property>
+              <property name="maxLength">
+               <number>60</number>
+              </property>
+             </widget>
+            </item>
+            <item row="1" column="3">
+             <widget class="QLabel" name="label_62">
+              <property name="text">
+               <string>Computer model</string>
+              </property>
+             </widget>
+            </item>
+            <item row="1" column="4">
+             <widget class="QLineEdit" name="modelLineEdit">
+              <property name="readOnly">
+               <bool>true</bool>
+              </property>
+             </widget>
+            </item>
+            <item row="2" column="0">
+             <widget class="QLabel" name="label">
+              <property name="text">
+               <string>Dive mode</string>
+              </property>
+              <property name="buddy">
+               <cstring>diveModeComboBox</cstring>
+              </property>
+             </widget>
+            </item>
+            <item row="2" column="1">
+             <widget class="QComboBox" name="diveModeComboBox">
               <item>
                <property name="text">
-                <string>Standard</string>
+                <string>OC</string>
                </property>
               </item>
               <item>
                <property name="text">
-                <string>Red</string>
+                <string>CC</string>
                </property>
               </item>
               <item>
                <property name="text">
-                <string>Green</string>
+                <string>Gauge</string>
                </property>
               </item>
               <item>
                <property name="text">
-                <string>Blue</string>
+                <string>Apnea</string>
                </property>
               </item>
              </widget>
             </item>
-            <item row="6" column="0" colspan="3">
-             <widget class="QCheckBox" name="dateTimeSyncCheckBox">
+            <item row="3" column="0">
+             <widget class="QLabel" name="label_11">
               <property name="text">
-               <string>Sync dive computer time with PC</string>
+               <string>Sampling rate</string>
+              </property>
+              <property name="buddy">
+               <cstring>samplingRateComboBox</cstring>
               </property>
              </widget>
             </item>
+            <item row="3" column="1">
+             <widget class="QComboBox" name="samplingRateComboBox">
+              <item>
+               <property name="text">
+                <string>2s</string>
+               </property>
+              </item>
+              <item>
+               <property name="text">
+                <string>10s</string>
+               </property>
+              </item>
+             </widget>
+            </item>
             <item row="5" column="0">
              <widget class="QLabel" name="label_13">
               <property name="text">
@@ -614,30 +617,41 @@
               </property>
              </widget>
             </item>
-            <item row="7" column="0" colspan="3">
-             <widget class="QCheckBox" name="safetyStopCheckBox">
-              <property name="text">
-               <string>Show safety stop</string>
-              </property>
+            <item row="5" column="1">
+             <widget class="QComboBox" name="diveModeColour">
+              <item>
+               <property name="text">
+                <string>Standard</string>
+               </property>
+              </item>
+              <item>
+               <property name="text">
+                <string>Red</string>
+               </property>
+              </item>
+              <item>
+               <property name="text">
+                <string>Green</string>
+               </property>
+              </item>
+              <item>
+               <property name="text">
+                <string>Blue</string>
+               </property>
+              </item>
              </widget>
             </item>
-            <item row="10" column="3" colspan="2">
-             <widget class="QPushButton" name="resetButton">
-              <property name="enabled">
-               <bool>false</bool>
-              </property>
+            <item row="6" column="0" colspan="3">
+             <widget class="QCheckBox" name="dateTimeSyncCheckBox">
               <property name="text">
-               <string>Reset device to default settings</string>
+               <string>Sync dive computer time with PC</string>
               </property>
              </widget>
             </item>
-            <item row="7" column="3">
-             <widget class="QLabel" name="label_15">
+            <item row="7" column="0" colspan="3">
+             <widget class="QCheckBox" name="safetyStopCheckBox">
               <property name="text">
-               <string>Compass gain</string>
-              </property>
-              <property name="buddy">
-               <cstring>compassGainComboBox</cstring>
+               <string>Show safety stop</string>
               </property>
              </widget>
             </item>
-- 
2.1.4



More information about the subsurface mailing list