forked from FOSS/BangleApps
fixes #1271 & some code rework
+ moved settings-helper method def to load settings method + settingsfile as const + isBangle1 via HWVERSION==1master
parent
910c3c0b5b
commit
223f6b6b81
|
@ -4279,7 +4279,7 @@
|
||||||
{
|
{
|
||||||
"id": "antonclk",
|
"id": "antonclk",
|
||||||
"name": "Anton Clock",
|
"name": "Anton Clock",
|
||||||
"version": "0.05",
|
"version": "0.06",
|
||||||
"description": "A clock using the bold Anton font, optionally showing seconds and date in ISO-8601 format.",
|
"description": "A clock using the bold Anton font, optionally showing seconds and date in ISO-8601 format.",
|
||||||
"readme":"README.md",
|
"readme":"README.md",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
|
|
|
@ -5,3 +5,6 @@
|
||||||
0.05: Clock can optionally show ISO-8601 calendar weeknumber (default: Off)
|
0.05: Clock can optionally show ISO-8601 calendar weeknumber (default: Off)
|
||||||
when weekday name "Off": week #:<num>
|
when weekday name "Off": week #:<num>
|
||||||
when weekday name "On": weekday name is cut at 6th position and .#<week num> is added
|
when weekday name "On": weekday name is cut at 6th position and .#<week num> is added
|
||||||
|
0.06: fixes #1271 - wrong settings name
|
||||||
|
when weekday name and calendar weeknumber are on then display is <weekday short> #<calweek>
|
||||||
|
week is buffered until date or timezone changes
|
|
@ -40,9 +40,9 @@ The main menu contains several settings covering Anton clock in general.
|
||||||
* **Show Weekday** - Weekday is shown in the time presentation without seconds.
|
* **Show Weekday** - Weekday is shown in the time presentation without seconds.
|
||||||
Weekday name depends on the current locale.
|
Weekday name depends on the current locale.
|
||||||
If seconds are shown, the weekday is never shown as there is not enough space on the watch face.
|
If seconds are shown, the weekday is never shown as there is not enough space on the watch face.
|
||||||
* **Show Weeknumber** - Week-number (ISO-8601) is shown. (default: Off)
|
* **Show CalWeek** - Week-number (ISO-8601) is shown. (default: Off)
|
||||||
If "Show Weekday" is "Off" the week-number is displayed as "week #:<num>".
|
If "Show Weekday" is "Off" displays the week-number as "week #<num>".
|
||||||
If "Show Weekday" is "On" the weekday name is cut at 6th position and suffixed with ".#<week num>".
|
If "Show Weekday" is "On" displays "weekday name short" with " #<num>" .
|
||||||
If seconds are shown, the week number is never shown as there is not enough space on the watch face.
|
If seconds are shown, the week number is never shown as there is not enough space on the watch face.
|
||||||
* **Vector font** - Use the built-in vector font for dates and weekday.
|
* **Vector font** - Use the built-in vector font for dates and weekday.
|
||||||
This can improve readability.
|
This can improve readability.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Clock with large digits using the "Anton" bold font
|
// Clock with large digits using the "Anton" bold font
|
||||||
|
|
||||||
var SETTINGSFILE = "antonclk.json";
|
const SETTINGSFILE = "antonclk.json";
|
||||||
|
|
||||||
Graphics.prototype.setFontAnton = function(scale) {
|
Graphics.prototype.setFontAnton = function(scale) {
|
||||||
// Actual height 69 (68 - 0)
|
// Actual height 69 (68 - 0)
|
||||||
|
@ -28,7 +28,7 @@ var drawTimeout;
|
||||||
var queueMillis = 1000;
|
var queueMillis = 1000;
|
||||||
var secondsScreen = true;
|
var secondsScreen = true;
|
||||||
|
|
||||||
var isBangle1 = (g.getWidth() == 240);
|
var isBangle1 = (process.env.HWVERSION == 1);
|
||||||
|
|
||||||
//For development purposes
|
//For development purposes
|
||||||
/*
|
/*
|
||||||
|
@ -50,13 +50,11 @@ require('Storage').writeJSON(SETTINGSFILE, {
|
||||||
require('Storage').erase(SETTINGSFILE);
|
require('Storage').erase(SETTINGSFILE);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Helper method for loading the settings
|
|
||||||
function def(value, def) {
|
|
||||||
return (value !== undefined ? value : def);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load settings
|
// Load settings
|
||||||
function loadSettings() {
|
function loadSettings() {
|
||||||
|
// Helper function default setting
|
||||||
|
function def (value, def) {return value !== undefined ? value : def;}
|
||||||
|
|
||||||
var settings = require('Storage').readJSON(SETTINGSFILE, true) || {};
|
var settings = require('Storage').readJSON(SETTINGSFILE, true) || {};
|
||||||
secondsMode = def(settings.secondsMode, "Never");
|
secondsMode = def(settings.secondsMode, "Never");
|
||||||
secondsColoured = def(settings.secondsColoured, true);
|
secondsColoured = def(settings.secondsColoured, true);
|
||||||
|
@ -104,7 +102,14 @@ function isoStr(date) {
|
||||||
return date.getFullYear() + "-" + ("0" + (date.getMonth() + 1)).substr(-2) + "-" + ("0" + date.getDate()).substr(-2);
|
return date.getFullYear() + "-" + ("0" + (date.getMonth() + 1)).substr(-2) + "-" + ("0" + date.getDate()).substr(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var calWeekBuffer = [false,false,false]; //buffer tz, date, week no (once calculated until other tz or date is requested)
|
||||||
function ISO8601calWeek(date) { //copied from: https://gist.github.com/IamSilviu/5899269#gistcomment-3035480
|
function ISO8601calWeek(date) { //copied from: https://gist.github.com/IamSilviu/5899269#gistcomment-3035480
|
||||||
|
console.log(date);
|
||||||
|
dateNoTime = date; dateNoTime.setHours(0,0,0,0);
|
||||||
|
console.log(dateNoTime);
|
||||||
|
if (calWeekBuffer[0] === date.getTimezoneOffset() && calWeekBuffer[1] === dateNoTime) return calWeekBuffer[2];
|
||||||
|
calWeekBuffer[0] = date.getTimezoneOffset();
|
||||||
|
calWeekBuffer[1] = dateNoTime;
|
||||||
var tdt = new Date(date.valueOf());
|
var tdt = new Date(date.valueOf());
|
||||||
var dayn = (date.getDay() + 6) % 7;
|
var dayn = (date.getDay() + 6) % 7;
|
||||||
tdt.setDate(tdt.getDate() - dayn + 3);
|
tdt.setDate(tdt.getDate() - dayn + 3);
|
||||||
|
@ -113,7 +118,8 @@ function ISO8601calWeek(date) { //copied from: https://gist.github.com/IamSilviu
|
||||||
if (tdt.getDay() !== 4) {
|
if (tdt.getDay() !== 4) {
|
||||||
tdt.setMonth(0, 1 + ((4 - tdt.getDay()) + 7) % 7);
|
tdt.setMonth(0, 1 + ((4 - tdt.getDay()) + 7) % 7);
|
||||||
}
|
}
|
||||||
return 1 + Math.ceil((firstThursday - tdt) / 604800000);
|
calWeekBuffer[2] = 1 + Math.ceil((firstThursday - tdt) / 604800000);
|
||||||
|
return calWeekBuffer[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
function doColor() {
|
function doColor() {
|
||||||
|
@ -186,13 +192,17 @@ function draw() {
|
||||||
else
|
else
|
||||||
g.setFont("6x8", 2);
|
g.setFont("6x8", 2);
|
||||||
g.drawString(dateStr, x, y);
|
g.drawString(dateStr, x, y);
|
||||||
if (weekDay || calWeek) {
|
if (calWeek || weekDay) {
|
||||||
var dowwumStr = require("locale").dow(date);
|
var dowcwStr = "";
|
||||||
if (calWeek)
|
if (calWeek)
|
||||||
dowwumStr = (weekDay ? dowwumStr.substr(0,Math.min(dowwumStr.length,6)) + (dowwumStr.length>=6 ? "." : "") : "week ") + "#" + ISO8601calWeek(date); //TODO: locale for "week"
|
dowcwStr = " #" + ("0" + ISO8601calWeek(date)).substring(-2);
|
||||||
|
if (weekDay)
|
||||||
|
dowcwStr = require("locale").dow(date, calWeek ? 1 : 0) + dowcwStr; //weekDay e.g. Monday or weekDayShort #<calWeek> e.g. Mon #01
|
||||||
|
else //week #01
|
||||||
|
dowcwStr = /*LANG*/"week" + dowcwStr;
|
||||||
if (upperCase)
|
if (upperCase)
|
||||||
dowwumStr = dowwumStr.toUpperCase();
|
dowcwStr = dowcwStr.toUpperCase();
|
||||||
g.drawString(dowwumStr, x, y + (vectorFont ? 26 : 16));
|
g.drawString(dowcwStr, x, y + (vectorFont ? 26 : 16));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,10 +48,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Show Weeknumber": {
|
"Show Weeknumber": {
|
||||||
value: (settings.weekNum !== undefined ? settings.weekNum : true),
|
value: (settings.calWeek !== undefined ? settings.calWeek : false),
|
||||||
format: v => v ? "On" : "Off",
|
format: v => v ? "On" : "Off",
|
||||||
onchange: v => {
|
onchange: v => {
|
||||||
settings.weekNum = v;
|
settings.calWeek = v;
|
||||||
writeSettings();
|
writeSettings();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue