mirror of https://github.com/espruino/BangleApps
More fixes
parent
900805e71b
commit
707f4a1ccd
|
@ -2,10 +2,8 @@ const STARTED = 1;
|
|||
const RESTING = 2;
|
||||
const COMPLETED = 3;
|
||||
const ONE_SECOND = 1000;
|
||||
const INCREMENT = "increment";
|
||||
const DECREMENT = "decrement";
|
||||
|
||||
class Exercise {
|
||||
exports = class Exercise {
|
||||
constructor(params /*{title, weight, unit, restPeriod}*/) {
|
||||
const DEFAULTS = {
|
||||
title: "Unknown",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Program {
|
||||
exports = class Program {
|
||||
constructor(params) {
|
||||
const DEFAULTS = {
|
||||
title: "Unknown",
|
||||
|
|
|
@ -1,101 +1 @@
|
|||
[
|
||||
{
|
||||
title: "Program A",
|
||||
exercises: [
|
||||
{
|
||||
title: "Squats",
|
||||
weight: 40,
|
||||
unit: "Kg",
|
||||
sets: [
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5
|
||||
]
|
||||
},
|
||||
{
|
||||
title: "Overhead press",
|
||||
weight: 20,
|
||||
unit: "Kg",
|
||||
sets: [
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5
|
||||
]
|
||||
},
|
||||
{
|
||||
title: "Deadlift",
|
||||
weight: 20,
|
||||
unit: "Kg",
|
||||
sets: [
|
||||
5
|
||||
]
|
||||
},
|
||||
{
|
||||
title: "Pullups",
|
||||
weight: 0,
|
||||
unit: "Kg",
|
||||
sets: [
|
||||
10,
|
||||
10,
|
||||
10
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: "Program B",
|
||||
exercises: [
|
||||
{
|
||||
title: "Squats",
|
||||
weight: 40,
|
||||
unit: "Kg",
|
||||
sets: [
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5
|
||||
]
|
||||
},
|
||||
{
|
||||
title: "Bench press",
|
||||
weight: 20,
|
||||
unit: "Kg",
|
||||
sets: [
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5
|
||||
]
|
||||
},
|
||||
{
|
||||
title: "Row",
|
||||
weight: 20,
|
||||
unit:"Kg",
|
||||
sets: [
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
title: "Tricep extension",
|
||||
weight: 20,
|
||||
unit: "Kg",
|
||||
sets: [
|
||||
10,
|
||||
10,
|
||||
10
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
[{"title":"Program A","exercises":[{"title":"Squats","weight":40,"unit":"Kg","sets":[5,5,5,5,5]},{"title":"Overhead press","weight":20,"unit":"Kg","sets":[5,5,5,5,5]},{"title":"Deadlift","weight":20,"unit":"Kg","sets":[5]},{"title":"Pullups","weight":0,"unit":"Kg","sets":[10,10,10]}]},{"title":"Program B","exercises":[{"title":"Squats","weight":40,"unit":"Kg","sets":[5,5,5,5,5]},{"title":"Bench press","weight":20,"unit":"Kg","sets":[5,5,5,5,5]},{"title":"Row","weight":20,"unit":"Kg","sets":[5,5,5,5,5]},{"title":"Tricep extension","weight":20,"unit":"Kg","sets":[10,10,10]}]}]
|
|
@ -0,0 +1,101 @@
|
|||
[
|
||||
{
|
||||
"title": "Program A",
|
||||
"exercises": [
|
||||
{
|
||||
"title": "Squats",
|
||||
"weight": 40,
|
||||
"unit": "Kg",
|
||||
"sets": [
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Overhead press",
|
||||
"weight": 20,
|
||||
"unit": "Kg",
|
||||
"sets": [
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Deadlift",
|
||||
"weight": 20,
|
||||
"unit": "Kg",
|
||||
"sets": [
|
||||
5
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Pullups",
|
||||
"weight": 0,
|
||||
"unit": "Kg",
|
||||
"sets": [
|
||||
10,
|
||||
10,
|
||||
10
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Program B",
|
||||
"exercises": [
|
||||
{
|
||||
"title": "Squats",
|
||||
"weight": 40,
|
||||
"unit": "Kg",
|
||||
"sets": [
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Bench press",
|
||||
"weight": 20,
|
||||
"unit": "Kg",
|
||||
"sets": [
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Row",
|
||||
"weight": 20,
|
||||
"unit":"Kg",
|
||||
"sets": [
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5,
|
||||
5
|
||||
]
|
||||
|
||||
},
|
||||
{
|
||||
"title": "Tricep extension",
|
||||
"weight": 20,
|
||||
"unit": "Kg",
|
||||
"sets": [
|
||||
10,
|
||||
10,
|
||||
10
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -1,4 +1,4 @@
|
|||
class Set {
|
||||
exports = class Set {
|
||||
constructor(maxReps) {
|
||||
this._minReps = 0;
|
||||
this._maxReps = maxReps;
|
||||
|
|
|
@ -1,36 +1,33 @@
|
|||
/* global g, setWatch, clearWatch, reset, BTN1, BTN2, BTN3 */
|
||||
const W = g.getWidth();
|
||||
const H = g.getHeight();
|
||||
const RED = "#d32e29";
|
||||
const PINK = "#f05a56";
|
||||
const WHITE = "#ffffff";
|
||||
|
||||
(() => {
|
||||
const W = g.getWidth();
|
||||
const H = g.getHeight();
|
||||
const RED = "#d32e29";
|
||||
const PINK = "#f05a56";
|
||||
const WHITE = "#ffffff";
|
||||
const Set = require("buffgym-set.js");
|
||||
const Exercise = require("buffgym-exercise.js");
|
||||
const Program = require("buffgym-program.js");
|
||||
|
||||
const Set = require("set.js");
|
||||
const Exercise = require("exercise.js");
|
||||
const Program = require("program.js");
|
||||
|
||||
function centerStringX(str) {
|
||||
function centerStringX(str) {
|
||||
return (W - g.stringWidth(str)) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
function iconIncrement() {
|
||||
function iconIncrement() {
|
||||
const img = require("heatshrink").decompress(atob("ikUxH+AA3XAAgNHCJIVMBYXQ5PC4XJ6AUJCIQQBAAoVCCQwjCAA/JCgglHA4IpJBYwTHA4RMJCY5oDJo4THKIQKET5IMGCaY7TMaKLTWajbTFJIlICgoVBFYXJYQYSGCggAGCRAVIBgw"));
|
||||
return img;
|
||||
}
|
||||
}
|
||||
|
||||
function iconDecrement() {
|
||||
function iconDecrement() {
|
||||
const img = require("heatshrink").decompress(atob("ikUxH+AA3XAAgNHCJIVMBYXQ5PC4XJ6AUJCIQQBAAoVCCQwjCAA/JCgglKFJADBCRYABCYQmOFAhNMKIw6FTw4LHCaY7TMaKLTWajbTFJglFCgoVBFYXJYQYSGCggAGCRAVIBgw="));
|
||||
return img;
|
||||
}
|
||||
}
|
||||
|
||||
function iconOk() {
|
||||
function iconOk() {
|
||||
const img = require("heatshrink").decompress(atob("ikUxH+AA3XAAgNHCJIVMBYXQ5PC4XJ6AUJCIQQBAAoVCCQwjCAA/JCgglKFJADBCJQxCCYQmMIwZoDJpQMCKIg6KBYwTGFQgeHHYouCCRI7EMYTXFRhILEK5SfFRgYSIborbSbpglFCgoVBFYXJYQYSGCggAGCRAVIBgwA=="));
|
||||
return img;
|
||||
}
|
||||
}
|
||||
|
||||
function drawMenu(params) {
|
||||
function drawMenu(params) {
|
||||
const DEFAULT_PARAMS = {
|
||||
showBTN1: false,
|
||||
showBTN2: false,
|
||||
|
@ -40,22 +37,22 @@
|
|||
if (p.showBTN1) g.drawImage(iconIncrement(), W - 30, 10);
|
||||
if (p.showBTN2) g.drawImage(iconOk(), W - 30, 110);
|
||||
if (p.showBTN3) g.drawImage(iconDecrement(), W - 30, 210);
|
||||
}
|
||||
}
|
||||
|
||||
function clearScreen() {
|
||||
function clearScreen() {
|
||||
g.setColor(RED);
|
||||
g.fillRect(0,0,W,H);
|
||||
}
|
||||
}
|
||||
|
||||
function drawTitle(exercise) {
|
||||
function drawTitle(exercise) {
|
||||
const title = exercise.humanTitle;
|
||||
|
||||
g.setFont("Vector",20);
|
||||
g.setColor(WHITE);
|
||||
g.drawString(title, centerStringX(title), 5);
|
||||
}
|
||||
}
|
||||
|
||||
function drawReps(exercise) {
|
||||
function drawReps(exercise) {
|
||||
const set = exercise.currentSet;
|
||||
if (set.isCompleted()) return;
|
||||
|
||||
|
@ -67,24 +64,24 @@
|
|||
g.setFont("Vector", 15);
|
||||
const note = `of ${set.maxReps}`;
|
||||
g.drawString(note, centerStringX(note), (H / 2) + 25);
|
||||
}
|
||||
}
|
||||
|
||||
function drawSets(exercise) {
|
||||
function drawSets(exercise) {
|
||||
const sets = exercise.subTitle;
|
||||
|
||||
g.setColor(WHITE);
|
||||
g.setFont("Vector", 15);
|
||||
g.drawString(sets, centerStringX(sets), H - 25);
|
||||
}
|
||||
}
|
||||
|
||||
function drawSetProgress(exercise) {
|
||||
function drawSetProgress(exercise) {
|
||||
drawTitle(exercise);
|
||||
drawReps(exercise);
|
||||
drawSets(exercise);
|
||||
drawMenu({showBTN1: true, showBTN2: true, showBTN3: true});
|
||||
}
|
||||
}
|
||||
|
||||
function drawStartNextExercise() {
|
||||
function drawStartNextExercise() {
|
||||
const title = "Good work";
|
||||
const msg = "No need to rest\nmove straight on\nto the next exercise";
|
||||
|
||||
|
@ -94,9 +91,9 @@
|
|||
g.setFont("Vector", 15);
|
||||
g.drawString(msg, 30, 150);
|
||||
drawMenu({showBTN1: false, showBTN2: true, showBTN3: false});
|
||||
}
|
||||
}
|
||||
|
||||
function drawProgramCompleted() {
|
||||
function drawProgramCompleted() {
|
||||
const title1 = "You did";
|
||||
const title2 = "GREAT!";
|
||||
const msg = "That's the program\ncompleted. Now eat\nsome food and\nget plenty of rest.";
|
||||
|
@ -112,10 +109,10 @@
|
|||
g.setFont("Vector", 15);
|
||||
g.drawString(msg, 30, 150);
|
||||
drawMenu({showBTN1: false, showBTN2: true, showBTN3: false});
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
function drawExerciseCompleted(program) {
|
||||
/*
|
||||
function drawExerciseCompleted(program) {
|
||||
const exercise = program.currentExercise();
|
||||
const title = exercise.canProgress?
|
||||
"WELL DONE!" :
|
||||
|
@ -138,10 +135,10 @@
|
|||
setWatch(() => {
|
||||
init(program);
|
||||
}, BTN2, {repeat: false});
|
||||
}
|
||||
*/
|
||||
}
|
||||
*/
|
||||
|
||||
function drawRestTimer(program) {
|
||||
function drawRestTimer(program) {
|
||||
const exercise = program.currentExercise();
|
||||
const motivation = "Take a breather..";
|
||||
clearScreen();
|
||||
|
@ -160,9 +157,9 @@
|
|||
exercise.resetRestTimer();
|
||||
redraw(program);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function redraw(program) {
|
||||
function redraw(program) {
|
||||
const exercise = program.currentExercise();
|
||||
|
||||
clearScreen();
|
||||
|
@ -183,17 +180,17 @@
|
|||
}
|
||||
|
||||
drawSetProgress(exercise);
|
||||
}
|
||||
}
|
||||
|
||||
function init(program) {
|
||||
function init(program) {
|
||||
clearWatch();
|
||||
program.next();
|
||||
}
|
||||
}
|
||||
|
||||
// Setup training program. This should come from file
|
||||
// Setup training program. This should come from file
|
||||
|
||||
// Squats
|
||||
function buildPrograms() {
|
||||
// Squats
|
||||
function buildPrograms() {
|
||||
const programsJSON = require("Storage").readJSON("buffgym-programs.json", 1);
|
||||
|
||||
if (!programsJSON) throw "No programs JSON found";
|
||||
|
@ -221,10 +218,9 @@
|
|||
});
|
||||
|
||||
return programs;
|
||||
}
|
||||
}
|
||||
|
||||
// For this spike, just run the first program, what will
|
||||
// really happen is the user picks a program to do from
|
||||
// some menu on a start page.
|
||||
init(buildPrograms()[0]);
|
||||
})();
|
||||
// For this spike, just run the first program, what will
|
||||
// really happen is the user picks a program to do from
|
||||
// some menu on a start page.
|
||||
init(buildPrograms()[0]);
|
Loading…
Reference in New Issue