pushups: working on menu ; fiddling with accel
parent
2568a1a221
commit
d2133841b8
|
|
@ -1,6 +1,5 @@
|
||||||
let h = require("heatshrink");
|
let h = require("heatshrink");
|
||||||
|
|
||||||
|
|
||||||
//TODO: should we force not moving for planks and rests
|
//TODO: should we force not moving for planks and rests
|
||||||
|
|
||||||
const ACTIVITIES = ["pushups", "situps", "squats", "plank", "jacks", "rest"];
|
const ACTIVITIES = ["pushups", "situps", "squats", "plank", "jacks", "rest"];
|
||||||
|
|
@ -219,6 +218,9 @@ class FitnessStatus {
|
||||||
let status = new FitnessStatus(10 * 60);
|
let status = new FitnessStatus(10 * 60);
|
||||||
// status.display();
|
// status.display();
|
||||||
|
|
||||||
|
Bangle.accelWr(0x18,0b01110100); // off, +-8g // NOTE: this code is taken from 'accelrec' app
|
||||||
|
Bangle.accelWr(0x1B,0x03 | 0x40); // 100hz output, ODR/2 filter
|
||||||
|
Bangle.accelWr(0x18,0b11110100); // +-8g
|
||||||
Bangle.setPollInterval(10);
|
Bangle.setPollInterval(10);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -249,7 +251,7 @@ function start_routine() {
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
status.display();
|
status.display();
|
||||||
}, 250);
|
}, 350);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,14 +259,7 @@ function start_routine() {
|
||||||
function edit_menu() {
|
function edit_menu() {
|
||||||
let w = g.getWidth();
|
let w = g.getWidth();
|
||||||
let h = g.getHeight();
|
let h = g.getHeight();
|
||||||
let routine = [
|
let routine = status.routine;
|
||||||
[0, 10],
|
|
||||||
[1, 10],
|
|
||||||
[2, 10],
|
|
||||||
[3, 30],
|
|
||||||
[4, 10],
|
|
||||||
[5, 30]
|
|
||||||
];
|
|
||||||
|
|
||||||
E.showScroller({
|
E.showScroller({
|
||||||
h : 60,
|
h : 60,
|
||||||
|
|
@ -291,12 +286,50 @@ function edit_menu() {
|
||||||
} else if (idx == routine.length) {
|
} else if (idx == routine.length) {
|
||||||
console.log("TODO: add");
|
console.log("TODO: add");
|
||||||
} else {
|
} else {
|
||||||
console.log("TODO: change counter");
|
E.showScroller();
|
||||||
|
set_counter(idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function set_counter(index) {
|
||||||
|
let w = g.getWidth();
|
||||||
|
let h = g.getHeight();
|
||||||
|
let counter = status.routine[index][1];
|
||||||
|
g.setFont("Vector:64")
|
||||||
|
.setFontAlign(0, 0);
|
||||||
|
g.clear();
|
||||||
|
g.drawString(""+counter, w/2, h/2);
|
||||||
|
Bangle.on("swipe", function (directionLR, directionUD) {
|
||||||
|
if (directionUD == -1) {
|
||||||
|
counter += 5;
|
||||||
|
} else if (directionUD == 1) {
|
||||||
|
counter -= 5;
|
||||||
|
} else if (directionLR == -1) {
|
||||||
|
counter -= 1;
|
||||||
|
} else if (directionLR == 1) {
|
||||||
|
counter += 1;
|
||||||
|
}
|
||||||
|
if (counter < 0) {
|
||||||
|
counter = 0;
|
||||||
|
}
|
||||||
|
g.clear();
|
||||||
|
g.drawString(""+counter, w/2, h/2);
|
||||||
|
});
|
||||||
|
Bangle.on("touch", function(button, xy) {
|
||||||
|
if (counter == 0) {
|
||||||
|
status.routine.splice(index, 1);
|
||||||
|
} else {
|
||||||
|
status.routine[index][1] = counter;
|
||||||
|
}
|
||||||
|
Bangle.removeAllListeners("touch");
|
||||||
|
Bangle.removeAllListeners("swipe");
|
||||||
|
edit_menu();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function main_menu() {
|
function main_menu() {
|
||||||
let w = g.getWidth();
|
let w = g.getWidth();
|
||||||
let h = g.getHeight();
|
let h = g.getHeight();
|
||||||
|
|
@ -308,11 +341,22 @@ function main_menu() {
|
||||||
.setFontAlign(0, 0)
|
.setFontAlign(0, 0)
|
||||||
.drawString("Start", w/2, h/4);
|
.drawString("Start", w/2, h/4);
|
||||||
g.drawString("Edit", w/2, 3*h/4);
|
g.drawString("Edit", w/2, 3*h/4);
|
||||||
|
Bangle.setLocked(false);
|
||||||
Bangle.on("touch", function(button, xy) {
|
Bangle.on("touch", function(button, xy) {
|
||||||
if (xy.y > h/2+10) {
|
if (xy.y > h/2+10) {
|
||||||
|
g.fillRect(10, h/2+10, w-10, h-10);
|
||||||
|
g.setColor(1, 1, 1)
|
||||||
|
.setFont("Vector:32")
|
||||||
|
.setFontAlign(0, 0)
|
||||||
|
.drawString("Edit", w/2, 3*h/4);
|
||||||
Bangle.removeAllListeners("touch");
|
Bangle.removeAllListeners("touch");
|
||||||
edit_menu();
|
edit_menu();
|
||||||
} else if (xy.y < h/2-10) {
|
} else if (xy.y < h/2-10) {
|
||||||
|
g.fillRect(10, 10, w-10, h/2-10);
|
||||||
|
g.setColor(1, 1, 1)
|
||||||
|
.setFont("Vector:32")
|
||||||
|
.setFontAlign(0, 0)
|
||||||
|
.drawString("Start", w/2, h/4);
|
||||||
Bangle.removeAllListeners("touch");
|
Bangle.removeAllListeners("touch");
|
||||||
start_routine();
|
start_routine();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue