Skip to content

Commit

Permalink
Set blinking and removed error warning (#10)
Browse files Browse the repository at this point in the history
* blinking is in settings

* removed error checking
  • Loading branch information
Floskinner committed Nov 25, 2022
1 parent b35686e commit abfa9a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 29 deletions.
33 changes: 4 additions & 29 deletions static/javascript/mySockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const MAX_ABOVE_RED = 1.20;
const MAX_BELOW_ORANGE = 0.86;
const MAX_BELOW_RED = 0.80;

let blinking = false;

socket.on('connect', function () {
let browserTime = new Date().toISOString();

Expand Down Expand Up @@ -47,13 +49,10 @@ socket.on('newValues', function (values) {
applyWarningColors($("#lamda1"), lamda1);
applyWarningColors($("#lamda2"), lamda2);

checkErrors($('#bank1Label'), $('#lamda1'), $('#afr1'), voltage1);
checkErrors($('#bank2Label'), $('#lamda2'), $('#afr2'), voltage2);

if (lamda1 >= MAX_ABOVE_RED || lamda1 <= MAX_BELOW_RED) {
if ((lamda1 >= MAX_ABOVE_RED || lamda1 <= MAX_BELOW_RED) && blinking) {
applyRedBlinking($("#lamda1"));
}
if (lamda2 >= MAX_ABOVE_RED || lamda2 <= MAX_BELOW_RED) {
if ((lamda2 >= MAX_ABOVE_RED || lamda2 <= MAX_BELOW_RED) && blinking) {
applyRedBlinking($("#lamda2"));
}
});
Expand All @@ -68,30 +67,6 @@ function updateValuesOnScreen(lamda1, lamda2, afr1, afr2) {
$('#afr2').html(afr2.toFixed(2) + " AFR");
}

function checkErrors(htmlBankLabel, htmlLamda, htmlAFR, voltage) {
label = htmlBankLabel.html();
color = "#000000";
lamda = htmlLamda.html();
afr = htmlAFR.html();

if (Math.abs(voltage) <= 0.15) {
// label += " - Fehler";
color = "#b30000";
lamda = "Fehler";
afr = "--------";
} else if (Math.abs(voltage) <= 0.2) {
// label += " - Heizphase";
color = "#b30000";
lamda = "Heizphase";
afr = "--------";
}

htmlBankLabel.html(label);
htmlBankLabel.css("color", color);
htmlLamda.html(lamda);
htmlAFR.html(afr);
}

function applyWarningColors(htmlElement, lamdaValue) {
// Sind die Werte von Lamda entsprechend, wird der Text erst Orange und dann Rot
if (lamdaValue >= MAX_ABOVE_ORANGE || lamdaValue <= MAX_BELOW_ORANGE) {
Expand Down
8 changes: 8 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ <h4>Anzuzeigende Nachkommastellen:</h4>
<input class="w3-radio" type="radio" name="nachkommastellen" value="3">
<label>3</label><br>

<h4>Blinken der Werte im roten Bereich:</h4>
<input class="w3-check" type="checkbox" onchange=toggle_blinking(this)>
<label>Blinken</label><br>

<hr>

<h4>Korrekturfaktor für Lamdaberechnung:</h4>
Expand Down Expand Up @@ -208,6 +212,10 @@ <h4>Korrekturfaktor für Lamdaberechnung:</h4>
$('#warning').toggle();
}

function toggle_blinking(checkbox) {
blinking = checkbox.checked;
}

</script>

</html>

0 comments on commit abfa9a9

Please sign in to comment.