mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 18:03:24 +00:00
Planner: Increase CCR Setpoint Precision to 0.01.
Increase the precision of the setpoint that can be specified per planned leg of the dive to 0.01 mbar. Some rebreather models (APD Inspiration) support this precision for setpoint setting. Motivated-by: https://groups.google.com/g/subsurface-divelog/c/pD5gYlG5szI/m/G8_as4TyBwAJ Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
parent
8992ca629d
commit
de5311033c
2 changed files with 22 additions and 14 deletions
|
@ -1130,25 +1130,36 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
}
|
||||
|
||||
/*
|
||||
* Get a value in tenths (so "10.2" == 102, "9" = 90)
|
||||
* Get a value with a given number of decimals:
|
||||
* - get_decimals("10.2", &"10.2", 1) == 102
|
||||
* - get_decimals("9", &"9", 1) = 90
|
||||
* - get_decimals("1.35", &"1.35", 2) == 135))
|
||||
*
|
||||
* Return negative for errors.
|
||||
*/
|
||||
static int get_tenths(const char *begin, const char **endp)
|
||||
static int get_decimals(const char *begin, const char **endp, const unsigned decimals)
|
||||
{
|
||||
char *end;
|
||||
int value = strtol(begin, &end, 10);
|
||||
|
||||
if (begin == end)
|
||||
return -1;
|
||||
value *= 10;
|
||||
|
||||
/* Fraction? We only look at the first digit */
|
||||
if (*end == '.') {
|
||||
end++;
|
||||
if (!isdigit(*end))
|
||||
return -1;
|
||||
value += *end - '0';
|
||||
unsigned fraction = 0;
|
||||
for (unsigned i = 0; i < decimals; i++) {
|
||||
value *= 10;
|
||||
|
||||
end++;
|
||||
|
||||
if (!isdigit(*end))
|
||||
return -1;
|
||||
|
||||
fraction = 10 * fraction + (*end - '0');
|
||||
}
|
||||
value += fraction;
|
||||
|
||||
do {
|
||||
end++;
|
||||
} while (isdigit(*end));
|
||||
|
@ -1159,7 +1170,7 @@ static int get_tenths(const char *begin, const char **endp)
|
|||
|
||||
static int get_permille(const char *begin, const char **end)
|
||||
{
|
||||
int value = get_tenths(begin, end);
|
||||
int value = get_decimals(begin, end, 1);
|
||||
if (value >= 0) {
|
||||
/* Allow a percentage sign */
|
||||
if (**end == '%')
|
||||
|
@ -1222,18 +1233,15 @@ int validate_po2(const char *text, int *mbar_po2)
|
|||
if (!text)
|
||||
return 0;
|
||||
|
||||
po2 = get_tenths(text, &text);
|
||||
po2 = get_decimals(text, &text, 2);
|
||||
if (po2 < 0)
|
||||
return 0;
|
||||
|
||||
while (isspace(*text))
|
||||
text++;
|
||||
|
||||
while (isspace(*text))
|
||||
text++;
|
||||
if (*text)
|
||||
return 0;
|
||||
|
||||
*mbar_po2 = po2 * 100;
|
||||
*mbar_po2 = po2 * 10;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ DivePlannerWidget::DivePlannerWidget(dive &planned_dive, PlannerWidgets *parent)
|
|||
// the depth will be done in settingChanged() since this depends on the chosen units.
|
||||
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::RUNTIME, new SpinBoxDelegate(0, INT_MAX, 1, this));
|
||||
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DURATION, new SpinBoxDelegate(0, 6000, 1, this));
|
||||
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::CCSETPOINT, new DoubleSpinBoxDelegate(0, 2, 0.1, this));
|
||||
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::CCSETPOINT, new DoubleSpinBoxDelegate(0, 2, 0.01, this));
|
||||
|
||||
connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &DivePlannerWidget::settingsChanged);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue