As reported on the mailing list, the ascent/descent rates are sometimes not
what is expected. E.g. setting the ascent rate to 10m/min results in an actual
ascent rate of 9m/min.  This is due to truncating the ascent rate preference,
then effectively rounding up the time to reach each stop to 2s intervals. The
result being that setting the ascent rate to 10m/min results in 20s to ascend
3m (9m/min), when it should be exactly 18s. Rounding the ascent/descent rate
(stored in mm/s), by adding + 0.5 before truncating the integer, results in
better behaviour.

Reported-by: John Smith <[email protected]>
Signed-off-by: Rick Walsh <[email protected]>
---
 desktop-widgets/diveplanner.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp
index 4fc38cd..bb295a9 100644
--- a/desktop-widgets/diveplanner.cpp
+++ b/desktop-widgets/diveplanner.cpp
@@ -478,27 +478,27 @@ void PlannerSettingsWidget::printDecoPlan()
 
 void PlannerSettingsWidget::setAscRate75(int rate)
 {
-       SettingsObjectWrapper::instance()->planner_settings->setAscrate75(rate 
* UNIT_FACTOR);
+       SettingsObjectWrapper::instance()->planner_settings->setAscrate75(rate 
* UNIT_FACTOR + 0.5);
 }
 
 void PlannerSettingsWidget::setAscRate50(int rate)
 {
-       SettingsObjectWrapper::instance()->planner_settings->setAscrate50(rate 
* UNIT_FACTOR);
+       SettingsObjectWrapper::instance()->planner_settings->setAscrate50(rate 
* UNIT_FACTOR + 0.5);
 }
 
 void PlannerSettingsWidget::setAscRateStops(int rate)
 {
-       
SettingsObjectWrapper::instance()->planner_settings->setAscratestops(rate * 
UNIT_FACTOR);
+       
SettingsObjectWrapper::instance()->planner_settings->setAscratestops(rate * 
UNIT_FACTOR + 0.5);
 }
 
 void PlannerSettingsWidget::setAscRateLast6m(int rate)
 {
-       
SettingsObjectWrapper::instance()->planner_settings->setAscratelast6m(rate * 
UNIT_FACTOR);
+       
SettingsObjectWrapper::instance()->planner_settings->setAscratelast6m(rate * 
UNIT_FACTOR + 0.5);
 }
 
 void PlannerSettingsWidget::setDescRate(int rate)
 {
-       SettingsObjectWrapper::instance()->planner_settings->setDescrate(rate * 
UNIT_FACTOR);
+       SettingsObjectWrapper::instance()->planner_settings->setDescrate(rate * 
UNIT_FACTOR + 0.5);
 }
 
 void PlannerSettingsWidget::sacFactorChanged(const double factor)
-- 
2.9.3

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to