master
Erik Andresen 2025-05-04 10:15:34 +02:00
parent dd0d5b2cd4
commit 359a75f5c2
2 changed files with 41 additions and 41 deletions

View File

@ -38,23 +38,23 @@ Z: /*LANG*/'Stormy, much rain',
};
const ZAMBRETTI_FALLING = {
1050: 'A',
1040: 'B',
1024: 'C',
1018: 'H',
1010: 'O',
1004: 'R',
1050: 'A',
1040: 'B',
1024: 'C',
1018: 'H',
1010: 'O',
1004: 'R',
998: 'U',
991: 'V',
985: 'X',
};
const ZAMBRETTI_STEADY = {
1033: 'A',
1023: 'B',
1014: 'E',
1008: 'K',
1000: 'N',
1033: 'A',
1023: 'B',
1014: 'E',
1008: 'K',
1000: 'N',
994: 'P',
989: 'S',
981: 'W',
@ -63,11 +63,11 @@ const ZAMBRETTI_STEADY = {
};
const ZAMBRETTI_RISING = {
1030: 'A',
1022: 'B',
1012: 'C',
1007: 'F',
1000: 'G',
1030: 'A',
1022: 'B',
1012: 'C',
1007: 'F',
1000: 'G',
995: 'I',
990: 'J',
984: 'L',
@ -132,7 +132,7 @@ function showMenu() {
loadSettings();
showMenu();
}),
'Plot history': () => {E.showMenu(); history();},
'Plot history': () => {E.showMenu(); plot();},
};
E.showMenu(menu);
}
@ -181,7 +181,7 @@ function show() {
Bangle.getPressure().then(p =>{if (p) draw(p.temperature);});
}
function history() {
function plot() {
const interval = 15; // minutes
const history3 = require('Storage').readJSON("zambretti.log.json", true) || []; // history of recent 3 hours

View File

@ -4,11 +4,11 @@
const history3 = require('Storage').readJSON(LOG_FILE, true) || []; // history of recent 3 hours
let currentPressures = [];
isValidPressureValue = (pressure) => {
const isValidPressureValue = (pressure) => {
return !(pressure == undefined || pressure <= 0);
};
calculcate3hAveragePressure = () => {
const calculcate3hAveragePressure = () => {
if (history3 != undefined && history3.length > 0) {
let sum = 0;
for (let i = 0; i < history3.length; i++) {
@ -20,7 +20,7 @@
}
};
handlePressureValue = (pressure) => {
const handlePressureValue = (pressure) => {
if (pressure == undefined || pressure <= 0) {
return;
}
@ -50,7 +50,7 @@
calculcate3hAveragePressure();
};
barometerPressureHandler = (e) => {
const barometerPressureHandler = (e) => {
const MEDIANLENGTH = 20;
while (currentPressures.length > MEDIANLENGTH)
currentPressures.pop();
@ -62,7 +62,7 @@
if (median.length > 10) {
var mid = median.length >> 1;
medianPressure = Math.round(E.sum(median.slice(mid - 4, mid + 5)) / 9);
let medianPressure = Math.round(E.sum(median.slice(mid - 4, mid + 5)) / 9);
if (medianPressure > 0) {
turnOff();
handlePressureValue(medianPressure);
@ -78,13 +78,13 @@
take the middle one (median)
turn off barometer power
*/
getPressureValue = () => {
const getPressureValue = () => {
Bangle.setBarometerPower(true, "zambretti");
Bangle.on('pressure', barometerPressureHandler);
setTimeout(turnOff, 30000);
};
turnOff = () => {
const turnOff = () => {
Bangle.removeListener('pressure', barometerPressureHandler);
Bangle.setBarometerPower(false, "zambretti");
};