„index.h“ ändern

This commit is contained in:
Michael Clemens // DK1MI 2023-05-20 10:16:41 +00:00
parent 42c5211179
commit 3c0c3aae57

73
index.h
View File

@ -56,8 +56,6 @@ function vumeter(elem, config){
var boxGapFraction = config.boxGapFraction || 0.2; var boxGapFraction = config.boxGapFraction || 0.2;
var jitter = 0;//config.jitter || 0.02; var jitter = 0;//config.jitter || 0.02;
// Colours // Colours
var redOn = 'rgba(255,47,30,0.9)'; var redOn = 'rgba(255,47,30,0.9)';
var redOff = 'rgba(64,12,8,0.9)'; var redOff = 'rgba(64,12,8,0.9)';
@ -86,8 +84,6 @@ function vumeter(elem, config){
var targetVal = parseInt(elem.dataset.val, 10); var targetVal = parseInt(elem.dataset.val, 10);
// Gradual approach // Gradual approach
if (curVal <= targetVal){ if (curVal <= targetVal){
curVal += (targetVal - curVal) / 5; curVal += (targetVal - curVal) / 5;
@ -107,7 +103,6 @@ function vumeter(elem, config){
if (curVal < 0) { if (curVal < 0) {
curVal = 0; curVal = 0;
} }
c.save(); c.save();
c.beginPath(); c.beginPath();
@ -118,8 +113,7 @@ function vumeter(elem, config){
drawBoxes(c, curVal); drawBoxes(c, curVal);
requestAnimationFrame(draw); requestAnimationFrame(draw);
}; };
// Draw the boxes // Draw the boxes
@ -169,43 +163,9 @@ function vumeter(elem, config){
return (id <= maxOn); return (id <= maxOn);
} }
// Trigger the animation
//if (okaytogo) {
draw(); draw();
//}
} }
window.onload = function(){
var fwd_vu_meter = document.getElementById('fwd_vu_meter');
var ref_vu_meter = document.getElementById('ref_vu_meter');
var swr_vu_meter = document.getElementById('swr_vu_meter');
vumeter(fwd_vu_meter, {
"boxCount": 10,
"boxGapFraction": 0.25,
"max": 200,
});
vumeter(ref_vu_meter, {
"boxCount": 10,
"boxGapFraction": 0.25,
"max": 200,
});
vumeter(swr_vu_meter, {
"boxCount": 10,
"boxGapFraction": 0.25,
"max": 2,
});
};
setInterval(function() { setInterval(function() {
// Call a function repetatively // Call a function repetatively
okaytogo = !okaytogo; okaytogo = !okaytogo;
@ -231,11 +191,8 @@ function formatNum(num, separator, fraction) {
return str; return str;
} }
// formatNum(parseFloat(val*1000000).toPrecision(2))
function convert_power(val){ function convert_power(val){
let ret = "0"; let ret = "0";
//if (isNaN(val)) {
if (val < 0.001){ if (val < 0.001){
ret = formatNum(val*1000000,'','.') + " uW"; ret = formatNum(val*1000000,'','.') + " uW";
} else if (val < 1) { } else if (val < 1) {
@ -261,8 +218,8 @@ function getDATA() {
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() { xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
document.getElementById("ref_led_box").style.display = 'none'; //document.getElementById("ref_led_box").style.display = 'none';
document.getElementById("vswr_led_box").style.display = 'none'; //document.getElementById("vswr_led_box").style.display = 'none';
data = this.responseText.split(";"); data = this.responseText.split(";");
if (data[15] == "0") { if (data[15] == "0") {
document.getElementById("FWDWatt").innerHTML = convert_power(data[0]); document.getElementById("FWDWatt").innerHTML = convert_power(data[0]);
@ -277,8 +234,12 @@ function getDATA() {
} else { } else {
document.getElementById("FWDWatt").innerHTML = "---"; document.getElementById("FWDWatt").innerHTML = "---";
document.getElementById("FWDdBm").innerHTML = "---"; document.getElementById("FWDdBm").innerHTML = "---";
document.getElementById("FWDVoltage").innerHTML = "---"; document.getElementById("FWDVoltage").innerHTML = data[2];
fwd_vu_meter.setAttribute('data-val', 0); if (data[17] == "true") {
fwd_vu_meter.setAttribute('data-val', 0);
} else {
document.getElementById("fwd_led_box").style.display = 'none';
}
} }
if (data[16] == "0") { if (data[16] == "0") {
document.getElementById("REFWatt").innerHTML = convert_power(data[3]); document.getElementById("REFWatt").innerHTML = convert_power(data[3]);
@ -293,8 +254,12 @@ function getDATA() {
} else { } else {
document.getElementById("REFWatt").innerHTML = "---"; document.getElementById("REFWatt").innerHTML = "---";
document.getElementById("REFdBm").innerHTML = "---"; document.getElementById("REFdBm").innerHTML = "---";
document.getElementById("REFVoltage").innerHTML = "---"; document.getElementById("REFVoltage").innerHTML = data[5];
ref_vu_meter.setAttribute('data-val', 0); if (data[18] == "true") {
ref_vu_meter.setAttribute('data-val', 0);
} else {
document.getElementById("ref_led_box").style.display = 'none';
}
} }
document.getElementById("VSWRValue").innerHTML = data[6]; document.getElementById("VSWRValue").innerHTML = data[6];
document.getElementById("RLValue").innerHTML = data[7]; document.getElementById("RLValue").innerHTML = data[7];
@ -338,13 +303,16 @@ function getDATA() {
"boxGapFraction": 0.25, "boxGapFraction": 0.25,
"max": strtoint(data[12]*1000000), "max": strtoint(data[12]*1000000),
}); });
vumeter(ref_vu_meter, { vumeter(ref_vu_meter, {
"boxCount": 10, "boxCount": 10,
"boxGapFraction": 0.25, "boxGapFraction": 0.25,
"max": strtoint(data[13]*1000000), "max": strtoint(data[13]*1000000),
}); });
vumeter(swr_vu_meter, {
"boxCount": 10,
"boxGapFraction": 0.25,
"max": 2,
});
} }
}; };
xhttp.open("GET", "readDATA", true); xhttp.open("GET", "readDATA", true);
@ -405,7 +373,6 @@ function getDATA() {
</div> </div>
</div> </div>
<form method='post' action='config'><button class='button' value='config' name='config' type='submit'>Configuration</button></form> <form method='post' action='config'><button class='button' value='config' name='config' type='submit'>Configuration</button></form>
</body> </body>