mirror of https://github.com/espruino/BangleApps
Merge remote-tracking branch 'upstream/master'
commit
bbd922a1cd
14
apps.json
14
apps.json
|
@ -2021,7 +2021,7 @@
|
||||||
"name": "Vertical watch face",
|
"name": "Vertical watch face",
|
||||||
"shortName":"Vertical Face",
|
"shortName":"Vertical Face",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"version":"0.07",
|
"version":"0.08",
|
||||||
"description": "A simple vertical watch face with the date. Heart rate monitor is toggled with BTN1",
|
"description": "A simple vertical watch face with the date. Heart rate monitor is toggled with BTN1",
|
||||||
"tags": "clock",
|
"tags": "clock",
|
||||||
"type":"clock",
|
"type":"clock",
|
||||||
|
@ -2661,5 +2661,17 @@
|
||||||
{"name":"mclockplus.app.js","url":"mclockplus.app.js"},
|
{"name":"mclockplus.app.js","url":"mclockplus.app.js"},
|
||||||
{"name":"mclockplus.img","url":"mclockplus-icon.js","evaluate":true}
|
{"name":"mclockplus.img","url":"mclockplus-icon.js","evaluate":true}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{ "id": "intervals",
|
||||||
|
"name": "Intervals App",
|
||||||
|
"shortName":"Intervals",
|
||||||
|
"icon": "intervals.png",
|
||||||
|
"version":"0.01",
|
||||||
|
"description": "Intervals for training. It is possible to configure work time and rest time and number of sets.",
|
||||||
|
"tags": "",
|
||||||
|
"storage": [
|
||||||
|
{"name":"intervals.app.js","url":"intervals.app.js"},
|
||||||
|
{"name":"intervals.img","url":"intervals-icon.js","evaluate":true}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Intervals app
|
||||||
|
Just my first app to test this amazing smartwatch.
|
||||||
|
|
||||||
|
The idea is to create a simple app which allows to define a workout, being able to configure the work time, rest time and number of sets. Try it out, it is quite simple.
|
||||||
|
|
||||||
|
This is obviously version 0.01 but it should work.
|
|
@ -0,0 +1 @@
|
||||||
|
require("heatshrink").decompress(atob("mEwwg96xAWVhGIwAuWGCoXrCIZfFDZkJyAKTAAOZBaojEzIADGBoOChITEAgIUCGBAhCCwIlFA4YwIhIjCDQYtDAoIMBQhgUCzJMDR5xYGFwSPMHwYRED4KPMCQcIxKtHWApoCEYczmYXCPgYAEGgZGCAgMDC4pEGA4gVBGwIWCF6GqhWgC4kqBYYAGGgegC4QWCC4kKI4oQBC4guEC4wJDC4gtBGoIXDmWqBoQMBBQUwIAQXJKopSDJooXGmQRBBwYLBFgR2EC4QAEC4RIDToRQDC56pESYhHDAAYFBA4YvMD4oOEL5bMGaJIQFC5ZiEAoxRCC5I1KJoIXVBYJ4FEYgAGPAwwHSYIAGJAwwHEA5+HB5AvMZI4XKBwu72ELAQIHCAoQCBchQMCAQIADDgIfEDBYRBAAI5DCxYUDAxYYMAAgWPDIoVSAFAA=="))
|
|
@ -0,0 +1,167 @@
|
||||||
|
var counter;
|
||||||
|
var counterInterval;
|
||||||
|
|
||||||
|
var settings;
|
||||||
|
|
||||||
|
var work=false; //true if training false if resting
|
||||||
|
var prep=true; //true if we are in prep phase (at the beginning of the session
|
||||||
|
var setNum;
|
||||||
|
|
||||||
|
var paused;
|
||||||
|
|
||||||
|
function endPart() {
|
||||||
|
g.clear();
|
||||||
|
if (prep){
|
||||||
|
prep=false;
|
||||||
|
work = true;
|
||||||
|
counter = settings.workseg+settings.workmin*60;
|
||||||
|
startCounter();
|
||||||
|
}else if (work){
|
||||||
|
work = false;
|
||||||
|
counter = settings.restseg+settings.restmin*60;
|
||||||
|
startCounter();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if (setNum>1)
|
||||||
|
{
|
||||||
|
setNum--;
|
||||||
|
work = true;
|
||||||
|
counter = settings.workseg+settings.workmin*60;
|
||||||
|
startCounter();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//End session
|
||||||
|
setWatch(showMenu, BTN2);
|
||||||
|
E.showMessage("Press BTN2 for\ngoing back\nto the menu","Well done!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function printCounter(counter){
|
||||||
|
g.setFontAlign(0,0); // center font
|
||||||
|
g.setFont("Vector",80); // vector font, 80px
|
||||||
|
// draw the current counter value
|
||||||
|
let minutes = Math.floor(counter/60);
|
||||||
|
let segs = counter % 60;
|
||||||
|
let textMinutes = minutes.toString().padStart(2, "0");
|
||||||
|
let textSegs = segs.toString().padStart(2,"0");
|
||||||
|
g.clearRect(0,80,239,160);
|
||||||
|
g.setFont("Vector",30);
|
||||||
|
if (prep)
|
||||||
|
g.setColor(125,125,0);
|
||||||
|
else if (work)
|
||||||
|
g.setColor(255,0,0);
|
||||||
|
else
|
||||||
|
g.setColor(0,255,0);
|
||||||
|
g.drawString(setNum,120,50);
|
||||||
|
if (prep)
|
||||||
|
g.drawString("PREPARATION",120,190);
|
||||||
|
else if (work)
|
||||||
|
g.drawString("WORK",120,190);
|
||||||
|
else
|
||||||
|
g.drawString("REST",120,190);
|
||||||
|
g.setFont("Vector",10);
|
||||||
|
g.drawString("Touch to pause",120,215);
|
||||||
|
g.setFont("Vector",80);
|
||||||
|
g.drawString(textMinutes+":"+textSegs,120,120);
|
||||||
|
}
|
||||||
|
|
||||||
|
function signal_to_user(le){
|
||||||
|
if (settings.buzz)
|
||||||
|
Bangle.buzz(le);
|
||||||
|
else
|
||||||
|
Bangle.beep(le,4000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function countDown() {
|
||||||
|
counter--;
|
||||||
|
if (counter<4 && counter>0)
|
||||||
|
signal_to_user(200);
|
||||||
|
if (counter==0)
|
||||||
|
signal_to_user(600);
|
||||||
|
|
||||||
|
if (counter<0) {
|
||||||
|
clearInterval(counterInterval);
|
||||||
|
counterInterval = undefined;
|
||||||
|
endPart();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printCounter(counter);
|
||||||
|
}
|
||||||
|
g.flip();
|
||||||
|
}
|
||||||
|
|
||||||
|
function startCounter(){
|
||||||
|
if (!counterInterval)
|
||||||
|
counterInterval = setInterval(countDown, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function pause()
|
||||||
|
{
|
||||||
|
if (!paused)
|
||||||
|
{
|
||||||
|
clearInterval(counterInterval);
|
||||||
|
counterInterval = undefined;
|
||||||
|
setWatch(resume,BTN4);
|
||||||
|
setWatch(resume,BTN5);
|
||||||
|
paused=true;
|
||||||
|
g.clear();
|
||||||
|
g.setFont("Vector",60);
|
||||||
|
g.drawString("PAUSED",120,120);
|
||||||
|
g.setFont("Vector",20);
|
||||||
|
g.drawString("Touch to continue",120,180);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resume(){
|
||||||
|
if (paused)
|
||||||
|
{
|
||||||
|
g.clear();
|
||||||
|
counterInterval = setInterval(countDown, 1000);
|
||||||
|
setWatch(pause,BTN4);
|
||||||
|
setWatch(pause,BTN5);
|
||||||
|
paused=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function startSession() {
|
||||||
|
E.showMenu();
|
||||||
|
paused=false;
|
||||||
|
setWatch(pause,BTN4);
|
||||||
|
setWatch(pause,BTN5);
|
||||||
|
require('Storage').write('intervals.settings.json',settings);
|
||||||
|
setNum = settings.sets;
|
||||||
|
counter = 5;//prep time
|
||||||
|
prep=true;
|
||||||
|
work=false;
|
||||||
|
startCounter();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showMenu()
|
||||||
|
{
|
||||||
|
settings = require('Storage').readJSON('intervals.settings.json',1)||
|
||||||
|
{ sets:1,workseg:10,workmin:0,restseg:5,restmin:0,buzz:true};
|
||||||
|
|
||||||
|
var mainmenu = {
|
||||||
|
"" : { "title" : "-- Main Menu --" },
|
||||||
|
"START" : function() { startSession(); },
|
||||||
|
"Sets" : { value : settings.sets,min:0,max:20,step:1,onchange : v => { settings.sets=v; } },
|
||||||
|
"Work minutes" : { value : settings.workmin,min:0,max:59,step:1,onchange : v => { settings.workmin=v; } },
|
||||||
|
"Work seconds" : { value : settings.workseg,min:0,max:59,step:5,onchange : v => { settings.workseg=v; } },
|
||||||
|
"Rest minutes" : { value : settings.restmin,min:0,max:59,step:1,onchange : v => { settings.restmin=v; } },
|
||||||
|
"Rest seconds" : { value : settings.restseg,min:0,max:59,step:5,onchange : v => { settings.restseg=v; } },
|
||||||
|
"Signal type" : { value : settings.buzz,format : v => v?"Buzz":"Beep",onchange : v => { settings.buzz=v; }}
|
||||||
|
};
|
||||||
|
|
||||||
|
E.showMenu(mainmenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
showMenu();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
2
core
2
core
|
@ -1 +1 @@
|
||||||
Subproject commit f9020126eebd81abef204c6771914ff2c31160a1
|
Subproject commit 1b1293a5eb9b8bb9e4f743c4599f0587f597d368
|
|
@ -32,3 +32,6 @@
|
||||||
top: 36px;
|
top: 36px;
|
||||||
left: -24px;
|
left: -24px;
|
||||||
}
|
}
|
||||||
|
.btn-favourite {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue