forked from FOSS/BangleApps
Add disc golf score tracking app
parent
bbd2cac110
commit
785ce64779
|
@ -0,0 +1 @@
|
|||
0.01: Initial version of disc golf app. Has throw and hole counter, along with summary screen. Uses buttons for holes & throws.
|
|
@ -0,0 +1,14 @@
|
|||
# Disc Golf
|
||||
|
||||
Individual score tracking for disc golf on your wrist.
|
||||
|
||||

|
||||

|
||||
|
||||
## Usage
|
||||
|
||||
Press the side button once to increment throws. Double-tap the side button to increment holes. View your game summary with the button in the upper right of the screen.
|
||||
|
||||
## Creator
|
||||
|
||||
Made by [Noah Howard](https://github.com/nh-99)
|
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("mEwxH+AH4A/ABFzudsAAImmABIppAAIQBFcYMBzwMDFbP+y5RJHYiHdLJYADG5AATzxaNFotszwuXFp5sFLq4tIVpANNF0D4FRqobFJ5peaFxKtJXgi9VzxdSLwwvUFyYvaFxIhKOYwvSFxoAEzyjJF7I/VFyzRjU5QICuYiNBxBJTQp7lFF7byQGQYwSOwovSOpJsFdpwvTao4voMQ4vQOQQwmX4oQCBAwwgCxAvWDIwvPGD4vIy4WJSSzcFMCCpGMC+eGChiUYJwjJPIRiTF5xULBxwvVEJgQQCIQOEF5X+zwfLSoY0HBYg9FF5a2QDSQvNWqJbBAQTaOMTY9PF6DFNAB4uRGLguUYygucfKwubGQgzLFsAAHFYV6Fc4A/AAw="))
|
|
@ -0,0 +1,171 @@
|
|||
Bangle.loadWidgets();
|
||||
|
||||
//
|
||||
// App imports
|
||||
//
|
||||
var Layout = require("Layout");
|
||||
|
||||
//
|
||||
// App variables
|
||||
//
|
||||
var holeCount = 1;
|
||||
var throwCount = 0;
|
||||
var drawTimeout;
|
||||
var currentScreen = 'throw';
|
||||
var redraw = true;
|
||||
var update = true;
|
||||
var holeSummary = {
|
||||
"< Back" : () => { update = true; redraw = true; currentScreen = 'throw'; E.showMenu(); createThrowLayout(); },
|
||||
"Hole #1": { value: 0 },
|
||||
"Hole #2": { value: 0 },
|
||||
"Hole #3": { value: 0 },
|
||||
"Hole #4": { value: 0 },
|
||||
"Hole #5": { value: 0 },
|
||||
"Hole #6": { value: 0 },
|
||||
"Hole #7": { value: 0 },
|
||||
"Hole #8": { value: 0 },
|
||||
"Hole #9": { value: 0 },
|
||||
"Front": { value: 0 },
|
||||
"Hole #10": { value: 0 },
|
||||
"Hole #11": { value: 0 },
|
||||
"Hole #12": { value: 0 },
|
||||
"Hole #13": { value: 0 },
|
||||
"Hole #14": { value: 0 },
|
||||
"Hole #15": { value: 0 },
|
||||
"Hole #16": { value: 0 },
|
||||
"Hole #17": { value: 0 },
|
||||
"Hole #18": { value: 0 },
|
||||
"Back": { value: 0 },
|
||||
};
|
||||
|
||||
// Images
|
||||
function getBackImage() {
|
||||
return atob("FhYBAAAAEAAAwAAHAAA//wH//wf//g///BwB+DAB4EAHwAAPAAA8AADwAAPAAB4AAHgAB+AH/wA/+AD/wAH8AA==");
|
||||
}
|
||||
function getMenuImage() {
|
||||
return {
|
||||
width : 20, height : 20, bpp : 1,
|
||||
buffer : require("heatshrink").decompress(atob("AAk///D//8CBcDBwITB4AiVA"))
|
||||
};
|
||||
}
|
||||
function getBasketIcon() {
|
||||
return {
|
||||
width : 20, height : 20, bpp : 1,
|
||||
buffer : require("heatshrink").decompress(atob("gFggF/8EH/0AiWAgtogEW0EDt0Am3ggfsgEf4EB/EA//4j//wEChEP/8AgwnDAgw"))
|
||||
};
|
||||
}
|
||||
function getFrisbeeIcon() {
|
||||
return {
|
||||
width : 20, height : 20, bpp : 1,
|
||||
buffer : require("heatshrink").decompress(atob("AAf+gF/wE+uEPx0B+PAn0cgf/4F3/0G/1g9/7g1/7AJB4+f/k+v3B/Hcg4WBj/4E4ItC"))
|
||||
};
|
||||
}
|
||||
|
||||
var throwLayout;
|
||||
|
||||
function createThrowLayout() {
|
||||
throwLayout = new Layout( {
|
||||
type:"v", c: [
|
||||
// Title & menu button
|
||||
{
|
||||
type:"h", fillx:1, valign:-1, bgCol:g.theme.bg2, col: g.theme.fg2, c: [
|
||||
{type:"img", src:getBasketIcon()},
|
||||
{type:"txt", pad:4, font:"15%", label:holeCount, id: "holeCount"},
|
||||
{type:"txt", pad:4, font:"15%", label: '', fillx:1},
|
||||
{type:"btn", src:getMenuImage(), halign:1, cb: l=>{ currentScreen = 'summary'; update = true; redraw = true; }}
|
||||
]
|
||||
},
|
||||
// Throw count
|
||||
{
|
||||
type:"h", filly:1, c: [
|
||||
{type:"img", pad:4, src:getFrisbeeIcon() },
|
||||
{type:"txt", fillx:1, font:"6x8:2", label:"Throws: "+throwCount, id:"throwCount"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {lazy:true});
|
||||
}
|
||||
|
||||
function incrementHole() {
|
||||
if (holeCount > 18) return;
|
||||
resetThrow();
|
||||
holeCount += 1;
|
||||
holeSummary["Hole #" + holeCount] = {value: 0};
|
||||
}
|
||||
function incrementThrow() {
|
||||
throwCount += 1;
|
||||
holeSummary["Hole #" + holeCount] = {value: throwCount};
|
||||
}
|
||||
function decrementThrow() {
|
||||
throwCount -= 1;
|
||||
holeSummary["Hole #" + holeCount] = {value: throwCount};
|
||||
}
|
||||
function resetThrow() {
|
||||
throwCount = 0;
|
||||
}
|
||||
function computeFrontScore() {
|
||||
var scoreSum = 0;
|
||||
for (var i = 1; i < 10; i++) {
|
||||
scoreSum += holeSummary["Hole #" + i].value;
|
||||
}
|
||||
holeSummary.Front = {value: scoreSum};
|
||||
}
|
||||
function computeBackScore() {
|
||||
var scoreSum = 0;
|
||||
for (var i = 1; i < 19; i++) {
|
||||
scoreSum += holeSummary["Hole #" + i].value;
|
||||
}
|
||||
holeSummary.Back = {value: scoreSum};
|
||||
}
|
||||
|
||||
// update the app state/variables
|
||||
function updateApp() {
|
||||
throwLayout.holeCount.label = holeCount;
|
||||
throwLayout.throwCount.label = "Throws: " + throwCount;
|
||||
}
|
||||
|
||||
// update the screen
|
||||
function draw() {
|
||||
updateApp();
|
||||
if (redraw) {
|
||||
throwLayout.forgetLazyState();
|
||||
redraw = false;
|
||||
}
|
||||
if (update) {
|
||||
if (currentScreen == 'throw') {
|
||||
throwLayout.render();
|
||||
} else if (currentScreen == 'summary') {
|
||||
E.showMenu(holeSummary);
|
||||
}
|
||||
update = false;
|
||||
}
|
||||
// schedule a draw for the next 500ms
|
||||
if (drawTimeout) clearTimeout(drawTimeout);
|
||||
drawTimeout = setTimeout(function() {
|
||||
drawTimeout = undefined;
|
||||
draw();
|
||||
}, 500 - (Date.now() % 500));
|
||||
}
|
||||
|
||||
//
|
||||
// button press events
|
||||
//
|
||||
setWatch((p) => {
|
||||
if (p.time - p.lastTime < 0.2) {
|
||||
decrementThrow();
|
||||
incrementHole();
|
||||
} else {
|
||||
incrementThrow();
|
||||
}
|
||||
computeFrontScore();
|
||||
computeBackScore();
|
||||
update = true;
|
||||
}, BTN, {edge:"rising", debounce:50, repeat:true});
|
||||
|
||||
//
|
||||
// main app function start
|
||||
//
|
||||
g.clear();
|
||||
Bangle.drawWidgets();
|
||||
createThrowLayout();
|
||||
draw();
|
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
|
@ -0,0 +1,14 @@
|
|||
{ "id": "discgolf",
|
||||
"name": "Disc Golf",
|
||||
"shortName":"Disc Golf",
|
||||
"version":"0.01",
|
||||
"description": "A personal disc golf score tracker",
|
||||
"icon": "app.png",
|
||||
"tags": "",
|
||||
"supports" : ["BANGLEJS2"],
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"discgolf.app.js","url":"app.js"},
|
||||
{"name":"discgolf.img","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
Loading…
Reference in New Issue