From dc7bbe8099d479d7a241fc64e07399e075e18978 Mon Sep 17 00:00:00 2001 From: steffen Date: Sat, 5 Dec 2020 17:36:29 +0000 Subject: [PATCH] update division by zero --- ChangeLog | 3 +++ server/locomotive.cc | 2 +- webinterface/locomotive.js | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3d4a2a6..d283fb9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2020-12-05: +- locomotive fixed division by zero + 2020-11-29: - lococtrl display is now working with reverse and forward. diff --git a/server/locomotive.cc b/server/locomotive.cc index 3f7a395..940eac0 100644 --- a/server/locomotive.cc +++ b/server/locomotive.cc @@ -263,7 +263,7 @@ int Locomotives::SetSpeedFromBus(string ifname, int addr, int speed) { case LOCO_INT_DCC14: maxstep = 14; break; case LOCO_INT_DCC28: maxstep = 28; break; case LOCO_INT_DCC128: maxstep = 126; break; - default: maxstep = 0; break; + default: maxstep = -1; break; } if (speed == 0) locomotives[i].speed = 0; diff --git a/webinterface/locomotive.js b/webinterface/locomotive.js index 64c95f9..4e7fd2b 100644 --- a/webinterface/locomotive.js +++ b/webinterface/locomotive.js @@ -391,7 +391,7 @@ function locolist_show() { var win = document.getElementById("locolist"); debug ("locolist_show"); - + if (!win) { debug ("locolist_show create window"); win = gWindowCreate("locolist", "Locomotives", 400, 500, " \ @@ -417,8 +417,10 @@ function locolist_show() { // append all locomotives for (var i = 0; i < locomotives.length; i++) { let li = document.createElement("li"); + li.appendChild(document.createTextNode(locomotives[i].name)); li.setAttribute("id", "locol_elm_"+locomotives[i].name); + ul.appendChild(li); gAddEventListener("locol_elm_"+locomotives[i].name, 'click', locolist_clicked); @@ -512,7 +514,7 @@ function lococtrl_speed() { let speed = this.value; if (reverse.innerHTML == "REV") speed = -speed; - + debug ("Speed Loco:'"+name+"' Speed:'"+speed+"'"); for (var i = 0; i < locomotives.length; i++) { if (name == locomotives[i].name) {