0.07: Ensure barometer gets turned off after a few readings (isBarometerOn broken in 2v16)
parent
769c4c2793
commit
cc24cb5bb3
|
|
@ -7,3 +7,4 @@
|
|||
Show difference of last measurement to pressure average of the the last three hours in the widget
|
||||
Only use valid pressure values
|
||||
0.06: Fix exception
|
||||
0.07: Ensure barometer gets turned off after a few readings (isBarometerOn broken in 2v16)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"id": "widbaroalarm",
|
||||
"name": "Barometer Alarm Widget",
|
||||
"shortName": "Barometer Alarm",
|
||||
"version": "0.06",
|
||||
"version": "0.07",
|
||||
"description": "A widget that can alarm on when the pressure reaches defined thresholds.",
|
||||
"icon": "widget.png",
|
||||
"type": "widget",
|
||||
|
|
|
|||
|
|
@ -211,19 +211,8 @@ function calculcate3hAveragePressure() {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
turn on barometer power
|
||||
take multiple measurements
|
||||
sort the results
|
||||
take the middle one (median)
|
||||
turn off barometer power
|
||||
*/
|
||||
function getPressureValue() {
|
||||
if (stop)
|
||||
return;
|
||||
function barometerPressureHandler(e) {
|
||||
const MEDIANLENGTH = 20;
|
||||
Bangle.setBarometerPower(true, "widbaroalarm");
|
||||
Bangle.on('pressure', function(e) {
|
||||
while (currentPressures.length > MEDIANLENGTH)
|
||||
currentPressures.pop();
|
||||
|
||||
|
|
@ -242,13 +231,24 @@ function getPressureValue() {
|
|||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout(function() { turnOff(); }, 30000);
|
||||
/*
|
||||
turn on barometer power
|
||||
take multiple measurements
|
||||
sort the results
|
||||
take the middle one (median)
|
||||
turn off barometer power
|
||||
*/
|
||||
function getPressureValue() {
|
||||
if (stop) return;
|
||||
Bangle.setBarometerPower(true, "widbaroalarm");
|
||||
Bangle.on('pressure', barometerPressureHandler);
|
||||
setTimeout(turnOff, 30000);
|
||||
}
|
||||
|
||||
function turnOff() {
|
||||
if (Bangle.isBarometerOn())
|
||||
Bangle.removeListener('pressure', barometerPressureHandler);
|
||||
Bangle.setBarometerPower(false, "widbaroalarm");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue