Merge branch 'master' of github.com:espruino/BangleApps
commit
30d49662ae
|
|
@ -2962,7 +2962,7 @@
|
|||
{ "id": "stepo",
|
||||
"name": "Stepometer Clock",
|
||||
"icon": "stepo.png",
|
||||
"version":"0.01",
|
||||
"version":"0.02",
|
||||
"description": "A large font watch, displays step count in a doughnut guage and warns of low battery",
|
||||
"tags": "clock",
|
||||
"type":"clock",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
0.01: First version
|
||||
0.02: Speeded up draw, start stop timer, long press BTN2 to switch to the launcher
|
||||
|
|
@ -10,6 +10,7 @@ A large font watch, displays step count in a doughnut guage and warns of low bat
|
|||
- The guage show percentage of steps out of a goal of 10000 steps
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
- When the battery is less than 25% the doughnut turns red
|
||||
|
|
@ -17,8 +18,14 @@ A large font watch, displays step count in a doughnut guage and warns of low bat
|
|||

|
||||
|
||||
|
||||
# Notes
|
||||
## BTN2 Long press to start the launcher
|
||||
|
||||
BTN2 is confiured to respond to a 1.5 second press in order to switch
|
||||
to the launcher App. Simply press and hold until you hear a buzz and
|
||||
release. This avoids accidently switching out of the watch app when
|
||||
clothing catches it.
|
||||
|
||||
## Notes
|
||||
|
||||
* Uses an arrayBuffer to prepare the doughnut guage. The arrayBuffer
|
||||
is 160*160 and is larger than required. The reason for this is that
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
var pal4color = new Uint16Array([0x0000,0xFFFF,0x7BEF,0xAFE5],0,2); // b,w,grey,greenyellow
|
||||
var pal4red = new Uint16Array([0x0000,0xFFFF,0xF800,0xAFE5],0,2); // b,w,red,greenyellow
|
||||
var buf = Graphics.createArrayBuffer(160,160,2,{msb:true});
|
||||
var intervalRefSec;
|
||||
|
||||
function flip(x,y) {
|
||||
g.drawImage({width:160,height:160,bpp:2,buffer:buf.buffer, palette:pal4color}, x, y);
|
||||
|
|
@ -33,7 +34,7 @@ function drawSteps() {
|
|||
buf.setColor(3); // green-yellow
|
||||
|
||||
// draw guauge
|
||||
for (i = startrot; i > midrot; i--) {
|
||||
for (i = startrot; i > midrot; i -= 4) {
|
||||
x = cx + r * Math.sin(radians(i));
|
||||
y = cy + r * Math.cos(radians(i));
|
||||
buf.fillCircle(x,y,4);
|
||||
|
|
@ -42,7 +43,7 @@ function drawSteps() {
|
|||
buf.setColor(2); // grey
|
||||
|
||||
// draw remainder of guage in grey
|
||||
for (i = midrot; i > endrot; i--) {
|
||||
for (i = midrot; i > endrot; i -= 4) {
|
||||
x = cx + r * Math.sin(radians(i));
|
||||
y = cy + r * Math.cos(radians(i));
|
||||
buf.fillCircle(x,y,4);
|
||||
|
|
@ -80,6 +81,15 @@ function getSteps() {
|
|||
return stepsWidget().getSteps();
|
||||
return "-";
|
||||
}
|
||||
|
||||
function startTimer() {
|
||||
draw();
|
||||
intervalRefSec = setInterval(draw, 15000);
|
||||
}
|
||||
|
||||
function stopTimer() {
|
||||
if(intervalRefSec) { intervalRefSec = clearInterval(intervalRefSec); }
|
||||
}
|
||||
|
||||
function stepsWidget() {
|
||||
if (WIDGETS.activepedom !== undefined) {
|
||||
|
|
@ -92,13 +102,46 @@ function stepsWidget() {
|
|||
|
||||
// handle switch display on by pressing BTN1
|
||||
Bangle.on('lcdPower', function(on) {
|
||||
if (on) draw();
|
||||
if (on)
|
||||
startTimer();
|
||||
else
|
||||
stopTimer();
|
||||
});
|
||||
|
||||
let firstPress = 0;
|
||||
var pressTimer;
|
||||
|
||||
// start a timer and buzz whenn held long enough
|
||||
function firstPressed() {
|
||||
firstPress = getTime();
|
||||
pressTimer = setInterval(longPressCheck, 1500);
|
||||
}
|
||||
|
||||
// if you release too soon there is no buzz as timer is cleared
|
||||
function thenReleased() {
|
||||
var dur = getTime() - firstPress;
|
||||
if (pressTimer) {
|
||||
clearInterval(pressTimer);
|
||||
pressTimer = undefined;
|
||||
}
|
||||
if ( dur >= 1.5 ) Bangle.showLauncher();
|
||||
}
|
||||
|
||||
// when you feel the buzzer you know you have done a long press
|
||||
function longPressCheck() {
|
||||
Bangle.buzz();
|
||||
if (pressTimer) {
|
||||
clearInterval(pressTimer);
|
||||
pressTimer = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// make BTN require a long press (1.5 seconds) to switch to launcher
|
||||
setWatch(firstPressed, BTN2,{repeat:true,edge:"rising"});
|
||||
setWatch(thenReleased, BTN2,{repeat:true,edge:"falling"});
|
||||
|
||||
g.reset();
|
||||
g.clear();
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
setInterval(draw, 15000); // refresh every 15s
|
||||
draw();
|
||||
setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"});
|
||||
startTimer();
|
||||
|
|
|
|||
Loading…
Reference in New Issue