mirror of https://github.com/espruino/BangleApps
pushups: new app
parent
8f7528699f
commit
163f08b990
|
@ -0,0 +1 @@
|
||||||
|
0.01: Initial code
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Pushups
|
||||||
|
|
||||||
|
Train for push ups using the accelerometer. It should buzz everytime you go up and down.
|
||||||
|
Swipe the screen to set the countdown value.
|
||||||
|
|
||||||
|
|
||||||
|
## Creator
|
||||||
|
|
||||||
|
Feel free to give me feedback : is it useful for you ? what other features would you like ?
|
||||||
|
|
||||||
|
frederic.wagner@imag.fr
|
|
@ -0,0 +1 @@
|
||||||
|
require("heatshrink").decompress(atob("mEwwhC/AH4A/AH4A/ACcEogXVolEoAuVAAIXYhvdC6vdAAPQL6QuBAAaPRhtNDAgyQDQIXE7qYPC48iMaFM5gWC6kikAXPpvMDAXSC6BIBhoYB5oXBJB4XBOQPc5lCC4IYPC4StBCwUikgvQAAMCC4TlCeZgHFC4YYKFwoADkgXCDBIuHEQgACOpZTKC6oNGiIASC7YA/AH4A/AH4AdA"))
|
|
@ -0,0 +1,69 @@
|
||||||
|
|
||||||
|
Bangle.loadWidgets();
|
||||||
|
|
||||||
|
const UP = 0;
|
||||||
|
const DOWN = 1;
|
||||||
|
|
||||||
|
let status = UP;
|
||||||
|
|
||||||
|
// to get rid of noise we'll need to count how many measures confirm where we think we are
|
||||||
|
let counts_in_opposite_status = 0;
|
||||||
|
let remaining_pushups = 10;
|
||||||
|
|
||||||
|
function display() {
|
||||||
|
g.clear();
|
||||||
|
g.setColor(0, 0, 0);
|
||||||
|
g.setFont("Vector:80").setFontAlign(0, 0).drawString(""+remaining_pushups, g.getWidth()/2, g.getHeight()/2);
|
||||||
|
Bangle.drawWidgets();
|
||||||
|
g.flip();
|
||||||
|
}
|
||||||
|
|
||||||
|
display();
|
||||||
|
|
||||||
|
Bangle.setPollInterval(80);
|
||||||
|
|
||||||
|
|
||||||
|
setWatch(
|
||||||
|
function () {
|
||||||
|
load();
|
||||||
|
},
|
||||||
|
BTN1,
|
||||||
|
{
|
||||||
|
repeat: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
Bangle.on('swipe', function(directionLR, directionUD) {
|
||||||
|
if (directionUD == -1) {
|
||||||
|
remaining_pushups += 1;
|
||||||
|
} else if (directionUD == 1) {
|
||||||
|
remaining_pushups = Math.max(remaining_pushups-1, 1);
|
||||||
|
} else if (directionLR == -1) {
|
||||||
|
remaining_pushups += 5;
|
||||||
|
} else if (directionLR == 1) {
|
||||||
|
remaining_pushups = Math.max(remaining_pushups-5, 1);
|
||||||
|
}
|
||||||
|
display();
|
||||||
|
});
|
||||||
|
|
||||||
|
Bangle.on('accel', function(xyz) {
|
||||||
|
let new_status = (xyz.y > 0.4)?DOWN:UP;
|
||||||
|
if (new_status != status) {
|
||||||
|
counts_in_opposite_status += 1;
|
||||||
|
|
||||||
|
if (counts_in_opposite_status == 6) {
|
||||||
|
status = 1-status;
|
||||||
|
counts_in_opposite_status = 0;
|
||||||
|
if (status == UP) {
|
||||||
|
remaining_pushups -= 1;
|
||||||
|
display();
|
||||||
|
if (remaining_pushups == 0) {
|
||||||
|
Bangle.buzz(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Bangle.buzz(100);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
counts_in_opposite_status = 0;
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"id": "pushups",
|
||||||
|
"name": "Pushups",
|
||||||
|
"shortName": "Pushups",
|
||||||
|
"version": "0.1",
|
||||||
|
"description": "Pushups countdown using the accelerometer.",
|
||||||
|
"allow_emulator":false,
|
||||||
|
"icon": "pushups.png",
|
||||||
|
"type": "app",
|
||||||
|
"tags": "health",
|
||||||
|
"supports": ["BANGLEJS2"],
|
||||||
|
"readme": "README.md",
|
||||||
|
"storage": [
|
||||||
|
{"name":"pushups.app.js","url":"app.js"},
|
||||||
|
{"name":"pushups.img","url":"app-icon.js","evaluate":true}
|
||||||
|
]
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 854 B |
Loading…
Reference in New Issue