diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..e8a127b --- /dev/null +++ b/readme.md @@ -0,0 +1,20 @@ +Wallas DT/GB Heater Controller on an ESP32C3 +============================================ + +## Getting Started + +As described in the chapter on Risc-V target installation in the [Rust on ESP Book](https://docs.esp-rs.org/book/installation/riscv.html), +you should install the ESP32c3 target for your rust toolchain by doing: + +```bash +rustup toolchain install stable --component rust-src +rustup target add riscv32imc-unknown-none-elf +``` + +It is advised to run the `--release` version of the application, thus to build and run, do: + +```bash +cargo build --release +cargo run --release +``` + diff --git a/src/httpd.rs b/src/httpd.rs index 3cfff90..877cb17 100644 --- a/src/httpd.rs +++ b/src/httpd.rs @@ -117,12 +117,12 @@ fn page(heading: &str, content: Markup) -> Markup { br; "RISC-V is a registered trademark of RISC-V International · Wallas is a registered trademark of Wallas-Marin Oy · Espressif is a registered trademark of Espressif Systems" } - dialog #message .dialog-center; + dialog #message .dialog-center {}; dialog #"set-target" .dialog-center { span ."cancel-x" { "🗙" }; form { div #"temperature-form" { - input #target type="tage" min="5" max="25" name="target"; + input #target type="range" min="5" max="25" name="target"; br; label #"target-label" for="target" { "Target temperature in °C" }; br; diff --git a/src/static/app.js b/src/static/app.js index d1f32e7..30972f6 100644 --- a/src/static/app.js +++ b/src/static/app.js @@ -46,7 +46,7 @@ async function LoadLatest(platest) { target = json.target; platest.innerHTML = `Temperature was ${temperature}°C at ${time} UTC, target temperature was ${target}°C`; } - }) + }).catch((error) => { console.log("server unable to respond") }); await sleep(10000); } }; @@ -125,10 +125,9 @@ async function LoadGraph(pgraph) { target_polyline = appendSVGElement(svg, "polyline", {"class": "data target", "points": target_points_str}); temperature_polyline = appendSVGElement(svg, "polyline", {"class": "data temperature", "points": temperature_points_str}); - //temperature_polyline.onmouseover = () => { console.log("yup"); }; pgraph.replaceChildren(graph); } - }) + }).catch((error) => { console.log("server unable to respond"); }); await sleep(10000); } } @@ -136,7 +135,6 @@ async function LoadGraph(pgraph) { async function set_temperature_dialog() { var target = null; await fetch("/api/v1/latest").then((response) => response.json()).then((json) => { - console.log(json); if (json.target) { if (json.target < 5) { target = 5; @@ -146,7 +144,8 @@ async function set_temperature_dialog() { target = json.target; } } - }); + }).catch((error) => { console.log("server unable to respond"); }); + if (target == null) return; var dialog = document.querySelector("dialog#set-target"); dialog.showModal(); var target_label = document.querySelector("label#target-label"); @@ -177,11 +176,12 @@ async function wallas_command(cmd, no_atok, success) { } else if (response.status == 204) { dialog.innerHTML = success; } else { - dialog.innerHTML = "Trouble communicating with Wallas Heater, try again later"; + dialog.innerHTML = "Controller has trouble communicating with Wallas Heater, try again later"; } - setTimeout(() => { - dialog.close(); - }, 5000); - }); -} + }).catch((error) => { console.log("server unable to respond"); + dialog.innerHTML = "Controller is unable to respond"; }); + setTimeout(() => { + dialog.close(); + }, 5000); + } diff --git a/src/static/styles.css b/src/static/styles.css index 56342d0..d4536ec 100644 --- a/src/static/styles.css +++ b/src/static/styles.css @@ -83,6 +83,7 @@ button { background-color: rgb(160, 171, 185); border: 2px solid rgb(160, 171, 185); padding: 15px; + margin: 0 0.5em 0 0.5em; border-radius: 5px; } button:hover {