Merge pull request #3871 from elcste/master

andark: three new features
master
thyttan 2025-06-03 01:00:53 +02:00 committed by GitHub
commit c037148be0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 65 additions and 20 deletions

View File

@ -7,3 +7,5 @@
0.06: Fix issue showing widgets when app is fast-loaded into from launcher with widgets disabled 0.06: Fix issue showing widgets when app is fast-loaded into from launcher with widgets disabled
0.07: Enable fast loading and queue updates to the second 0.07: Enable fast loading and queue updates to the second
0.08: Restore redraw on charging event + fixup for safer fast-loading 0.08: Restore redraw on charging event + fixup for safer fast-loading
0.09: Add setting to show the weekday and not the year + add setting to hide the battery +
changed to follow system them with setting for dark theme

View File

@ -7,10 +7,19 @@
* battery percentage (showing charge status with color) * battery percentage (showing charge status with color)
* turned off or swipeable widgets (choose in settings) * turned off or swipeable widgets (choose in settings)
![logo](andark_screen.png) ![Screenshot of Dark Analog Clock with default settings](andark_screen.png)
*Default settings*
![Screenshot of Dark Analog Clock with default settings](andark_screen_light_weekday_nobatt.png)
*Following system theme, with weekday shown and battery hidden*
## Settings ## Settings
* whether to load widgets, or not; if widgets are loaded, they are swipeable from the top; if not, NO ACTIONS of widgets are available * whether to load widgets, or not; if widgets are loaded, they are swipeable from the top; if not, NO ACTIONS of widgets are available
* date and battery can be printed both below hands (as if hands were physical) and above (more readable) * date and battery can be printed both below hands (as if hands were physical) and above (more readable)
* hour hand can be made slighly shorter to improve readability when minute hand is behind a number * hour hand can be made slighly shorter to improve readability when minute hand is behind a number
* show the weekday and not the year
* hide the battery percentage; the font for the date is increased since there is more space
* dark theme (enabled by default); disable to follow system theme

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -2,10 +2,19 @@
const defaultSettings = { const defaultSettings = {
loadWidgets : false, loadWidgets : false,
textAboveHands : false, textAboveHands : false,
shortHrHand : false shortHrHand : false,
weekdayNoYear : false,
noBattery : false,
darkTheme : true
}; };
const settings = Object.assign(defaultSettings, require('Storage').readJSON('andark.json',1)||{}); const settings = Object.assign(defaultSettings, require('Storage').readJSON('andark.json',1)||{});
const origTheme = g.theme;
if (settings.darkTheme) {
g.setTheme({bg: "#000"});
g.setTheme({fg: "#FFF"});
}
const c={"x":g.getWidth()/2,"y":g.getHeight()/2}; const c={"x":g.getWidth()/2,"y":g.getHeight()/2};
const zahlpos=(function() { const zahlpos=(function() {
@ -36,7 +45,7 @@ const zeiger = function(len,dia,tim) {
const drawHands = function(d) { const drawHands = function(d) {
let m=d.getMinutes(), h=d.getHours(), s=d.getSeconds(); let m=d.getMinutes(), h=d.getHours(), s=d.getSeconds();
g.setColor(1,1,1); g.setColor(g.theme.fg);
if(h>12){ if(h>12){
h=h-12; h=h-12;
@ -62,23 +71,31 @@ const drawHands = function(d) {
}; };
const drawText = function(d) { const drawText = function(d) {
g.setFont("Vector",10); //g.setFont("Vector",10);
g.setBgColor(0,0,0); g.setBgColor(g.theme.bg);
g.setColor(1,1,1); g.setColor(g.theme.fg);
const dateStr = require("locale").date(d); const dateStr = settings.weekdayNoYear
g.drawString(dateStr, c.x, c.y+20, true); ? require("locale").dow(d, 1)+" "+d.getDate()+" "+require("locale").month(d, 1)
: require("locale").date(d);
const batStr = Math.round(E.getBattery()/5)*5+"%"; const batStr = Math.round(E.getBattery()/5)*5+"%";
if (Bangle.isCharging()) { if (settings.noBattery) {
g.setBgColor(1,0,0); g.setFont("Vector",13);
g.drawString(dateStr, c.x, c.y+25, true);
} else {
g.setFont("Vector",10);
g.drawString(dateStr, c.x, c.y+20, true);
if (Bangle.isCharging()) {
g.setBgColor(1,0,0);
}
g.drawString(batStr, c.x, c.y+40, true);
} }
g.drawString(batStr, c.x, c.y+40, true);
}; };
const drawNumbers = function() { const drawNumbers = function() {
//draws the numbers on the screen //draws the numbers on the screen
g.setFont("Vector",20); g.setFont("Vector",20);
g.setColor(1,1,1); g.setColor(g.theme.fg);
g.setBgColor(0,0,0); g.setBgColor(g.theme.bg);
for(let i = 0;i<12;i++){ for(let i = 0;i<12;i++){
g.drawString(zahlpos[i][0],zahlpos[i][1],zahlpos[i][2],true); g.drawString(zahlpos[i][0],zahlpos[i][1],zahlpos[i][2],true);
} }
@ -114,7 +131,7 @@ const queueDraw = function() {
const draw = function() { const draw = function() {
// draw black rectangle in the middle to clear screen from scale and hands // draw black rectangle in the middle to clear screen from scale and hands
g.setColor(0,0,0); g.setColor(g.theme.bg);
g.fillRect(10,10,2*c.x-10,2*c.x-10); g.fillRect(10,10,2*c.x-10,2*c.x-10);
// prepare for drawing the text // prepare for drawing the text
g.setFontAlign(0,0); g.setFontAlign(0,0);
@ -132,7 +149,7 @@ const draw = function() {
//draws the scale once the app is startet //draws the scale once the app is startet
const drawScale = function() { const drawScale = function() {
// clear the screen // clear the screen
g.setBgColor(0,0,0); g.setBgColor(g.theme.bg);
g.clear(); g.clear();
// draw the ticks of the scale // draw the ticks of the scale
for(let i=-14;i<47;i++){ for(let i=-14;i<47;i++){
@ -140,9 +157,9 @@ const drawScale = function() {
let d=2; let d=2;
if(i%5==0){d=5;} if(i%5==0){d=5;}
g.fillPoly(zeiger(300,d,win),true); g.fillPoly(zeiger(300,d,win),true);
g.setColor(0,0,0); g.setColor(g.theme.bg);
g.fillRect(10,10,2*c.x-10,2*c.x-10); g.fillRect(10,10,2*c.x-10,2*c.x-10);
g.setColor(1,1,1); g.setColor(g.theme.fg);
} }
}; };
@ -152,6 +169,7 @@ const drawScale = function() {
Bangle.setUI({ Bangle.setUI({
mode: "clock", mode: "clock",
remove: function() { remove: function() {
if (settings.darkTheme) g.setTheme(origTheme);
Bangle.removeListener('lcdPower', updateState); Bangle.removeListener('lcdPower', updateState);
Bangle.removeListener('lock', updateState); Bangle.removeListener('lock', updateState);
Bangle.removeListener('charging', draw); Bangle.removeListener('charging', draw);

View File

@ -1,13 +1,14 @@
{ "id": "andark", { "id": "andark",
"name": "Analog Dark", "name": "Analog Dark",
"shortName":"AnDark", "shortName":"AnDark",
"version":"0.08", "version":"0.09",
"description": "analog clock face without disturbing widgets", "description": "analog clock face without disturbing widgets",
"icon": "andark_icon.png", "icon": "andark_icon.png",
"type": "clock", "type": "clock",
"tags": "clock", "tags": "clock",
"allow_emulator": true,
"supports" : ["BANGLEJS2"], "supports" : ["BANGLEJS2"],
"screenshots": [{"url":"andark_screen.png"}], "screenshots": [{"url":"andark_screen.png"},{"url":"andark_screen_light_weekday_nobatt.png"}],
"readme": "README.md", "readme": "README.md",
"storage": [ "storage": [
{"name":"andark.app.js","url":"app.js"}, {"name":"andark.app.js","url":"app.js"},

View File

@ -2,7 +2,10 @@
const defaultSettings = { const defaultSettings = {
loadWidgets : false, loadWidgets : false,
textAboveHands : false, textAboveHands : false,
shortHrHand : false shortHrHand : false,
weekdayNoYear : false,
noBattery : false,
darkTheme : true
} }
let settings = Object.assign(defaultSettings, require('Storage').readJSON('andark.json',1)||{}); let settings = Object.assign(defaultSettings, require('Storage').readJSON('andark.json',1)||{});
@ -22,6 +25,18 @@
value : !!settings.shortHrHand, value : !!settings.shortHrHand,
onchange : v => { settings.shortHrHand=v; save();} onchange : v => { settings.shortHrHand=v; save();}
}, },
/*LANG*/'Show weekday not year': {
value : !!settings.weekdayNoYear,
onchange : v => { settings.weekdayNoYear=v; save();}
},
/*LANG*/'Hide the battery': {
value : !!settings.noBattery,
onchange : v => { settings.noBattery=v; save();}
},
/*LANG*/'Dark theme': {
value : !!settings.darkTheme,
onchange : v => { settings.darkTheme=v; save();}
},
}; };
E.showMenu(appMenu); E.showMenu(appMenu);