aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShadify <boomkin1234@hotmail.com>2017-12-04 10:01:06 +0100
committerShadify <boomkin1234@hotmail.com>2017-12-04 10:01:06 +0100
commit074799d1471df407663931d6654847fa38484a3e (patch)
treec6dc3169407077e4aee786a5b52a7d5637c4d2f3 /web/js/realtime.js
parentccf443791736af36391e9274a5633ef2269ecfc0 (diff)
Fixed breakpoint in AQI calculation
Diffstat (limited to 'web/js/realtime.js')
-rw-r--r--web/js/realtime.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/web/js/realtime.js b/web/js/realtime.js
index 27cb25c..e090d05 100644
--- a/web/js/realtime.js
+++ b/web/js/realtime.js
@@ -30,12 +30,12 @@ function calculateAQI(gasName, concentration) {
var bpLowIndex, bpHiIndex;
table[gasName].breakpoints.forEach(function(value, index) {
- if(value < concentration && table[gasName].breakpoints[index + 1] > concentration) {
+ if(value <= concentration && table[gasName].breakpoints[index + 1] >= concentration) {
bpLow = value;
bpLowIndex = index;
}
- if(value > concentration && table[gasName].breakpoints[index - 1] < concentration) {
+ if(value >= concentration && table[gasName].breakpoints[index - 1] <= concentration) {
bpHi = value;
bpHiIndex = index;
}
@@ -75,6 +75,7 @@ function update() {
indexes.push(NO);
indexes.push(SO);
+
var max = arrayMax(indexes);
document.querySelector("#aq").innerHTML = `The current air quality index is <strong>${max}</strong>`;