Skip to content

Commit 5579fd3

Browse files
author
Corwin Kerr
committed
Merge remote-tracking branch 'origin/master' into widclkinfo-swipeOn-aware
2 parents 0d4234d + 6ff9693 commit 5579fd3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+3739
-523
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ updates:
55
directory: "/"
66
schedule:
77
interval: "daily"
8+
reviewers:
9+
- "gfwilliams"

apps/agenda/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
0.13: Show day of the week in date
1616
0.14: Fixed "Today" and "Yesterday" wrongly displayed for allDay events on some time zones
1717
0.15: Minor code improvements
18+
0.16: Correct date for all day events in negative timezones, improve locale display

apps/agenda/agenda.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@ var settings = require("Storage").readJSON("agenda.settings.json",true)||{};
3030

3131
CALENDAR=CALENDAR.sort((a,b)=>a.timestamp - b.timestamp);
3232

33-
function getDate(timestamp) {
34-
return new Date(timestamp*1000);
33+
function getDate(timestamp, allDay) {
34+
// All day events are always in UTC and always start at 00:00:00, so we
35+
// need to "undo" the timezone offsetting to make sure that the day is
36+
// correct.
37+
var offset = allDay ? new Date().getTimezoneOffset() * 60 : 0
38+
return new Date((timestamp+offset)*1000);
3539
}
40+
3641
function formatDay(date) {
37-
let formattedDate = Locale.dow(date,1) + " " + Locale.date(date).replace(/\d\d\d\d/,"");
42+
let formattedDate = Locale.dow(date,1) + " " + Locale.date(date).replace(/,*\s*\d\d\d\d/,"");
3843
if (!settings.useToday) {
3944
return formattedDate;
4045
}
@@ -57,8 +62,9 @@ function formatDateLong(date, includeDay, allDay) {
5762
}
5863
return shortTime;
5964
}
65+
6066
function formatDateShort(date, allDay) {
61-
return formatDay(date)+(allDay?"":Locale.time(date,1)+Locale.meridian(date));
67+
return formatDay(date)+(allDay?"":" "+Locale.time(date,1)+Locale.meridian(date));
6268
}
6369

6470
var lines = [];
@@ -69,16 +75,19 @@ function showEvent(ev) {
6975
//var lines = [];
7076
if (ev.title) lines = g.wrapString(ev.title, g.getWidth()-10);
7177
var titleCnt = lines.length;
72-
var start = getDate(ev.timestamp);
73-
var end = getDate((+ev.timestamp) + (+ev.durationInSeconds));
78+
var start = getDate(ev.timestamp, ev.allDay);
79+
// All day events end at the midnight boundary of the following day. Here, we
80+
// subtract one second for all day events so the days display correctly.
81+
const allDayEndCorrection = ev.allDay ? 1 : 0;
82+
var end = getDate((+ev.timestamp) + (+ev.durationInSeconds) - allDayEndCorrection, ev.allDay);
7483
var includeDay = true;
7584
if (titleCnt) lines.push(""); // add blank line after title
7685
if(start.getDay() == end.getDay() && start.getMonth() == end.getMonth())
7786
includeDay = false;
78-
if(includeDay && ev.allDay) {
79-
//single day all day (average to avoid getting previous day)
87+
if(!includeDay && ev.allDay) {
88+
//single day all day
8089
lines = lines.concat(
81-
g.wrapString(formatDateLong(new Date((start+end)/2), includeDay, ev.allDay), g.getWidth()-10));
90+
g.wrapString(formatDateLong(start, includeDay, ev.allDay), g.getWidth()-10));
8291
} else if(includeDay || ev.allDay) {
8392
lines = lines.concat(
8493
/*LANG*/"Start"+":",
@@ -137,7 +146,7 @@ function showList() {
137146
if (!ev) return;
138147
var isPast = false;
139148
var x = r.x+2, title = ev.title;
140-
var body = formatDateShort(getDate(ev.timestamp),ev.allDay)+"\n"+(ev.location?ev.location:/*LANG*/"No location");
149+
var body = formatDateShort(getDate(ev.timestamp, ev.allDay),ev.allDay)+"\n"+(ev.location?ev.location:/*LANG*/"No location");
141150
if(settings.pastEvents) isPast = ev.timestamp + ev.durationInSeconds < (new Date())/1000;
142151
if (title) g.setFontAlign(-1,-1).setFont(fontBig)
143152
.setColor(isPast ? "#888" : g.theme.fg).drawString(title, x+4,r.y+2);

apps/agenda/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "agenda",
33
"name": "Agenda",
4-
"version": "0.15",
4+
"version": "0.16",
55
"description": "Simple agenda",
66
"icon": "agenda.png",
77
"screenshots": [{"url":"screenshot_agenda_overview.png"}, {"url":"screenshot_agenda_event1.png"}, {"url":"screenshot_agenda_event2.png"}],

apps/andark/ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
0.05: Fix support for dark theme + support widgets +
66
add settings for widgets, order of drawing and hour hand length
77
0.06: Fix issue showing widgets when app is fast-loaded into from launcher with widgets disabled
8+
0.07: Enable fast loading and queue updates to the second
9+
0.08: Restore redraw on charging event + fixup for safer fast-loading

apps/andark/app.js

Lines changed: 68 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{
12
const defaultSettings = {
23
loadWidgets : false,
34
textAboveHands : false,
@@ -11,9 +12,9 @@ const zahlpos=(function() {
1112
let z=[];
1213
let sk=1;
1314
for(let i=-10;i<50;i+=5){
14-
let win=i*2*Math.PI/60;
15-
let xsk =c.x+2+Math.cos(win)*(c.x-10),
16-
ysk =c.y+2+Math.sin(win)*(c.x-10);
15+
let win=i*2*Math.PI/60;
16+
let xsk =c.x+2+Math.cos(win)*(c.x-10),
17+
ysk =c.y+2+Math.sin(win)*(c.x-10);
1718
if(sk==3){xsk-=10;}
1819
if(sk==6){ysk-=10;}
1920
if(sk==9){xsk+=10;}
@@ -25,18 +26,15 @@ const zahlpos=(function() {
2526
return z;
2627
})();
2728

28-
let unlock = false;
29-
30-
function zeiger(len,dia,tim){
29+
const zeiger = function(len,dia,tim) {
3130
const x=c.x+ Math.cos(tim)*len/2,
3231
y=c.y + Math.sin(tim)*len/2,
3332
d={"d":3,"x":dia/2*Math.cos(tim+Math.PI/2),"y":dia/2*Math.sin(tim+Math.PI/2)},
3433
pol=[c.x-d.x,c.y-d.y,c.x+d.x,c.y+d.y,x+d.x,y+d.y,x-d.x,y-d.y];
3534
return pol;
35+
};
3636

37-
}
38-
39-
function drawHands(d) {
37+
const drawHands = function(d) {
4038
let m=d.getMinutes(), h=d.getHours(), s=d.getSeconds();
4139
g.setColor(1,1,1);
4240

@@ -61,32 +59,60 @@ function drawHands(d) {
6159
g.fillPoly(sekz,true);
6260
}
6361
g.fillCircle(c.x,c.y,4);
64-
}
62+
};
6563

66-
function drawText(d) {
64+
const drawText = function(d) {
6765
g.setFont("Vector",10);
6866
g.setBgColor(0,0,0);
6967
g.setColor(1,1,1);
70-
let dateStr = require("locale").date(d);
68+
const dateStr = require("locale").date(d);
7169
g.drawString(dateStr, c.x, c.y+20, true);
72-
let batStr = Math.round(E.getBattery()/5)*5+"%";
70+
const batStr = Math.round(E.getBattery()/5)*5+"%";
7371
if (Bangle.isCharging()) {
7472
g.setBgColor(1,0,0);
7573
}
7674
g.drawString(batStr, c.x, c.y+40, true);
77-
}
75+
};
7876

79-
function drawNumbers() {
77+
const drawNumbers = function() {
8078
//draws the numbers on the screen
8179
g.setFont("Vector",20);
8280
g.setColor(1,1,1);
8381
g.setBgColor(0,0,0);
8482
for(let i = 0;i<12;i++){
85-
g.drawString(zahlpos[i][0],zahlpos[i][1],zahlpos[i][2],true);
83+
g.drawString(zahlpos[i][0],zahlpos[i][1],zahlpos[i][2],true);
8684
}
87-
}
85+
};
86+
87+
let drawTimeout;
88+
let queueMillis = 1000;
89+
let unlock = true;
90+
91+
const updateState = function() {
92+
if (Bangle.isLCDOn()) {
93+
if (!Bangle.isLocked()) {
94+
queueMillis = 1000;
95+
unlock = true;
96+
} else {
97+
queueMillis = 60000;
98+
unlock = false;
99+
}
100+
draw();
101+
} else {
102+
if (drawTimeout) clearTimeout(drawTimeout);
103+
drawTimeout = undefined;
104+
}
105+
};
106+
107+
const queueDraw = function() {
108+
if (drawTimeout) clearTimeout(drawTimeout);
109+
drawTimeout = setTimeout(function() {
110+
drawTimeout = undefined;
111+
draw();
112+
}, queueMillis - (Date.now() % queueMillis));
113+
};
88114

89-
function draw(){
115+
const draw = function() {
90116
// draw black rectangle in the middle to clear screen from scale and hands
91117
g.setColor(0,0,0);
92118
g.fillRect(10,10,2*c.x-10,2*c.x-10);
@@ -100,10 +126,11 @@ function draw(){
100126
} else {
101127
drawText(d); drawHands(d);
102128
}
103-
}
129+
queueDraw();
130+
};
104131

105132
//draws the scale once the app is startet
106-
function drawScale(){
133+
const drawScale = function() {
107134
// clear the screen
108135
g.setBgColor(0,0,0);
109136
g.clear();
@@ -117,36 +144,35 @@ function drawScale(){
117144
g.fillRect(10,10,2*c.x-10,2*c.x-10);
118145
g.setColor(1,1,1);
119146
}
120-
}
147+
};
121148

122149
//// main running sequence ////
123150

124151
// Show launcher when middle button pressed, and widgets that we're clock
125-
Bangle.setUI("clock");
152+
Bangle.setUI({
153+
mode: "clock",
154+
remove: function() {
155+
Bangle.removeListener('lcdPower', updateState);
156+
Bangle.removeListener('lock', updateState);
157+
Bangle.removeListener('charging', draw);
158+
// We clear drawTimout after removing all listeners, because they can add one again
159+
if (drawTimeout) clearTimeout(drawTimeout);
160+
drawTimeout = undefined;
161+
require("widget_utils").show();
162+
}
163+
});
126164
// Load widgets if needed, and make them show swipeable
127165
if (settings.loadWidgets) {
128166
Bangle.loadWidgets();
129167
require("widget_utils").swipeOn();
130168
} else if (global.WIDGETS) require("widget_utils").hide();
131-
// Clear the screen once, at startup
132-
drawScale();
133-
draw();
134-
135-
let secondInterval = setInterval(draw, 1000);
136169

137170
// Stop updates when LCD is off, restart when on
138-
Bangle.on('lcdPower',on=>{
139-
if (secondInterval) clearInterval(secondInterval);
140-
secondInterval = undefined;
141-
if (on) {
142-
secondInterval = setInterval(draw, 1000);
143-
draw(); // draw immediately
144-
}
145-
});
146-
Bangle.on('lock',on=>{
147-
unlock = !on;
148-
if (secondInterval) clearInterval(secondInterval);
149-
secondInterval = setInterval(draw, unlock ? 1000 : 60000);
150-
draw(); // draw immediately
151-
});
152-
Bangle.on('charging',on=>{draw();});
171+
Bangle.on('lcdPower', updateState);
172+
Bangle.on('lock', updateState);
173+
Bangle.on('charging', draw); // Immediately redraw when charger (dis)connected
174+
175+
updateState();
176+
drawScale();
177+
draw();
178+
}

apps/andark/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{ "id": "andark",
22
"name": "Analog Dark",
33
"shortName":"AnDark",
4-
"version":"0.06",
4+
"version":"0.08",
55
"description": "analog clock face without disturbing widgets",
66
"icon": "andark_icon.png",
77
"type": "clock",

apps/assistedgps/custom.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ <h2>Assisted GPS</h2>
4949
<input type="radio" name="gnss_select" value="6"><i class="form-icon"></i> BDS+GLONASS
5050
</label>
5151
<label class="form-radio">
52-
<input type="radio" name="gnss_select" value="6"><i class="form-icon"></i> GPS+BDS+GLONASS
52+
<input type="radio" name="gnss_select" value="7"><i class="form-icon"></i> GPS+BDS+GLONASS
5353
</label>
5454
</div>
5555
</div>

apps/ateatimer/ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
0.01: First release
2+
0.02: Fix icon, utilize sched, show running timer on app relaunch

apps/ateatimer/app-icon.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)