88 lines
2.4 KiB
HTML
88 lines
2.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<link
|
|
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
|
|
rel="stylesheet"
|
|
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
|
|
crossorigin="anonymous"
|
|
/>
|
|
<title>ESP8266 Servo Control</title>
|
|
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
|
|
</head>
|
|
|
|
<body>
|
|
<div class="container jumbotron text-center">
|
|
<h1 class="display-4">Water Heater Control</h1>
|
|
<br />
|
|
|
|
<input type="range" id="temperature" name="temperature" min="90" max="120" onchange="setTemperature(this.value)">
|
|
|
|
<br />
|
|
<button type="button" class="btn btn-success btn-lg" id="toSlider">Set to [??]</button>
|
|
<br />
|
|
<br />
|
|
|
|
<button type="button" class="btn btn-danger btn-sm" id="initialize">Initialize to 90</button>
|
|
</div>
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
|
<script
|
|
src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
|
|
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
|
|
crossorigin="anonymous"
|
|
></script>
|
|
<script>
|
|
|
|
var temperature = 90;
|
|
var timer = null;
|
|
|
|
function setTemperature(temp) {
|
|
temperature = temp;
|
|
$("#toSlider").text("Set Temperature: " + temperature)
|
|
console.log("Set Temperature: " + temperature);
|
|
}
|
|
|
|
function action(newTemperature) {
|
|
$("#toSlider").prop("disabled", true);
|
|
$("#temperature").prop("disabled", true);
|
|
console.log(newTemperature);
|
|
setTimeout(() => {
|
|
$("#toSlider").prop("disabled", false);
|
|
$("#temperature").prop("disabled", false);
|
|
|
|
}, 3000);
|
|
|
|
let rotations = newTemperature - 90; //base at 0;
|
|
|
|
$.post("/setTemperature", {
|
|
newTemperature,
|
|
rotations,
|
|
});
|
|
}
|
|
|
|
|
|
$(document).ready(() => {
|
|
$("#to90").on("click", () => {
|
|
action(90);
|
|
setTemperature(90);
|
|
document.getElementById("temperature").value = temperature;
|
|
});
|
|
$("#toSlider").on("click", () => {
|
|
action(temperature);
|
|
});
|
|
$("#initialize").on("click", () => {
|
|
$.post("/initialize");
|
|
})
|
|
|
|
|
|
|
|
document.getElementById("temperature").value = temperature;
|
|
setTemperature(temperature);
|
|
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|