34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
|
const vdd = document.getElementById('vdd');
|
||
|
const vref = document.getElementById('vref');
|
||
|
const vadj = document.getElementById('vadj');
|
||
|
const ts = document.getElementById('timestamp');
|
||
|
const table = document.getElementById('data');
|
||
|
|
||
|
let old_channel_count=0;
|
||
|
|
||
|
async function update () {
|
||
|
|
||
|
data = await fetch("/data").then((data)=>{return data.json()});
|
||
|
vdd.innerHTML = "V<sub>DD</sub>: " + parseFloat(data["ratio"]["pivdd"]);
|
||
|
vref.innerHTML = "V<sub>REF</sub>: " + parseFloat(data["ratio"]["vref"]);
|
||
|
vadj.innerHTML = "V<sub>ADJ</sub>: " + parseFloat(data["ratio"]["vadj"]);
|
||
|
ts.innerHTML = "Last updated: " + data["time"];
|
||
|
for (let i=0; i<old_channel_count; i++) {
|
||
|
table.deleteRow(-1);
|
||
|
}
|
||
|
old_channel_count =0;
|
||
|
|
||
|
data["channels"].forEach(e => {
|
||
|
let unit = e["unit"];
|
||
|
let value = e["value"];
|
||
|
let channel = e["id"];
|
||
|
|
||
|
let row = table.insertRow(-1);
|
||
|
row.insertCell(0).innerText = channel;
|
||
|
row.insertCell(1).innerText = value;
|
||
|
row.insertCell(2).innerText = unit;
|
||
|
old_channel_count++;
|
||
|
});
|
||
|
}
|
||
|
update();
|
||
|
setInterval(update, 1000);
|