Added humidity

pull/1269/head
David Peer 2022-01-11 21:24:23 +01:00
parent 755f44cf3f
commit 1f06e6cfc5
3 changed files with 25 additions and 14 deletions

View File

@ -24,6 +24,7 @@ To contribute you can open a PR at this [GitHub Repo]( https://github.com/peerda
* VREF - Voltage of battery
* HRM - Last measured HRM
* Temp - Weather temperature loaded via the weather module + gadgetbridge
* Humidity - Humidity loaded via the weather module + gadgetbridge
* CoreT - Temperature of device
## Multiple screens support

View File

@ -3,9 +3,9 @@ const locale = require('locale');
const storage = require('Storage')
let settings = {
alarm: -1,
dataRow1: "Battery",
dataRow2: "Steps",
dataRow3: "Temp."
dataRow1: "Steps",
dataRow2: "Temp",
dataRow3: "Battery"
};
let saved_settings = storage.readJSON(SETTINGS_FILE, 1) || settings;
for (const key in saved_settings) {
@ -140,6 +140,11 @@ function printData(key, y, c){
var weather = getWeather();
value = locale.temp(parseInt(weather.temp-273.15));
} else if (key == "HUMIDITY"){
text = "HUM";
var weather = getWeather();
value = parseInt(weather.hum) + "%";
} else if(key == "CORET"){
value = locale.temp(parseInt(E.getTemperature()));
}
@ -418,17 +423,22 @@ function getSteps() {
function getWeather(){
let weather;
var weather = {
temp: 0,
hum: 0,
txt: "",
wind: 0,
wdir: 0,
wrose: ""
};
try {
weather = require('weather');
weather = require('weather').get();
} catch(ex) {
return {
temp: 0.0
};
// Return default
}
return weather.get();
return weather;
}

View File

@ -7,7 +7,7 @@
alarm: -1,
dataRow1: "Battery",
dataRow2: "Steps",
dataRow3: "Temp."
dataRow3: "Temp"
};
let saved_settings = storage.readJSON(SETTINGS_FILE, 1) || settings;
for (const key in saved_settings) {
@ -18,14 +18,14 @@
storage.write(SETTINGS_FILE, settings)
}
var data_options = ["Steps", "Battery", "VREF", "HRM", "Temp", "CoreT"];
var data_options = ["Steps", "Battery", "VREF", "HRM", "Temp", "Humidity", "CoreT"];
E.showMenu({
'': { 'title': 'LCARS Clock' },
'< Back': back,
'Row 1': {
value: 0 | data_options.indexOf(settings.dataRow1),
min: 0, max: 5,
min: 0, max: 6,
format: v => data_options[v],
onchange: v => {
settings.dataRow1 = data_options[v];
@ -34,7 +34,7 @@
},
'Row 2': {
value: 0 | data_options.indexOf(settings.dataRow2),
min: 0, max: 5,
min: 0, max: 6,
format: v => data_options[v],
onchange: v => {
settings.dataRow2 = data_options[v];
@ -43,7 +43,7 @@
},
'Row 3': {
value: 0 | data_options.indexOf(settings.dataRow3),
min: 0, max: 5,
min: 0, max: 6,
format: v => data_options[v],
onchange: v => {
settings.dataRow3 = data_options[v];