From 099e504d3f4fc554ef32f0378a6e2e68fe46f5e9 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Fri, 16 Aug 2024 21:58:34 +0200 Subject: [PATCH] sixths: fix alt up/down counts. --- apps/sixths/sixths.app.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/sixths/sixths.app.js b/apps/sixths/sixths.app.js index 160847020..10c18255f 100644 --- a/apps/sixths/sixths.app.js +++ b/apps/sixths/sixths.app.js @@ -721,7 +721,7 @@ function walkHandle() { if (this_step - prev_step > 100 || 1 || step - this_step > 100) { - msg += fmt.fmtSteps((this_step - prev_step) * 12); + //msg += fmt.fmtSteps((this_step - prev_step) * 12); let dir = ext_alt > base_alt; /* 1.. climb */ if (!dir) dir = -1; @@ -731,8 +731,8 @@ function walkHandle() { ext_alt = cur; } } + let diff = ext_alt - base_alt; if (cur*dir < (ext_alt - hyst*dir)*dir) { - let diff = ext_alt - base_alt; if (1 == dir) { tot_up += diff; } @@ -742,8 +742,15 @@ function walkHandle() { base_alt = ext_alt; ext_alt = cur; } + let tmp_down = tot_down, tmp_up = tot_up; + if (1 == dir) { + tmp_up += diff; + } + if (-1 == dir) { + tmp_down += -diff; + } - msg += " " + fmt.fmtAlt(tot_down-cur+base_alt) + " " + fmt.fmtAlt(tot_up+cur-base_alt); + msg += " " + fmt.fmtAlt(tmp_down) + " " + fmt.fmtAlt(tmp_up); return msg + "\n"; }