summaryrefslogtreecommitdiffstats
path: root/configuredivecomputerthreads.cpp
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2014-12-07 23:44:44 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-12-08 08:39:02 -0800
commitd6f417b5bff55bbddef2b0b209a54c57f3b97d50 (patch)
tree7f9b7d31a2be09f725ee50756d7594b0ce3476cd /configuredivecomputerthreads.cpp
parentac207ee5ff60794c477d6d96c81645c4fc5b1994 (diff)
downloadsubsurface-d6f417b5bff55bbddef2b0b209a54c57f3b97d50.tar.gz
Read and write alarm time correctly for Stinger
The Stinger stores the alarm time in seconds, instead of minutes as the Vyper does it. This corrects for that. Reported-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'configuredivecomputerthreads.cpp')
-rw-r--r--configuredivecomputerthreads.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp
index 209794b3b..87b4417d2 100644
--- a/configuredivecomputerthreads.cpp
+++ b/configuredivecomputerthreads.cpp
@@ -247,7 +247,11 @@ void ReadSettingsThread::run()
}
rc = dc_device_read(m_data->device, SUUNTO_VYPER_ALARM_TIME, data, 2);
if (rc == DC_STATUS_SUCCESS) {
- m_deviceDetails->setAlarmTime(data[0] << 8 ^ data[1]);
+ int time = data[0] << 8 ^ data[1];
+ // The stinger stores alarm time in seconds instead of minutes.
+ if (m_deviceDetails->model() == "Stinger")
+ time /= 60;
+ m_deviceDetails->setAlarmTime(time);
}
rc = dc_device_read(m_data->device, SUUNTO_VYPER_ALARM_DEPTH, data, 2);
if (rc == DC_STATUS_SUCCESS) {
@@ -838,6 +842,7 @@ void WriteSettingsThread::run()
case DC_FAMILY_SUUNTO_VYPER:
unsigned char data;
unsigned char data2[2];
+ int time;
// Maybee we should read the model from the device to sanity check it here too..
// For now we just check that we actually read a device before writing to one.
if (m_deviceDetails->model() == "")
@@ -863,8 +868,12 @@ void WriteSettingsThread::run()
dc_device_write(m_data->device, SUUNTO_VYPER_LIGHT, &data, 1);
data = m_deviceDetails->alarmDepthEnabled() << 1 ^ m_deviceDetails->alarmTimeEnabled();
dc_device_write(m_data->device, SUUNTO_VYPER_ALARM_DEPTH_TIME, &data, 1);
- data2[0] = m_deviceDetails->alarmTime() >> 8;
- data2[1] = m_deviceDetails->alarmTime() & 0xFF;
+ // The stinger stores alarm time in seconds instead of minutes.
+ time = m_deviceDetails->alarmTime();
+ if (m_deviceDetails->model() == "Stinger")
+ time *= 60;
+ data2[0] = time >> 8;
+ data2[1] = time & 0xFF;
dc_device_write(m_data->device, SUUNTO_VYPER_ALARM_TIME, data2, 2);
data2[0] = (int)(mm_to_feet(m_deviceDetails->alarmDepth()) * 128) >> 8;
data2[1] = (int)(mm_to_feet(m_deviceDetails->alarmDepth()) * 128) & 0x0FF;