diff --git a/web/js-ts/serialv2.js b/web/js-ts/serialv2.js index c41fadc..f312896 100644 --- a/web/js-ts/serialv2.js +++ b/web/js-ts/serialv2.js @@ -20,6 +20,10 @@ let LichtWaardes; const between = (x, min, max) => { return x >= min && x <= max; }; + document.getElementById("temp").innerHTML = "ESP niet connected"; + document.getElementById("humid").innerHTML = "ESP niet connected"; + document.getElementById("licht").innerHTML = "ESP niet connected"; + document.getElementById("Advies").innerHTML = "ESP niet connected"; // Request a port and open a connection. async function connect() { @@ -141,9 +145,22 @@ function Advies(TempWaardes, LuchtVochtigsheidWaardes, LichtWaardes) { HumidAdvies = "De lucht voelt heel vochtig aan. " } - if (LichtWaardes == 0 < 400) { + if (between(LichtWaardes, 0, 400)) { LichtAdvies = "Zet het licht aan holbewoner." } + if (between(LichtWaardes, 400, 1200)) { + LichtAdvies = "Het is nog een beetje donker hier maar je kan er prima zien." + } + + if (between(LichtWaardes, 1200, 3000)) { + LichtAdvies = "Het is licht" + } + + if (between(LichtWaardes, 3000, 6900)) { + LichtAdvies = "Het is heel licht" + } + + } function AdviesUpdate(){