Skip to content

Commit

Permalink
Merge pull request #3698 from dormio/master
Browse files Browse the repository at this point in the history
[clockcal] Added an option to show weeks prior to the current week on clock calendar
  • Loading branch information
bobrippling authored Dec 20, 2024
2 parents 0ac4c51 + 794e40f commit f43971e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions apps/clockcal/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
0.08: Fixed typo in settings.js for DRAGDOWN to make option work
0.09: You can now back out of the calendar using the button
0.10: Fix linter warnings
0.11: Added option to show prior weeks on clock calendar
7 changes: 4 additions & 3 deletions apps/clockcal/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Bangle.setUI("clock");
Bangle.loadWidgets();

var s = Object.assign({
CAL_ROWS: 4, //number of calendar rows.(weeks) Shouldn't exceed 5 when using widgets.
CAL_ROWS: 4, //total number of calendar rows.(weeks) Shouldn't exceed 5 when using widgets.
CAL_ROWS_PRIOR: 0, //number of calendar rows.(weeks) that show above the current week
BUZZ_ON_BT: true, //2x slow buzz on disconnect, 2x fast buzz on connect. Will be extra widget eventually
MODE24: true, //24h mode vs 12h mode
FIRSTDAY: 6, //First day of the week: mo, tu, we, th, fr, sa, su
Expand Down Expand Up @@ -178,7 +179,7 @@ function drawWatch() {
const dow = (s.FIRSTDAY + d.getDay()) % 7; //MO=0, SU=6
const today = d.getDate();
var rD = new Date(d.getTime());
rD.setDate(rD.getDate() - dow);
rD.setDate(rD.getDate() - dow - s.CAL_ROWS_PRIOR * 7);
var rDate = rD.getDate();
g.setFontAlign(1, 1);
for (var y = 1; y <= s.CAL_ROWS; y++) {
Expand All @@ -187,7 +188,7 @@ function drawWatch() {
bottomrightY = y * CELL_H + CAL_Y;
g.setFont("Vector", 16);
var fg = ((s.REDSUN && rD.getDay() == 0) || (s.REDSAT && rD.getDay() == 6)) ? '#f00' : '#fff';
if (y == 1 && today == rDate) {
if (y == s.CAL_ROWS_PRIOR + 1 && today == rDate) {
g.setColor('#0f0');
g.fillRect(bottomrightX - CELL_W + 1, bottomrightY - CELL_H - 1, bottomrightX, bottomrightY - 2);
g.setColor('#000');
Expand Down
2 changes: 1 addition & 1 deletion apps/clockcal/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "clockcal",
"name": "Clock & Calendar",
"version": "0.10",
"version": "0.11",
"description": "Clock with Calendar",
"readme":"README.md",
"icon": "app.png",
Expand Down
11 changes: 10 additions & 1 deletion apps/clockcal/settings.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(function (back) {
var FILE = "clockcal.json";
const defaults={
CAL_ROWS: 4, //number of calendar rows.(weeks) Shouldn't exceed 5 when using widgets.
CAL_ROWS: 4, //total number of calendar rows.(weeks) Shouldn't exceed 5 when using widgets.
CAL_ROWS_PRIOR: 0, //number of calendar rows.(weeks) that show above the current week
BUZZ_ON_BT: true, //2x slow buzz on disconnect, 2x fast buzz on connect. Will be extra widget eventually
MODE24: true, //24h mode vs 12h mode
FIRSTDAY: 6, //First day of the week: mo, tu, we, th, fr, sa, su
Expand Down Expand Up @@ -39,6 +40,14 @@
writeSettings();
}
},
'#Cal Rows Prior': {
value: settings.CAL_ROWS_PRIOR,
min: 0, max: 4,
onchange: v => {
settings.CAL_ROWS_PRIOR = v;
writeSettings();
}
},
'Clock mode': {
value: settings.MODE24,
format: v => v ? "24h" : "12h",
Expand Down

0 comments on commit f43971e

Please sign in to comment.