Merge pull request #1066 from lunctis-viribus/master

weatherClock Bangle.js 2 layout compatibility
master
Gordon Williams 2021-12-13 10:14:32 +00:00 committed by GitHub
commit e725e3c6f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 11 deletions

View File

@ -4749,7 +4749,7 @@
{ {
"id": "weatherClock", "id": "weatherClock",
"name": "Weather Clock", "name": "Weather Clock",
"version": "0.03", "version": "0.04",
"description": "A clock which displays current weather conditions (requires Gadgetbridge and Weather apps).", "description": "A clock which displays current weather conditions (requires Gadgetbridge and Weather apps).",
"icon": "app.png", "icon": "app.png",
"screenshots": [{"url":"screens/screen1.png"}], "screenshots": [{"url":"screens/screen1.png"}],

View File

@ -1,3 +1,4 @@
0.01: New App! 0.01: New App!
0.02: Minor layout format tweak so it uses less memory and draws ok on Bangle.js 1 (#1012) 0.02: Minor layout format tweak so it uses less memory and draws ok on Bangle.js 1 (#1012)
0.03: Minor layout extra spaces. 0.03: Minor layout extra spaces.
0.04: Layout now compatible with Bangle.js 2

View File

@ -73,12 +73,10 @@ var clockLayout = new Layout( {
{type: "img", filly: 1, id: "weatherIcon", src: sunIcon}, {type: "img", filly: 1, id: "weatherIcon", src: sunIcon},
{type: "v", fillx:1, c: [ {type: "v", fillx:1, c: [
{type: "h", c: [ {type: "h", c: [
{type: "txt", font: "10%", id: "temp", label: "000"}, {type: "txt", font: "10%", id: "temp", label: "000 °C"},
{type: "txt", font: "10%", id: "tempUnit", label: "°C"},
]}, ]},
{type: "h", c: [ {type: "h", c: [
{type: "txt", font: "10%", id: "wind", label: "00"}, {type: "txt", font: "10%", id: "wind", label: "00 km/h"},
{type: "txt", font: "10%", id: "windUnit", label: "km/h"},
]} ]}
] ]
}, },
@ -106,18 +104,14 @@ function draw() {
if(weatherJson && weatherJson.weather){ if(weatherJson && weatherJson.weather){
var currentWeather = weatherJson.weather; var currentWeather = weatherJson.weather;
const temp = locale.temp(currentWeather.temp-273.15).match(/^(\D*\d*)(.*)$/); const temp = locale.temp(currentWeather.temp-273.15).match(/^(\D*\d*)(.*)$/);
clockLayout.temp.label = temp[1]; clockLayout.temp.label = temp[1] + " " + temp[2];
clockLayout.tempUnit.label = temp[2];
clockLayout.weatherIcon.src = chooseIcon(currentWeather.txt); clockLayout.weatherIcon.src = chooseIcon(currentWeather.txt);
const wind = locale.speed(currentWeather.wind).match(/^(\D*\d*)(.*)$/); const wind = locale.speed(currentWeather.wind).match(/^(\D*\d*)(.*)$/);
clockLayout.wind.label = wind[1] + " ".repeat(wind[2].length-1); clockLayout.wind.label = wind[1] + " " + wind[2] + " " + (currentWeather.wrose||'').toUpperCase();
clockLayout.windUnit.label = wind[2] + " " + (currentWeather.wrose||'').toUpperCase();
} }
else{ else{
clockLayout.temp.label = "Err"; clockLayout.temp.label = "Err";
clockLayout.tempUnit.label = "";
clockLayout.wind.label = "No Data"; clockLayout.wind.label = "No Data";
clockLayout.windUnit.label = "";
clockLayout.weatherIcon.src = errIcon; clockLayout.weatherIcon.src = errIcon;
} }
clockLayout.clear(); clockLayout.clear();