got parameter fetch working beta only
This commit is contained in:
+41
-9
@@ -41,21 +41,53 @@ function reloadTerminal() {
|
||||
},
|
||||
body: ''
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
if(data.length > 0) {
|
||||
terminal.innerHTML += data;
|
||||
if (autoscroll.checked)
|
||||
terminal.scrollTop = terminal.scrollHeight;
|
||||
}
|
||||
})
|
||||
.catch(error => console.log('Error:', error));
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
if(data.length > 0) {
|
||||
terminal.innerHTML += data;
|
||||
if (autoscroll.checked)
|
||||
terminal.scrollTop = terminal.scrollHeight;
|
||||
}
|
||||
})
|
||||
.catch(error => console.log('Error:', error));
|
||||
};
|
||||
|
||||
function updateParameters() {
|
||||
fetch('/parameters', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: ''
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(json_str => {
|
||||
const active_pwm = Math.round(json_str.active_pwm / 4095 * 100);
|
||||
document.querySelector('#range_act_pwm').value = active_pwm;
|
||||
document.querySelector('#out_act_pwm').value = active_pwm;
|
||||
|
||||
const idle_pwm_max = Math.round(json_str.idle_pwm_max / json_str.active_pwm * 100);
|
||||
document.querySelector('#range_idl_pwm').value = idle_pwm_max;
|
||||
document.querySelector('#out_idl_pwm').value = idle_pwm_max;
|
||||
|
||||
document.querySelector('#range_tim_sta').value = json_str.time_per_stair;
|
||||
document.querySelector('#out_tim_sta').value = json_str.time_per_stair;
|
||||
|
||||
document.querySelector('#range_tim_ldr').value = json_str.time_ldr;
|
||||
document.querySelector('#out_tim_ldr').value = json_str.time_ldr;
|
||||
|
||||
document.querySelector('#range_ldr_shw').value = json_str.ldr_schwelle;
|
||||
document.querySelector('#out_ldr_shw').value = json_str.ldr_schwelle;
|
||||
|
||||
})
|
||||
.catch(error => console.log('Error:', error));
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
setInterval(reloadTerminal, 1000);
|
||||
setInterval(reloadRangeValues, 1000);
|
||||
|
||||
updateParameters();
|
||||
|
||||
// use data- attributes for action
|
||||
document.querySelectorAll('.control').forEach((button) => {
|
||||
|
||||
Reference in New Issue
Block a user