feat: enable hiding or showing weather via settings

master
Sebin Suresh 2025-03-16 10:08:29 -05:00
parent ddb00b2bb9
commit 14abb10b39
No known key found for this signature in database
3 changed files with 19 additions and 5 deletions

View File

@ -5,6 +5,7 @@ Shows the
* Date * Date
* Time (hh:mm) - respecting 12/24 (uses locale string) * Time (hh:mm) - respecting 12/24 (uses locale string)
* 3 weeks calendar view (last,current and next week) * 3 weeks calendar view (last,current and next week)
* Weather icon and temperature - if weather app is set up
### The settings menu ### The settings menu
Calendar View can be customized 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] * 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 * Su color: Set Sundays color. Values: none [default], red, green or blue
* Border: show or none [default] * Border: show or none [default]
* Weather: show or none [default]
* Submenu Today settings - choose how today is highlighted * Submenu Today settings - choose how today is highlighted
* < Back: * < Back:
* Color: none, red [default], green or blue * Color: none, red [default], green or blue

View File

@ -29,7 +29,8 @@ class TimeCalClock{
suClr:1, //0:fg, 1:red=#E00, 2:green=#0E0, 3:blue=#00E suClr:1, //0:fg, 1:red=#E00, 2:green=#0E0, 3:blue=#00E
//phColor:"#E00", //public holiday //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 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 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 // X coord to center date and time text at
this.dtCenterX = Bangle.appRect.w/2; 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){ if(this.hasWeather){
this.dtCenterX =2*Bangle.appRect.w/3; this.dtCenterX =2*Bangle.appRect.w/3;
} }
@ -81,7 +82,7 @@ class TimeCalClock{
// }); // });
// require("weather").get = undefined; // 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; const prevCenterX = this.dtCenterX;
if(this.hasWeather){ if(this.hasWeather){
this.dtCenterX = 2 * Bangle.appRect.w / 3; 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 temp = require("locale").temp(curr.temp-273.15).match(/^(\D*\d*)(.*)$/)[0];
const iconRadius = 20; const iconRadius = 20;
const widgetHeight = 24; 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); weather.drawIcon(curr, Bangle.appRect.x + widgetHeight, Bangle.appRect.y + widgetHeight - 4, iconRadius);
g g
.setFontAlign(0, -1) .setFontAlign(0, -1)
.setFont('6x8', 2) .setFont('6x8', 2)

View File

@ -17,7 +17,8 @@
suClr:1, //0:fg, 1:red=#E00, 2:green=#0E0, 3:blue=#00E suClr:1, //0:fg, 1:red=#E00, 2:green=#0E0, 3:blue=#00E
//phColor:"#E00", //public holiday //phColor:"#E00", //public holiday
calBrdr:false calBrdr:false,
showWeather:false
}; };
let validSttngs = require("Storage").readJSON(FILE, 1) || {}; let validSttngs = require("Storage").readJSON(FILE, 1) || {};
for (const k in validSttngs) if (!DEFAULTS.hasOwnProperty(k)) delete this.validSttngs[k]; //remove invalid settings 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", format: v => v ? /*LANG*/"show" : /*LANG*/"none",
onchange: v => chngdSttngs.calBrdr = v 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*/"Today settings": () => showTodayMenu(),
/*LANG*/"< Cancel": () => cancelExitSettings() /*LANG*/"< Cancel": () => cancelExitSettings()
}); });