Fixed bug with slider sending wrong ID in web page. Honours fixed/thermostat mode from heater info.

This commit is contained in:
rljonesau 2018-12-16 01:09:10 +11:00
parent ff6715e018
commit 4a3a28540b
2 changed files with 24 additions and 7 deletions

View file

@ -51,7 +51,7 @@ void interpretJsonCommand(char* pLine)
JsonObject::iterator it;
for(it = obj.begin(); it != obj.end(); ++it) {
if(strcmp("DesiredTemp", it->key) == 0) {
if(strcmp("TempDesired", it->key) == 0) {
reqTemp(it->value.as<unsigned char>());
}
else if(strcmp("RunState", it->key) == 0) {

View file

@ -169,6 +169,21 @@ window.onload = function() {
case "ErrorState":
console.log("JSON Rx: ErrorState:", heater.ErrorState);
break;
case "Thermostat":
console.log("JSON Rx: Thermostat:", heater.Thermostat);
if(heater.Thermostat) {
document.getElementById("FixedDiv").hidden = true;
document.getElementById("ThermoDiv").hidden = false;
}
else {
document.getElementById("FixedDiv").hidden = false;
document.getElementById("ThermoDiv").hidden = true;
}
break;
case "PumpFixed":
console.log("JSON Rx: Thermostat:", heater.PumpFixed);
document.getElementById("PumpFixed").innerHTML = heater.PumpFixed;
break;
}
}
}
@ -268,10 +283,8 @@ function onSlide(newVal, JSONKey) {
document.getElementById(JSONKey).innerHTML = newVal;
const cmd = { JSONKey: 0 };
cmd.JSONKey = newVal;
var str = JSON.stringify(cmd);
// hand carve JSON string - cannot get JSON.stringify to co-operate with a variable as the key
var str = '{\"' + JSONKey + '\":' + newVal + '}';
console.log("JSON Tx:", str);
Socket.send(str);
}
@ -469,11 +482,15 @@ MainPage {
<h2>Temperature Control</h2>
</div>
<input type="range" id="slide" min="8" max="35" step="1" value="22" oninput="onSlide(this.value, 'TempDesired')" onchange="onSlide(this.value, 'TempDesired')">
<div>
<div id="ThermoDiv">
<b>Desired Temp: </b>
<span id="TempDesired"></span>
<div>
</div>
<div id="FixedDiv">
<b>Fixed Hz: </b>
<span id="PumpFixed"></span>
</div>
<div>
<b>Current Temp: </b><span id="TempCurrent">
</div>
</span>