From 752b6b8e614a43bfa6f370dd0999027bbcb090ad Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Wed, 31 Jul 2013 12:08:03 +0200 Subject: [PATCH] avoid unnecessary write after read --- web/htdocs/thresh/threshold.htm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/web/htdocs/thresh/threshold.htm b/web/htdocs/thresh/threshold.htm index c775d67..d566de5 100644 --- a/web/htdocs/thresh/threshold.htm +++ b/web/htdocs/thresh/threshold.htm @@ -63,6 +63,7 @@ var type = document.getElementById("form_type").value; var reference = document.getElementById("form_ref").value; var updateTask = 0; var total = 0; +var wasRead = 0; function update(bar,scale) { @@ -72,9 +73,14 @@ function update(bar,scale) { document.getElementById("total").innerHTML = total+" - "+Math.round(total/655.36*reference)/100+" mV"; command = (type << 20) + (chan << 16) + (total); command = command.toString(16); - dataWaiting = 1; - if(updateTask == 0) { - updateTask = setTimeout("doUpdate()",updaterate); + if(wasRead == 0) { + dataWaiting = 1; + if(updateTask == 0) { + updateTask = setTimeout("doUpdate()",updaterate); + } + } + else { + wasRead--; } } @@ -108,6 +114,7 @@ function anaret2(d) { var n=d.toLocaleTimeString(); document.getElementById("timeget").innerHTML = n; document.getElementById("timeget").style.background = "transparent"; + wasRead = 2; } -- 2.43.0