forked from FOSS/BangleApps
thermom 0.05: Use temperature from current locale
+ Update every 10s, average last 5 readings + Changes based on #1092master
parent
9b429fff22
commit
62900059ad
|
@ -4014,8 +4014,8 @@
|
|||
{
|
||||
"id": "thermom",
|
||||
"name": "Thermometer",
|
||||
"version": "0.04",
|
||||
"description": "Displays the current temperature in degree Celsius, updated every 20 seconds",
|
||||
"version": "0.05",
|
||||
"description": "Displays the current temperature in degree Celsius/Fahrenheit (depending on locale), updates every 10 seconds with average of last 5 readings.",
|
||||
"icon": "app.png",
|
||||
"tags": "tool",
|
||||
"supports": ["BANGLEJS", "BANGLEJS2"],
|
||||
|
@ -4080,7 +4080,7 @@
|
|||
"id": "thermomF",
|
||||
"name": "Fahrenheit Temp",
|
||||
"version": "0.01",
|
||||
"description": "A modification of the Thermometer App to display temprature in Fahrenheit",
|
||||
"description": "[NOT RECOMMENDED] A modification of the Thermometer App to display temprature in Fahrenheit. Please use the 'Thermometer App' and install 'Languages' to get the temperature in the correct format for your locale.",
|
||||
"icon": "thermf.png",
|
||||
"tags": "tool",
|
||||
"supports": ["BANGLEJS"],
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
0.02: New App!
|
||||
0.03: Improved messages and added Celsius sign
|
||||
0.04: Make temperature value readable on smaller screens
|
||||
0.05: Use temperature from current locale
|
||||
Update every 10s, average last 5 readings
|
||||
Changes based on #1092
|
||||
|
|
|
@ -1,13 +1,27 @@
|
|||
// history of temperature readings
|
||||
var history = [];
|
||||
|
||||
|
||||
// When we get temperature...
|
||||
function onTemperature(p) {
|
||||
g.reset(1).clearRect(0,24,g.getWidth(),g.getHeight());
|
||||
var rect = Bangle.appRect;
|
||||
g.reset(1).clearRect(rect.x, rect.y, rect.x2, rect.y2);
|
||||
g.setFont("6x8",2).setFontAlign(0,0);
|
||||
var x = g.getWidth()/2;
|
||||
var y = g.getHeight()/2 + 10;
|
||||
var x = (rect.x+rect.x2)/2;
|
||||
var y = (rect.y+rect.y2)/2 + 10;
|
||||
g.drawString("Temperature:", x, y - 45);
|
||||
g.setFontVector(g.getWidth() > 200 ? 70 : 40).setFontAlign(0,0);
|
||||
g.drawString(p.temperature.toFixed(1) + " °C", x, y);
|
||||
g.setFontVector(g.getWidth() > 200 ? 70 : 50).setFontAlign(0,0);
|
||||
|
||||
// Average the last 5 temperature readings
|
||||
while (history.length>4) history.shift();
|
||||
history.push(p.temperature);
|
||||
var avrTemp = E.sum(history) / history.length;
|
||||
// Draw the temperature
|
||||
var t = require('locale').temp(avrTemp).replace("'","°");
|
||||
g.drawString(t, x, y);
|
||||
}
|
||||
|
||||
// Gets the temperature in the most accurate way (pressure sensor or inbuilt thermistor)
|
||||
function drawTemperature() {
|
||||
if (Bangle.getPressure) {
|
||||
Bangle.getPressure().then(onTemperature);
|
||||
|
@ -18,11 +32,10 @@ function drawTemperature() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
setInterval(function() {
|
||||
drawTemperature();
|
||||
}, 20000);
|
||||
drawTemperature();
|
||||
}, 10000);
|
||||
E.showMessage("Reading temperature...");
|
||||
drawTemperature();
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
|
|
Loading…
Reference in New Issue