weatherclock v0.06
parent
769c4c2793
commit
bf3a9e0002
|
|
@ -1,5 +1,6 @@
|
|||
0.01: New App!
|
||||
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.04: Layout now compatible with Bangle.js 2
|
||||
0.05: Use weather condition code for icon selection
|
||||
0.04: Layout now compatible with Bangle.js 2.
|
||||
0.05: Use weather condition code for icon selection.
|
||||
0.06: New settings to (un)hide day of week, date and wind speed.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
const Layout = require("Layout");
|
||||
const storage = require('Storage');
|
||||
const locale = require("locale");
|
||||
const SETTINGS_FILE = "weatherClock.json";
|
||||
let settings;
|
||||
|
||||
// weather icons from https://icons8.com/icon/set/weather/color
|
||||
var sunIcon = require("heatshrink").decompress(atob("mEwwhC/AH4AbhvQC6vd7ouVC4IwUCwIwUFwQwQCYgAHDZQXc9wACC6QWDDAgXN7wXF9oXPCwowDC5guGGAYXMCw4wCC5RGJJAZGTJBiNISIylQVJrLCC5owGF65fXR7AwBC5jvhC7JIILxapDFxAXOGAy9KC4owGBAQXODAgHDC54AHC8T0FAAQSOGg4qPGA4WUGAIuVC7AA/AH4AEA="));
|
||||
|
|
@ -18,6 +20,13 @@ var stormIcon = require("heatshrink").decompress(atob("mEwwhC/AFEzmcwCyoYUgYXDmY
|
|||
// err icon - https://icons8.com/icons/set/error
|
||||
var errIcon = require("heatshrink").decompress(atob("mEwwkBiIA/AH4AZUAIWUiAXBWqgXXdIYuVGCgXBgICCIyYXCJCQTDC6QrEMCQSEJCQRFC6ApGJCCiDDQSpQFAYXEJBqNGJCA/EC4ZIOEwgXFJBgNEAhKlNAgxIKBgoXEJBjsLC5TsIeRycMBhRrMMBKzQEozjOBxAgHGww+IA6wfSH4hnIC47OMSJqlRIJAXCACIXaGoQARPwwuTAH4A/ABw"));
|
||||
|
||||
function loadSettings() {
|
||||
settings = require("Storage").readJSON(SETTINGS_FILE,1)||{};
|
||||
settings.day = settings.day||true;
|
||||
settings.date = settings.date||true;
|
||||
settings.wind = settings.wind||true;
|
||||
}
|
||||
|
||||
/**
|
||||
Choose weather icon to display based on condition.
|
||||
Based on function from the Bangle weather app so it should handle all of the conditions
|
||||
|
|
@ -120,8 +129,8 @@ function queueDraw() {
|
|||
function draw() {
|
||||
var date = new Date();
|
||||
clockLayout.time.label = locale.time(date, 1);
|
||||
clockLayout.date.label = locale.date(date, 1).toUpperCase();
|
||||
clockLayout.dow.label = locale.dow(date, 1).toUpperCase() + " ";
|
||||
clockLayout.date.label = (settings.date) ? locale.date(date, 1).toUpperCase() : "";
|
||||
clockLayout.dow.label = (settings.day) ? locale.dow(date, 1).toUpperCase() + " " : "";
|
||||
var weatherJson = getWeather();
|
||||
if(weatherJson && weatherJson.weather){
|
||||
var currentWeather = weatherJson.weather;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
{
|
||||
"id": "weatherClock",
|
||||
"name": "Weather Clock",
|
||||
"version": "0.05",
|
||||
"shortName": "Weather Clock",
|
||||
"version": "0.06",
|
||||
"description": "A clock which displays current weather conditions (requires Gadgetbridge and Weather apps).",
|
||||
"icon": "app.png",
|
||||
"screenshots": [{"url":"screens/screen1.png"}],
|
||||
"dependencies": {"weather":"app"},
|
||||
"screenshots": [{"url":"screens/screen1.png"}, {"url":"screens/screen2.png"}],
|
||||
"type": "clock",
|
||||
"tags": "clock, weather",
|
||||
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||
|
|
@ -12,6 +14,8 @@
|
|||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"weatherClock.app.js","url":"app.js"},
|
||||
{"name":"weatherClock.img","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
{"name":"weatherClock.img","url":"app-icon.js","evaluate":true},
|
||||
{"name":"weatherClock.settings.js","url":"weatherClock.settings.js"}
|
||||
],
|
||||
"data": [{"name":"weatherClock.json"}]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
(function(back) {
|
||||
const SETTINGS_FILE = "weatherClock.json";
|
||||
|
||||
// initialize with default settings...
|
||||
let s = {
|
||||
'day': true,
|
||||
'date': true,
|
||||
'wind': true
|
||||
}
|
||||
|
||||
// ...and overwrite them with any saved values
|
||||
// This way saved values are preserved if a new version adds more settings
|
||||
const storage = require('Storage')
|
||||
let settings = storage.readJSON(SETTINGS_FILE, 1) || {}
|
||||
const saved = settings || {}
|
||||
for (const key in saved) {
|
||||
s[key] = saved[key]
|
||||
}
|
||||
|
||||
function save() {
|
||||
settings = s
|
||||
storage.write(SETTINGS_FILE, settings)
|
||||
}
|
||||
|
||||
|
||||
E.showMenu({
|
||||
'': { 'title': 'Show Day of Week': {
|
||||
value: !!s.day,
|
||||
onchange: v => {
|
||||
s.day = v;
|
||||
save();
|
||||
},
|
||||
},
|
||||
'Show Date': {
|
||||
value: !!s.date,
|
||||
onchange: v => {
|
||||
s.date = v;
|
||||
save();
|
||||
},
|
||||
},
|
||||
'Show Wind Speed': {
|
||||
value: !!s.wind,
|
||||
onchange: v => {
|
||||
s.wind = v;
|
||||
save();
|
||||
},
|
||||
}
|
||||
})
|
||||
})
|
||||
2
core
2
core
|
|
@ -1 +1 @@
|
|||
Subproject commit 0d02ff3763783d166ff84906af038420736aabfc
|
||||
Subproject commit 23854083e0c3f83c649073a2d85e8079efc471d3
|
||||
Loading…
Reference in New Issue