Skip to content

Commit 2cb5ed3

Browse files
author
thyttan
committed
Merge remote-tracking branch 'upstream/master' into app-loader
2 parents 8bdf7b7 + 4be6bb2 commit 2cb5ed3

29 files changed

+1258
-287
lines changed

apps/andark/ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
0.06: Fix issue showing widgets when app is fast-loaded into from launcher with widgets disabled
88
0.07: Enable fast loading and queue updates to the second
99
0.08: Restore redraw on charging event + fixup for safer fast-loading
10+
0.09: Add setting to show the weekday and not the year + add setting to hide the battery +
11+
changed to follow system them with setting for dark theme

apps/andark/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,19 @@
77
* battery percentage (showing charge status with color)
88
* turned off or swipeable widgets (choose in settings)
99

10-
![logo](andark_screen.png)
10+
![Screenshot of Dark Analog Clock with default settings](andark_screen.png)
11+
12+
*Default settings*
13+
14+
![Screenshot of Dark Analog Clock with default settings](andark_screen_light_weekday_nobatt.png)
15+
16+
*Following system theme, with weekday shown and battery hidden*
1117

1218
## Settings
1319

1420
* whether to load widgets, or not; if widgets are loaded, they are swipeable from the top; if not, NO ACTIONS of widgets are available
1521
* date and battery can be printed both below hands (as if hands were physical) and above (more readable)
1622
* hour hand can be made slighly shorter to improve readability when minute hand is behind a number
23+
* show the weekday and not the year
24+
* hide the battery percentage; the font for the date is increased since there is more space
25+
* dark theme (enabled by default); disable to follow system theme
4.73 KB
Loading

apps/andark/app.js

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
22
const defaultSettings = {
33
loadWidgets : false,
44
textAboveHands : false,
5-
shortHrHand : false
5+
shortHrHand : false,
6+
weekdayNoYear : false,
7+
noBattery : false,
8+
darkTheme : true
69
};
710
const settings = Object.assign(defaultSettings, require('Storage').readJSON('andark.json',1)||{});
811

12+
const origTheme = g.theme;
13+
if (settings.darkTheme) {
14+
g.setTheme({bg: "#000"});
15+
g.setTheme({fg: "#FFF"});
16+
}
17+
918
const c={"x":g.getWidth()/2,"y":g.getHeight()/2};
1019

1120
const zahlpos=(function() {
@@ -36,7 +45,7 @@ const zeiger = function(len,dia,tim) {
3645

3746
const drawHands = function(d) {
3847
let m=d.getMinutes(), h=d.getHours(), s=d.getSeconds();
39-
g.setColor(1,1,1);
48+
g.setColor(g.theme.fg);
4049

4150
if(h>12){
4251
h=h-12;
@@ -62,23 +71,31 @@ const drawHands = function(d) {
6271
};
6372

6473
const drawText = function(d) {
65-
g.setFont("Vector",10);
66-
g.setBgColor(0,0,0);
67-
g.setColor(1,1,1);
68-
const dateStr = require("locale").date(d);
69-
g.drawString(dateStr, c.x, c.y+20, true);
74+
//g.setFont("Vector",10);
75+
g.setBgColor(g.theme.bg);
76+
g.setColor(g.theme.fg);
77+
const dateStr = settings.weekdayNoYear
78+
? require("locale").dow(d, 1)+" "+d.getDate()+" "+require("locale").month(d, 1)
79+
: require("locale").date(d);
7080
const batStr = Math.round(E.getBattery()/5)*5+"%";
71-
if (Bangle.isCharging()) {
72-
g.setBgColor(1,0,0);
81+
if (settings.noBattery) {
82+
g.setFont("Vector",13);
83+
g.drawString(dateStr, c.x, c.y+25, true);
84+
} else {
85+
g.setFont("Vector",10);
86+
g.drawString(dateStr, c.x, c.y+20, true);
87+
if (Bangle.isCharging()) {
88+
g.setBgColor(1,0,0);
89+
}
90+
g.drawString(batStr, c.x, c.y+40, true);
7391
}
74-
g.drawString(batStr, c.x, c.y+40, true);
7592
};
7693

7794
const drawNumbers = function() {
7895
//draws the numbers on the screen
7996
g.setFont("Vector",20);
80-
g.setColor(1,1,1);
81-
g.setBgColor(0,0,0);
97+
g.setColor(g.theme.fg);
98+
g.setBgColor(g.theme.bg);
8299
for(let i = 0;i<12;i++){
83100
g.drawString(zahlpos[i][0],zahlpos[i][1],zahlpos[i][2],true);
84101
}
@@ -114,7 +131,7 @@ const queueDraw = function() {
114131

115132
const draw = function() {
116133
// draw black rectangle in the middle to clear screen from scale and hands
117-
g.setColor(0,0,0);
134+
g.setColor(g.theme.bg);
118135
g.fillRect(10,10,2*c.x-10,2*c.x-10);
119136
// prepare for drawing the text
120137
g.setFontAlign(0,0);
@@ -132,17 +149,17 @@ const draw = function() {
132149
//draws the scale once the app is startet
133150
const drawScale = function() {
134151
// clear the screen
135-
g.setBgColor(0,0,0);
152+
g.setBgColor(g.theme.bg);
136153
g.clear();
137154
// draw the ticks of the scale
138155
for(let i=-14;i<47;i++){
139156
const win=i*2*Math.PI/60;
140157
let d=2;
141158
if(i%5==0){d=5;}
142159
g.fillPoly(zeiger(300,d,win),true);
143-
g.setColor(0,0,0);
160+
g.setColor(g.theme.bg);
144161
g.fillRect(10,10,2*c.x-10,2*c.x-10);
145-
g.setColor(1,1,1);
162+
g.setColor(g.theme.fg);
146163
}
147164
};
148165

@@ -152,6 +169,7 @@ const drawScale = function() {
152169
Bangle.setUI({
153170
mode: "clock",
154171
remove: function() {
172+
if (settings.darkTheme) g.setTheme(origTheme);
155173
Bangle.removeListener('lcdPower', updateState);
156174
Bangle.removeListener('lock', updateState);
157175
Bangle.removeListener('charging', draw);

apps/andark/metadata.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{ "id": "andark",
22
"name": "Analog Dark",
33
"shortName":"AnDark",
4-
"version":"0.08",
4+
"version":"0.09",
55
"description": "analog clock face without disturbing widgets",
66
"icon": "andark_icon.png",
77
"type": "clock",
88
"tags": "clock",
9+
"allow_emulator": true,
910
"supports" : ["BANGLEJS2"],
10-
"screenshots": [{"url":"andark_screen.png"}],
11+
"screenshots": [{"url":"andark_screen.png"},{"url":"andark_screen_light_weekday_nobatt.png"}],
1112
"readme": "README.md",
1213
"storage": [
1314
{"name":"andark.app.js","url":"app.js"},

apps/andark/settings.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
const defaultSettings = {
33
loadWidgets : false,
44
textAboveHands : false,
5-
shortHrHand : false
5+
shortHrHand : false,
6+
weekdayNoYear : false,
7+
noBattery : false,
8+
darkTheme : true
69
}
710
let settings = Object.assign(defaultSettings, require('Storage').readJSON('andark.json',1)||{});
811

@@ -22,6 +25,18 @@
2225
value : !!settings.shortHrHand,
2326
onchange : v => { settings.shortHrHand=v; save();}
2427
},
28+
/*LANG*/'Show weekday not year': {
29+
value : !!settings.weekdayNoYear,
30+
onchange : v => { settings.weekdayNoYear=v; save();}
31+
},
32+
/*LANG*/'Hide the battery': {
33+
value : !!settings.noBattery,
34+
onchange : v => { settings.noBattery=v; save();}
35+
},
36+
/*LANG*/'Dark theme': {
37+
value : !!settings.darkTheme,
38+
onchange : v => { settings.darkTheme=v; save();}
39+
},
2540
};
2641

2742
E.showMenu(appMenu);

apps/counter2/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
0.03: Fix lint warnings
44
0.04: Fix lint warnings
55
0.05: Fix on not reading counter defaults in Settings
6+
0.06: Added ability to display only one counter and fast-scrolling

apps/counter2/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ The counter state gets saved. Best to use this with pattern launcher or ClockCal
1111
## Howto
1212
- Tap top side or swipe up to increase counter
1313
- Tap bottom side or swipe down to decrease counter
14-
- Hold (600ms) to reset to default value (configurable)
15-
- Press button to exit
14+
- Hold either side to quickly increase or decrease the counter.
15+
- If the counters are not on their presets, then press the button to reset them
16+
- If the counters are on their presets, then press the button to leave the screen
17+
- Long press the button to leave the screen regardless of the counter values
1618

1719
## Configurable Features
20+
- Display both Counters or only Counter 1
1821
- Default value Counter 1
1922
- Default value Counter 2
2023
- Buzz on interact

apps/counter2/app.js

Lines changed: 99 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
Bangle.loadWidgets();
2-
31
var s = Object.assign({
2+
display2:true,
43
counter0:10,
54
counter1:20,
65
max0:15,
76
max1:25,
7+
fullscreen:true,
88
buzz: true,
99
colortext: true,
1010
}, require('Storage').readJSON("counter2.json", true) || {});
1111

12+
var sGlob = Object.assign({
13+
timeout: 10,
14+
}, require('Storage').readJSON("setting.json", true) || {});
15+
1216
const f1 = (s.colortext) ? "#f00" : "#fff";
1317
const f2 = (s.colortext) ? "#00f" : "#fff";
1418
const b1 = (s.colortext) ? g.theme.bg : "#f00";
1519
const b2 = (s.colortext) ? g.theme.bg : "#00f";
1620

1721
var drag;
22+
var dragCurr = {x:0 ,y:0 ,dx:0 ,dy:0 ,b:false};
1823

1924
const screenwidth = g.getWidth();
2025
const screenheight = g.getHeight();
@@ -37,51 +42,111 @@ function saveSettings() {
3742
}
3843

3944
let ignoreonce = false;
45+
let fastupdateoccurring = false;
4046
var dragtimeout;
4147

4248
function updateScreen() {
43-
g.setBgColor(b1);
44-
g.clearRect(0, 0, halfwidth, screenheight);
45-
g.setBgColor(b2);
46-
g.clearRect(halfwidth, 0, screenwidth, screenheight);
47-
g.setFont("Vector", 60).setFontAlign(0, 0);
48-
g.setColor(f1);
49-
g.drawString(Math.floor(counter[0]), halfwidth * 0.5, halfheight);
50-
g.setColor(f2);
51-
g.drawString(Math.floor(counter[1]), halfwidth * 1.5, halfheight);
49+
if (s.display2) {
50+
g.setBgColor(b1);
51+
g.clearRect(0, 0, halfwidth, screenheight);
52+
g.setBgColor(b2);
53+
g.clearRect(halfwidth, 0, screenwidth, screenheight);
54+
g.setFont("Vector", 60).setFontAlign(0, 0);
55+
g.setColor(f1);
56+
g.drawString(Math.floor(counter[0]), halfwidth * 0.5, halfheight);
57+
g.setColor(f2);
58+
g.drawString(Math.floor(counter[1]), halfwidth * 1.5, halfheight);
59+
}
60+
else {
61+
g.setBgColor(b2); // Using right counter's colors b/c blue looks nicer than red
62+
g.clearRect(0, 0, screenwidth, screenheight);
63+
g.setFont("Vector", 90).setFontAlign(0, 0);
64+
g.setColor(f2);
65+
g.drawString(Math.floor(counter[0]), halfwidth, halfheight);
66+
}
5267
saveSettings();
5368
if (s.buzz) Bangle.buzz(50,.5);
54-
Bangle.drawWidgets();
69+
70+
Bangle.loadWidgets();
71+
if (s.fullscreen) {
72+
require("widget_utils").hide();
73+
}
74+
else {
75+
Bangle.drawWidgets();
76+
}
5577
}
5678

79+
// Clearing the timer on lock is likely uneeded, but just in case
80+
Bangle.on('lock', e => {
81+
drag = undefined;
82+
var timeOutTimer = sGlob.timeout * 1000;
83+
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout: timeOutTimer});
84+
if (dragtimeout) clearTimeout(dragtimeout);
85+
fastupdateoccurring = false;
86+
});
87+
5788
Bangle.on("drag", e => {
58-
const c = (e.x < halfwidth) ? 0 : 1;
89+
const c = (e.x >= halfwidth && s.display2) ? 1 : 0;
90+
dragCurr = e;
5991
if (!drag) {
6092
if (ignoreonce) {
6193
ignoreonce = false;
6294
return;
6395
}
6496
drag = { x: e.x, y: e.y };
65-
dragtimeout = setTimeout(function () { resetcounter(c); }, 600); //if dragging for 500ms, reset counter
97+
dragtimeout = setTimeout(function () { fastupdatecounter(c); }, 600); //if dragging for 500ms, reset counter
6698
}
6799
else if (drag && !e.b) { // released
68-
let adjust = 0;
69-
const dx = e.x - drag.x, dy = e.y - drag.y;
70-
if (Math.abs(dy) > Math.abs(dx) + 30) {
71-
adjust = (dy > 0) ? -1 : 1;
72-
} else {
73-
adjust = (e.y > halfwidth) ? -1 : 1;
74-
}
75-
counter[c] += adjust;
76-
updateScreen();
77-
drag = undefined;
100+
if (!fastupdateoccurring)
101+
updatecounter(c);
102+
drag = undefined;
103+
if (dragtimeout) {
104+
let timeOutTimer = 1000;
105+
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout: timeOutTimer});
78106
clearTimeout(dragtimeout);
79107
}
108+
fastupdateoccurring = false;
109+
}
80110
});
81111

112+
function updatecounter(which) {
113+
let adjust = 0;
114+
const dx = dragCurr.x - drag.x, dy = dragCurr.y - drag.y;
115+
if (Math.abs(dy) > Math.abs(dx) + 30) {
116+
adjust = (dy > 0) ? -1 : 1;
117+
} else {
118+
adjust = (dragCurr.y > halfheight) ? -1 : 1;
119+
}
120+
counter[which] += adjust;
121+
updateScreen();
122+
}
123+
124+
function fastupdatecounter(which) {
125+
fastupdateoccurring = true;
126+
updatecounter(which);
127+
Bangle.setOptions({backlightTimeout: 0, lockTimeout: 0});
128+
dragtimeout = setTimeout(function () { fastupdatecounter(which); }, 10);
129+
}
130+
131+
82132
function resetcounter(which) {
83-
counter[which] = defaults[which];
84-
console.log("resetting counter ", which);
133+
// If which is null, reset all
134+
fastupdateoccurring = false;
135+
if (dragtimeout) {
136+
let timeOutTimer = 1000;
137+
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout: timeOutTimer});
138+
clearTimeout(dragtimeout);
139+
}
140+
if (which == null) {
141+
for (let iter = 0; iter < defaults.length; iter++) {
142+
counter[iter] = defaults[iter];
143+
}
144+
console.log("resetting all counters");
145+
}
146+
else {
147+
counter[which] = defaults[which];
148+
console.log("resetting counter ", which);
149+
}
85150
updateScreen();
86151
drag = undefined;
87152
ignoreonce = true;
@@ -91,5 +156,13 @@ function resetcounter(which) {
91156
updateScreen();
92157

93158
setWatch(function() {
159+
for (let which = 0; which < defaults.length; which++) {
160+
if(counter[which] != defaults[which]) {
161+
resetcounter(null);
162+
return;
163+
}
164+
}
165+
var timeOutTimer = sGlob.timeout * 1000;
166+
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout: timeOutTimer});
94167
load();
95168
}, BTN1, {repeat:true, edge:"falling"});

apps/counter2/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "counter2",
33
"name": "Counter2",
4-
"version": "0.05",
4+
"version": "0.06",
55
"description": "Dual Counter",
66
"readme":"README.md",
77
"icon": "counter2-icon.png",

0 commit comments

Comments
 (0)