Probe and expose OSTC3 model information

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@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Anton Lundin 2015-09-25 00:59:03 +02:00 committed by Dirk Hohndel
parent 94a86df9a3
commit 8946c82242
3 changed files with 173 additions and 124 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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,41 +341,7 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="diveModeComboBox">
<item>
<property name="text">
<string>OC</string>
</property>
</item>
<item>
<property name="text">
<string>CC</string>
</property>
</item>
<item>
<property name="text">
<string>Gauge</string>
</property>
</item>
<item>
<property name="text">
<string>Apnea</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">
<item row="3" column="4">
<widget class="QComboBox" name="dateFormatComboBox">
<item>
<property name="text">
@ -417,17 +360,7 @@
</item>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Date format</string>
</property>
<property name="buddy">
<cstring>dateFormatComboBox</cstring>
</property>
</widget>
</item>
<item row="4" column="4">
<item row="5" column="4">
<widget class="QComboBox" name="brightnessComboBox">
<item>
<property name="text">
@ -446,7 +379,17 @@
</item>
</widget>
</item>
<item row="4" column="3">
<item row="3" column="3">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Date format</string>
</property>
<property name="buddy">
<cstring>dateFormatComboBox</cstring>
</property>
</widget>
</item>
<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,7 +492,98 @@
</property>
</spacer>
</item>
<item row="4" column="0">
<item row="11" column="3" colspan="2">
<widget class="QPushButton" name="resetButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<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>compassGainComboBox</cstring>
</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">
<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>OC</string>
</property>
</item>
<item>
<property name="text">
<string>CC</string>
</property>
</item>
<item>
<property name="text">
<string>Gauge</string>
</property>
</item>
<item>
<property name="text">
<string>Apnea</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Sampling rate</string>
@ -573,6 +593,30 @@
</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">
<string>Dive mode color</string>
</property>
<property name="buddy">
<cstring>diveModeColour</cstring>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="diveModeColour">
<item>
@ -604,16 +648,6 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Dive mode color</string>
</property>
<property name="buddy">
<cstring>diveModeColour</cstring>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3">
<widget class="QCheckBox" name="safetyStopCheckBox">
<property name="text">
@ -621,26 +655,6 @@
</property>
</widget>
</item>
<item row="10" column="3" colspan="2">
<widget class="QPushButton" name="resetButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Reset device to default settings</string>
</property>
</widget>
</item>
<item row="7" column="3">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Compass gain</string>
</property>
<property name="buddy">
<cstring>compassGainComboBox</cstring>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="advancedSettings">