forked from FOSS/BangleApps
Bugfix: If the weather module does not exist, an exception was thrown. Now its hidden in a function.
parent
d260e7c507
commit
1cdcedc997
|
@ -1,10 +1,5 @@
|
||||||
const SETTINGS_FILE = "lcars.setting.json";
|
const SETTINGS_FILE = "lcars.setting.json";
|
||||||
const Storage = require("Storage");
|
const locale = require('locale');
|
||||||
const weather = require('weather');
|
|
||||||
|
|
||||||
|
|
||||||
// ...and overwrite them with any saved values
|
|
||||||
// This way saved values are preserved if a new version adds more settings
|
|
||||||
const storage = require('Storage')
|
const storage = require('Storage')
|
||||||
let settings = {
|
let settings = {
|
||||||
alarm: -1,
|
alarm: -1,
|
||||||
|
@ -39,7 +34,7 @@ var disableInfoUpdate = true; // When gadgetbridge connects, step infos cannot b
|
||||||
/*
|
/*
|
||||||
* Requirements and globals
|
* Requirements and globals
|
||||||
*/
|
*/
|
||||||
const locale = require('locale');
|
|
||||||
|
|
||||||
var bgLeft = {
|
var bgLeft = {
|
||||||
width : 27, height : 176, bpp : 3,
|
width : 27, height : 176, bpp : 3,
|
||||||
|
@ -124,7 +119,7 @@ function queueDraw() {
|
||||||
function printData(key, y, c){
|
function printData(key, y, c){
|
||||||
g.setFontAlign(-1,-1,0);
|
g.setFontAlign(-1,-1,0);
|
||||||
var text = "ERR";
|
var text = "ERR";
|
||||||
var value = "NOT FOUND";
|
var value = "ERR";
|
||||||
|
|
||||||
if(key == "Battery"){
|
if(key == "Battery"){
|
||||||
text = "BAT";
|
text = "BAT";
|
||||||
|
@ -136,7 +131,7 @@ function printData(key, y, c){
|
||||||
|
|
||||||
} else if(key == "Temp."){
|
} else if(key == "Temp."){
|
||||||
text = "TEMP";
|
text = "TEMP";
|
||||||
value = Math.floor(E.getTemperature()) + "C";
|
value = locale.temp(parseInt(E.getTemperature()));
|
||||||
|
|
||||||
} else if(key == "HRM"){
|
} else if(key == "HRM"){
|
||||||
text = "HRM";
|
text = "HRM";
|
||||||
|
@ -148,12 +143,8 @@ function printData(key, y, c){
|
||||||
|
|
||||||
} else if (key == "Weather"){
|
} else if (key == "Weather"){
|
||||||
text = "TEMP";
|
text = "TEMP";
|
||||||
const w = weather.get();
|
var weather = getWeather();
|
||||||
if (!w) {
|
value = locale.temp(parseInt(weather.temp-273.15));
|
||||||
value = "ERR";
|
|
||||||
} else {
|
|
||||||
value = require('locale').temp(w.temp-273.15); // applies conversion
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setColor(c);
|
g.setColor(c);
|
||||||
|
@ -429,6 +420,21 @@ function getSteps() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getWeather(){
|
||||||
|
let weather;
|
||||||
|
|
||||||
|
try {
|
||||||
|
weather = require('weather');
|
||||||
|
} catch(ex) {
|
||||||
|
return {
|
||||||
|
temp: 0.0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return weather.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle alarm
|
* Handle alarm
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue