Merge branch 'peeweek-app/hcclock-0.2'

pull/863/head
Gordon Williams 2021-10-22 08:10:50 +01:00
commit cc884c2129
3 changed files with 42 additions and 9 deletions

View File

@ -3734,7 +3734,7 @@
{ {
"id": "hcclock", "id": "hcclock",
"name": "Hi-Contrast Clock", "name": "Hi-Contrast Clock",
"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.",
"icon": "hcclock-icon.png", "icon": "hcclock-icon.png",
"type": "clock", "type": "clock",

View File

@ -1,2 +1,2 @@
0.01: base code 0.01: base code
0.02: saved settings when switching color scheme

View File

@ -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);