diff --git a/apps/timecal/README.md b/apps/timecal/README.md index 8c5d619ad..c14e27c8e 100644 --- a/apps/timecal/README.md +++ b/apps/timecal/README.md @@ -5,6 +5,7 @@ Shows the * Date * Time (hh:mm) - respecting 12/24 (uses locale string) * 3 weeks calendar view (last,current and next week) +* Weather icon and temperature - if weather app is set up ### The settings menu Calendar View can be customized @@ -13,6 +14,7 @@ Calendar View can be customized * Start wday: Set day of week start. Values: 0=Sunday, 1=Monday,...,6=Saturday or -1=Relative to today [default 0: Sunday] * Su color: Set Sundays color. Values: none [default], red, green or blue * Border: show or none [default] +* Weather: show or none [default] * Submenu Today settings - choose how today is highlighted * < Back: * Color: none, red [default], green or blue diff --git a/apps/timecal/timecal.app.js b/apps/timecal/timecal.app.js index 8b1acbabc..034888103 100644 --- a/apps/timecal/timecal.app.js +++ b/apps/timecal/timecal.app.js @@ -29,7 +29,8 @@ class TimeCalClock{ suClr:1, //0:fg, 1:red=#E00, 2:green=#0E0, 3:blue=#00E //phColor:"#E00", //public holiday - calBrdr:false + calBrdr:false, + showWeather:false }; for (const k in this._settings) if (!defaults.hasOwnProperty(k)) delete this._settings[k]; //remove invalid settings for (const k in defaults) if(!this._settings.hasOwnProperty(k)) this._settings[k] = defaults[k]; //assign missing defaults @@ -41,7 +42,7 @@ class TimeCalClock{ // X coord to center date and time text at this.dtCenterX = Bangle.appRect.w/2; - this.hasWeather = require('weather') && require('weather').get(); + this.hasWeather = this.settings().showWeather && require('weather') && require('weather').get(); if(this.hasWeather){ this.dtCenterX =2*Bangle.appRect.w/3; } @@ -81,7 +82,7 @@ class TimeCalClock{ // }); // require("weather").get = undefined; - this.hasWeather = require('weather') && require('weather').get(); + this.hasWeather = this.settings().showWeather && require('weather') && require('weather').get(); const prevCenterX = this.dtCenterX; if(this.hasWeather){ this.dtCenterX = 2 * Bangle.appRect.w / 3; @@ -107,8 +108,13 @@ class TimeCalClock{ const temp = require("locale").temp(curr.temp-273.15).match(/^(\D*\d*)(.*)$/)[0]; const iconRadius = 20; const widgetHeight = 24; + g.clearRect( + Bangle.appRect.x, + Bangle.appRect.y, + Bangle.appRect.w/3, + Bangle.appRect.y + widgetHeight + iconRadius + ); weather.drawIcon(curr, Bangle.appRect.x + widgetHeight, Bangle.appRect.y + widgetHeight - 4, iconRadius); - g .setFontAlign(0, -1) .setFont('6x8', 2) diff --git a/apps/timecal/timecal.settings.js b/apps/timecal/timecal.settings.js index d7824815a..56f8a12f3 100644 --- a/apps/timecal/timecal.settings.js +++ b/apps/timecal/timecal.settings.js @@ -17,7 +17,8 @@ suClr:1, //0:fg, 1:red=#E00, 2:green=#0E0, 3:blue=#00E //phColor:"#E00", //public holiday - calBrdr:false + calBrdr:false, + showWeather:false }; let validSttngs = require("Storage").readJSON(FILE, 1) || {}; for (const k in validSttngs) if (!DEFAULTS.hasOwnProperty(k)) delete this.validSttngs[k]; //remove invalid settings @@ -64,6 +65,11 @@ format: v => v ? /*LANG*/"show" : /*LANG*/"none", onchange: v => chngdSttngs.calBrdr = v }, + "Weather": { + value: chngdSttngs.showWeather, + format: v => v ? /*LANG*/"show" : /*LANG*/"none", + onchange: v => chngdSttngs.showWeather = v + }, /*LANG*/"Today settings": () => showTodayMenu(), /*LANG*/"< Cancel": () => cancelExitSettings() });