mirror of https://github.com/espruino/BangleApps
Added Settings for Color scheme
parent
1592bcb1a5
commit
4d933ed959
|
@ -3390,13 +3390,14 @@
|
||||||
{ "id": "hcclock",
|
{ "id": "hcclock",
|
||||||
"name": "Hi-Contrast Clock",
|
"name": "Hi-Contrast Clock",
|
||||||
"icon": "hcclock-icon.png",
|
"icon": "hcclock-icon.png",
|
||||||
"version":"0.01",
|
"version":"0.02",
|
||||||
"description": "Hi-Contrast Clock : A simple yet very bold clock that aims to be readable in high luninosity environments. Uses big 10x5 pixel digits. Use BTN 1 to switch background and foreground colors.",
|
"description": "Hi-Contrast Clock : A simple yet very bold clock that aims to be readable in high luninosity environments. Uses big 10x5 pixel digits. Use BTN 1 to switch background and foreground colors.",
|
||||||
"tags": "clock",
|
"tags": "clock",
|
||||||
"type":"clock",
|
"type":"clock",
|
||||||
"allow_emulator":true,
|
"allow_emulator":true,
|
||||||
"storage": [
|
"storage": [
|
||||||
{"name":"hcclock.app.js","url":"hcclock.app.js"},
|
{"name":"hcclock.app.js","url":"hcclock.app.js"},
|
||||||
|
{"name":"hcclock.settings.js","url":"hcclock.settings.js"},
|
||||||
{"name":"hcclock.img","url":"hcclock-icon.js","evaluate":true}
|
{"name":"hcclock.img","url":"hcclock-icon.js","evaluate":true}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
0.01: base code
|
0.01: base code
|
||||||
|
0.02: added settings for color schemes
|
|
@ -174,19 +174,52 @@ function fmtDate(day,month,year,hour)
|
||||||
let ap = "(AM)";
|
let ap = "(AM)";
|
||||||
if(hour == 0 || hour > 12)
|
if(hour == 0 || hour > 12)
|
||||||
ap = "(PM)";
|
ap = "(PM)";
|
||||||
return months[month] + " " + day + " " + year + " "+ ap;
|
return months[month] + " " + day + " " + year + " "+ ap;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return months[month] + ". " + day + " " + year;
|
return months[month] + ". " + day + " " + year;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handles Flipping colors, then refreshes the UI
|
|
||||||
|
//////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// HANDLE COLORS + SETTINGS
|
||||||
|
//
|
||||||
|
|
||||||
|
function getColorScheme()
|
||||||
|
{
|
||||||
|
let settings = require('Storage').readJSON("hcclock.json", true) || {};
|
||||||
|
if (!("scheme" in settings)) {
|
||||||
|
settings.scheme = 0;
|
||||||
|
}
|
||||||
|
return settings.scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setColorScheme(value)
|
||||||
|
{
|
||||||
|
let settings = require('Storage').readJSON("hcclock.json", true) || {};
|
||||||
|
settings.scheme = value;
|
||||||
|
require('Storage').writeJSON('hcclock.json', settings);
|
||||||
|
|
||||||
|
if(value == 0) // White
|
||||||
|
{
|
||||||
|
bg = 255;
|
||||||
|
fg = 0;
|
||||||
|
}
|
||||||
|
else // Black
|
||||||
|
{
|
||||||
|
bg = 0;
|
||||||
|
fg = 255;
|
||||||
|
}
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
function flipColors()
|
function flipColors()
|
||||||
{
|
{
|
||||||
let t = bg;
|
if(getColorScheme() == 0)
|
||||||
bg = fg;
|
setColorScheme(1);
|
||||||
fg = t;
|
else
|
||||||
redraw();
|
setColorScheme(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
|
@ -197,7 +230,7 @@ function flipColors()
|
||||||
// Initialize
|
// Initialize
|
||||||
g.clear();
|
g.clear();
|
||||||
Bangle.loadWidgets();
|
Bangle.loadWidgets();
|
||||||
redraw();
|
setColorScheme(getColorScheme());
|
||||||
|
|
||||||
// Define Refresh Interval
|
// Define Refresh Interval
|
||||||
setInterval(updateTime, interval);
|
setInterval(updateTime, interval);
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
(function(back) {
|
||||||
|
|
||||||
|
function getColorScheme()
|
||||||
|
{
|
||||||
|
let settings = require('Storage').readJSON("hcclock.json", true) || {};
|
||||||
|
if (!("scheme" in settings)) {
|
||||||
|
settings.scheme = 0;
|
||||||
|
}
|
||||||
|
return settings.scheme;
|
||||||
|
}
|
||||||
|
function setColorScheme(value)
|
||||||
|
{
|
||||||
|
let settings = require('Storage').readJSON("hcclock.json", true) || {};
|
||||||
|
settings.scheme = value? 1 : 0;
|
||||||
|
require('Storage').writeJSON('hcclock.json', settings);
|
||||||
|
}
|
||||||
|
function setIcon(visible) {
|
||||||
|
updateSetting('showIcon', visible);
|
||||||
|
|
||||||
|
}
|
||||||
|
var mainmenu = {
|
||||||
|
"" : { "title" : "Hi-Contrast Clock" },
|
||||||
|
"Color Scheme" : {
|
||||||
|
value: getColorScheme,
|
||||||
|
format: v => v == 0?"White":"Black",
|
||||||
|
onchange: setColorScheme
|
||||||
|
},
|
||||||
|
"< Back" : back,
|
||||||
|
};
|
||||||
|
E.showMenu(mainmenu);
|
||||||
|
})
|
||||||
|
|
2
core
2
core
|
@ -1 +1 @@
|
||||||
Subproject commit 27f9a7125146a38c4357d679ec783f6e98a983c6
|
Subproject commit 8d9a012d62d40aae1b2304d0149440fb3c022393
|
Loading…
Reference in New Issue