Testing and upload

main
Devin Leamy 2023-10-28 17:22:14 -04:00
parent e5329c0d58
commit a703a611b9
3 changed files with 36 additions and 27 deletions

View File

@ -4,13 +4,5 @@
"version": "0.01", "version": "0.01",
"description": "A stopwatch with multiple modes for Bangle JS 2", "description": "A stopwatch with multiple modes for Bangle JS 2",
"icon": "stopwatch.png", "icon": "stopwatch.png",
"screenshots": [], "src": "timer.app.js"
"tags": "tools,app",
"supports": ["BANGLEJS2"],
"readme": "README.md",
"storage": [
{ "name": "stopwatch.app.js", "url": "stopwatch.app.js" },
{ "name": "stopwatch.img", "url": "stopwatch.icon.js", "evaluate": true }
],
"data": [{ "name": "timer.json" }]
} }

View File

@ -74,7 +74,7 @@ var TimerApp = /** @class */ (function () {
this.timers = []; this.timers = [];
this.displayedTimerIndex = 0; this.displayedTimerIndex = 0;
this.displayTextY = 20; this.displayTextY = 20;
this.timeTextY = this.height * (2.0 / 5.0); this.timeTextY = this.height / 2.0;
this.lastTickTimeMS = Date.now(); this.lastTickTimeMS = Date.now();
this.loadStateOrDefault(); this.loadStateOrDefault();
this.initializeButtons(); this.initializeButtons();
@ -103,8 +103,13 @@ var TimerApp = /** @class */ (function () {
self.leftButton.onClick(x, y); self.leftButton.onClick(x, y);
self.rightButton.onClick(x, y); self.rightButton.onClick(x, y);
} }
self.topLeftButton.onClick(x, y); // Make the navigation buttons easier to click.
self.topRightButton.onClick(x, y); var xx = Math.min(self.width, Math.max(0, point.x - self.width / 4.0));
var yy = Math.min(self.height, Math.max(0, point.y - self.height / 4.0));
self.topLeftButton.onClick(xx, yy);
xx = Math.min(self.width, Math.max(0, point.x + self.width / 4.0));
yy = Math.min(self.height, Math.max(0, point.y - self.height / 4.0));
self.topRightButton.onClick(xx, yy);
}, },
remove: function () { remove: function () {
self.pauseTimer(); self.pauseTimer();
@ -116,8 +121,6 @@ var TimerApp = /** @class */ (function () {
g.setTheme({ bg: "#000", fg: "#fff", dark: true }).clear(); g.setTheme({ bg: "#000", fg: "#fff", dark: true }).clear();
g.setColor(BLACK_COLOR); g.setColor(BLACK_COLOR);
g.fillRect(0, 0, this.width, this.height); g.fillRect(0, 0, this.width, this.height);
Bangle.loadWidgets();
Bangle.drawWidgets();
// These buttons don't update so they only need to be drawn once. // These buttons don't update so they only need to be drawn once.
this.topLeftButton.draw(); this.topLeftButton.draw();
this.topRightButton.draw(); this.topRightButton.draw();
@ -141,11 +144,11 @@ var TimerApp = /** @class */ (function () {
this.largeButton = new Button(0.0, (3.0 / 4.0) * this.height, this.width, this.height / 4.0, BLUE_COLOR, startOrPauseTimer, PLAY_IMG); this.largeButton = new Button(0.0, (3.0 / 4.0) * this.height, this.width, this.height / 4.0, BLUE_COLOR, startOrPauseTimer, PLAY_IMG);
this.leftButton = new Button(0.0, (3.0 / 4.0) * this.height, this.width / 2.0, this.height / 4.0, YELLOW_COLOR, resetTimer, PLAY_IMG); this.leftButton = new Button(0.0, (3.0 / 4.0) * this.height, this.width / 2.0, this.height / 4.0, YELLOW_COLOR, resetTimer, PLAY_IMG);
this.rightButton = new Button(this.width / 2.0, (3.0 / 4.0) * this.height, this.width / 2.0, this.height / 4.0, BLUE_COLOR, resumeTimer, PAUSE_IMG); this.rightButton = new Button(this.width / 2.0, (3.0 / 4.0) * this.height, this.width / 2.0, this.height / 4.0, BLUE_COLOR, resumeTimer, PAUSE_IMG);
var navigatorButtonSize = this.width / 8.0; var navigatorButtonSize = this.width / 5.0;
this.topLeftButton = new Button(0.0, 0.0, navigatorButtonSize, navigatorButtonSize, BLUE_COLOR, function () { this.topLeftButton = new Button(0.0, 0.0, navigatorButtonSize, navigatorButtonSize, BLACK_COLOR, function () {
self.gotoPreviousTimer(); self.gotoPreviousTimer();
}, RESET_IMG); }, RESET_IMG);
this.topRightButton = new Button(this.width - navigatorButtonSize, 0.0, navigatorButtonSize, navigatorButtonSize, BLUE_COLOR, function () { this.topRightButton = new Button(this.width - navigatorButtonSize, 0.0, navigatorButtonSize, navigatorButtonSize, BLACK_COLOR, function () {
self.gotoNextTimer(); self.gotoNextTimer();
}, RESET_IMG); }, RESET_IMG);
}; };
@ -188,16 +191,20 @@ var TimerApp = /** @class */ (function () {
} }
}; };
TimerApp.prototype.pauseDisplayedTimer = function () { TimerApp.prototype.pauseDisplayedTimer = function () {
Bangle.buzz();
this.displayedTimer().running = false; this.displayedTimer().running = false;
}; };
TimerApp.prototype.resetDisplayedTimer = function () { TimerApp.prototype.resetDisplayedTimer = function () {
Bangle.buzz();
this.displayedTimer().elapsedTime = 0.0; this.displayedTimer().elapsedTime = 0.0;
this.displayedTimer().running = false; this.displayedTimer().running = false;
}; };
TimerApp.prototype.resumeDisplayedTimer = function () { TimerApp.prototype.resumeDisplayedTimer = function () {
Bangle.buzz();
this.displayedTimer().running = true; this.displayedTimer().running = true;
}; };
TimerApp.prototype.playDisplayedTimer = function () { TimerApp.prototype.playDisplayedTimer = function () {
Bangle.buzz();
this.displayedTimer().running = true; this.displayedTimer().running = true;
}; };
TimerApp.prototype.displayedTimerIsRunning = function () { TimerApp.prototype.displayedTimerIsRunning = function () {

View File

@ -131,7 +131,7 @@ class TimerApp {
this.timers = [] this.timers = []
this.displayedTimerIndex = 0 this.displayedTimerIndex = 0
this.displayTextY = 20 this.displayTextY = 20
this.timeTextY = this.height * (2.0 / 5.0) this.timeTextY = this.height / 2.0
this.lastTickTimeMS = Date.now() this.lastTickTimeMS = Date.now()
this.loadStateOrDefault() this.loadStateOrDefault()
this.initializeButtons() this.initializeButtons()
@ -151,8 +151,8 @@ class TimerApp {
mode: "custom", mode: "custom",
btn: () => load(), btn: () => load(),
touch: (button, point) => { touch: (button, point) => {
const x = Math.min(self.width, Math.max(0, point.x)) let x = Math.min(self.width, Math.max(0, point.x))
const y = Math.min(self.height, Math.max(0, point.y)) let y = Math.min(self.height, Math.max(0, point.y))
if (self.displayedTimerIsRunning()) { if (self.displayedTimerIsRunning()) {
self.largeButton.onClick(x, y) self.largeButton.onClick(x, y)
@ -163,8 +163,16 @@ class TimerApp {
self.rightButton.onClick(x, y) self.rightButton.onClick(x, y)
} }
self.topLeftButton.onClick(x, y) // Make the navigation buttons easier to click.
self.topRightButton.onClick(x, y) let xx = Math.min(self.width, Math.max(0, point.x - self.width / 4.0))
let yy = Math.min(self.height, Math.max(0, point.y - self.height / 4.0))
self.topLeftButton.onClick(xx, yy)
xx = Math.min(self.width, Math.max(0, point.x + self.width / 4.0))
yy = Math.min(self.height, Math.max(0, point.y - self.height / 4.0))
self.topRightButton.onClick(xx, yy)
}, },
remove: () => { remove: () => {
self.pauseTimer() self.pauseTimer()
@ -177,8 +185,6 @@ class TimerApp {
g.setTheme({ bg: "#000", fg: "#fff", dark: true }).clear() g.setTheme({ bg: "#000", fg: "#fff", dark: true }).clear()
g.setColor(BLACK_COLOR) g.setColor(BLACK_COLOR)
g.fillRect(0, 0, this.width, this.height) g.fillRect(0, 0, this.width, this.height)
Bangle.loadWidgets()
Bangle.drawWidgets()
// These buttons don't update so they only need to be drawn once. // These buttons don't update so they only need to be drawn once.
this.topLeftButton.draw() this.topLeftButton.draw()
this.topRightButton.draw() this.topRightButton.draw()
@ -232,13 +238,13 @@ class TimerApp {
PAUSE_IMG PAUSE_IMG
) )
const navigatorButtonSize = this.width / 8.0 const navigatorButtonSize = this.width / 5.0
this.topLeftButton = new Button( this.topLeftButton = new Button(
0.0, 0.0,
0.0, 0.0,
navigatorButtonSize, navigatorButtonSize,
navigatorButtonSize, navigatorButtonSize,
BLUE_COLOR, BLACK_COLOR,
function () { function () {
self.gotoPreviousTimer() self.gotoPreviousTimer()
}, },
@ -249,7 +255,7 @@ class TimerApp {
0.0, 0.0,
navigatorButtonSize, navigatorButtonSize,
navigatorButtonSize, navigatorButtonSize,
BLUE_COLOR, BLACK_COLOR,
function () { function () {
self.gotoNextTimer() self.gotoNextTimer()
}, },
@ -299,19 +305,23 @@ class TimerApp {
} }
pauseDisplayedTimer() { pauseDisplayedTimer() {
Bangle.buzz()
this.displayedTimer().running = false this.displayedTimer().running = false
} }
resetDisplayedTimer() { resetDisplayedTimer() {
Bangle.buzz()
this.displayedTimer().elapsedTime = 0.0 this.displayedTimer().elapsedTime = 0.0
this.displayedTimer().running = false this.displayedTimer().running = false
} }
resumeDisplayedTimer() { resumeDisplayedTimer() {
Bangle.buzz()
this.displayedTimer().running = true this.displayedTimer().running = true
} }
playDisplayedTimer() { playDisplayedTimer() {
Bangle.buzz()
this.displayedTimer().running = true this.displayedTimer().running = true
} }