Skip to content

Commit

Permalink
Merge branch 'master' of github.com:espruino/BangleApps
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Oct 18, 2021
2 parents 3fb3381 + f0c9f07 commit 2cfc3ca
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 11 deletions.
19 changes: 16 additions & 3 deletions apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@
"icon": "chrono.png",
"version":"0.01",
"description": "Single click BTN1 to add 5 minutes. Single click BTN2 to add 30 seconds. Single click BTN3 to add 5 seconds. Tap to pause or play to timer. Double click BTN1 to reset. When timer finishes the watch vibrates.",
"tags": "Tools",
"tags": "tool",
"storage": [
{"name":"chrono.app.js","url":"chrono.js"},
{"name":"chrono.img","url":"chrono-icon.js","evaluate":true}
Expand Down Expand Up @@ -1577,7 +1577,7 @@
"icon": "app.png",
"version":"0.03",
"description": "Chronometer (timer) which runs as widget.",
"tags": "tools,widget",
"tags": "tool,widget,b2",
"readme": "README.md",
"storage": [
{"name":"chronowid.wid.js","url":"widget.js"},
Expand Down Expand Up @@ -3517,7 +3517,7 @@
"name": "Pastel Clock",
"shortName": "Pastel",
"icon": "pastel.png",
"version":"0.03",
"version":"0.04",
"description": "A Configurable clock with custom fonts and background",
"tags": "clock,b2",
"type":"clock",
Expand Down Expand Up @@ -3598,5 +3598,18 @@
"storage": [
{"name":"menusmall.boot.js","url":"boot.js"}
]
},
{ "id": "ffcniftya",
"name": "Nifty-A Clock",
"icon": "app.png",
"version":"0.01",
"description": "A nifty clock with time and date",
"tags":"clock,b2",
"type":"clock",
"allow_emulator":true,
"storage": [
{"name":"ffcniftya.app.js","url":"app.js"},
{"name":"ffcniftya.img","url":"app-icon.js","evaluate":true}
]
}
]
8 changes: 6 additions & 2 deletions apps/chronowid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ The advantage is, that you can still see your normal watchface and other widgets
The widget is always active, but only shown when the timer is on.
Hours, minutes, seconds and timer status can be set with an app.

Depending on when you start the timer, it may alert up to 0,999 seconds early. This is because it checks only for full seconds. When there is less than one seconds left, it buzzes. This cannot be avoided without checking more than every second, which I would like to avoid.
When there is less than one seconds left on the timer it buzzes.

The widget has been tested on Bangle 1 and Bangle 2

## Screenshots

TBD
![](chrono_with_wave.jpg)
![](chrono_with_pastel.jpg)


## Features

Expand Down
1 change: 1 addition & 0 deletions apps/ffcniftya/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.01: New Clock Nifty A
1 change: 1 addition & 0 deletions apps/ffcniftya/app-icon.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

95 changes: 95 additions & 0 deletions apps/ffcniftya/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
const locale = require("locale");
const is12Hour = (require("Storage").readJSON("setting.json", 1) || {})["12hour"];

/* Clock *********************************************/
const scale = g.getWidth() / 176;

const widget = 24;

const viewport = {
width: g.getWidth(),
height: g.getHeight(),
}

const center = {
x: viewport.width / 2,
y: Math.round(((viewport.height - widget) / 2) + widget),
}

function d02(value) {
return ('0' + value).substr(-2);
}

function draw() {
g.reset();
g.clearRect(0, widget, viewport.width, viewport.height);
const now = new Date();

const hour = d02(now.getHours() - (is12Hour && now.getHours() > 12 ? 12 : 0));
const minutes = d02(now.getMinutes());
const day = d02(now.getDay());
const month = d02(now.getMonth() + 1);
const year = now.getFullYear();

const month2 = locale.month(now, 3);
const day2 = locale.dow(now, 3);

g.setFontAlign(1, 0).setFont("Vector", 90 * scale);
g.drawString(hour, center.x + 32 * scale, center.y - 31 * scale);
g.drawString(minutes, center.x + 32 * scale, center.y + 46 * scale);

g.fillRect(center.x + 30 * scale, center.y - 72 * scale, center.x + 32 * scale, center.y + 74 * scale);

g.setFontAlign(-1, 0).setFont("Vector", 16 * scale);
g.drawString(year, center.x + 40 * scale, center.y - 62 * scale);
g.drawString(month, center.x + 40 * scale, center.y - 44 * scale);
g.drawString(day, center.x + 40 * scale, center.y - 26 * scale);
g.drawString(month2, center.x + 40 * scale, center.y + 48 * scale);
g.drawString(day2, center.x + 40 * scale, center.y + 66 * scale);
}


/* Minute Ticker *************************************/

let tickTimer;

function clearTickTimer() {
if (tickTimer) {
clearTimeout(tickTimer);
tickTimer = undefined;
}
}

function queueNextTick() {
clearTickTimer();
tickTimer = setTimeout(tick, 60000 - (Date.now() % 60000));
// tickTimer = setTimeout(tick, 3000);
}

function tick() {
draw();
queueNextTick();
}

/* Init **********************************************/

// Clear the screen once, at startup
g.clear();
// Start ticking
tick();

// Stop updates when LCD is off, restart when on
Bangle.on('lcdPower', (on) => {
if (on) {
tick(); // Start ticking
} else {
clearTickTimer(); // stop ticking
}
});

// Load widgets
Bangle.loadWidgets();
Bangle.drawWidgets();

// Show launcher when middle button pressed
Bangle.setUI("clock");
Binary file added apps/ffcniftya/app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/pastel/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0.01: First release
0.02: Display 12 hour clock as 12:xx not 00:xx when just into PM
0.03: Make it work with Gadgetbridge, Notifications fullscreen on a Bangle 2
0.04: Leave space at the bottom for Chrono widget, set back option at first option
8 changes: 4 additions & 4 deletions apps/pastel/pastel.app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions apps/pastel/pastel.settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

E.showMenu({
'': { 'title': 'Pastel Clock' },
'< Back': back,
'Font': {
value: 0 | font_options.indexOf(s.font),
min: 0, max: 4,
Expand All @@ -50,7 +51,6 @@
s.date = !s.date
save()
},
},
'< Back': back,
}
})
})

0 comments on commit 2cfc3ca

Please sign in to comment.