Add support for second voltage column

This commit is contained in:
Kelvin Ly 2023-07-30 23:52:43 -04:00
parent c7ace97ef0
commit dcf8069f68
1 changed files with 8 additions and 0 deletions

View File

@ -36,9 +36,11 @@ function initCharts() {
columns: [
['time', 1, 2, 3, 4],
['voltage', 24, 24.5, 24.3, 24.6],
['voltage2', 24, 24.5, 24.3, 24.6],
],
axes: {
voltage: 'y',
voltage2: 'y',
}
},
axis: {
@ -62,6 +64,7 @@ var time = []
var temp = []
var humd = []
var volts = []
var volts2 = []
function status(msg) {
document.getElementById('status').textContent = msg
@ -112,6 +115,7 @@ async function updateCharts() {
temp.push(v.temp)
humd.push(v.hum)
volts.push(v.hv)
volts2.push(v.hv2)
}
})
// truncate all the lists as necessary
@ -131,11 +135,13 @@ async function updateCharts() {
temp = temp.slice(slice_idx)
humd = humd.slice(slice_idx)
volts = volts.slice(slice_idx)
volts2 = volts2.slice(slice_idx)
time = time.slice(slice_idx)
const temp_d = temp.filter((_, idx) => (idx % decimation_rate) == 0)
const humd_d = humd.filter((_, idx) => (idx % decimation_rate) == 0)
const volts_d = volts.filter((_, idx) => (idx % decimation_rate) == 0)
const volts2_d = volts2.filter((_, idx) => (idx % decimation_rate) == 0)
const time_d = time.filter((_, idx) => (idx % decimation_rate) == 0)
chart.load({
@ -149,6 +155,7 @@ async function updateCharts() {
columns: [
["time"].concat(time_d),
["voltage"].concat(volts_d),
["voltage2"].concat(volts2_d),
]
})
status("charts updated")
@ -263,6 +270,7 @@ window.onload = () => {
temp = []
humd = []
volts = []
volts2 = []
}
}
})