mirror of https://github.com/espruino/BangleApps
Performance improvements + Show if GPS is on.
parent
f445666f72
commit
dd85859cd3
|
@ -14,6 +14,7 @@ mode, but widgets are still loaded in background.
|
||||||
- If the battery is charged, the icons will change.
|
- If the battery is charged, the icons will change.
|
||||||
- If you have done more than 10k steps, the red hand and icon will turn green.
|
- If you have done more than 10k steps, the red hand and icon will turn green.
|
||||||
- Shows current lock status of your bangle va a colored dot in the middle.
|
- Shows current lock status of your bangle va a colored dot in the middle.
|
||||||
|
- Sows symbol if GPS is on.
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||

|

|
||||||
|
|
|
@ -49,6 +49,12 @@ var stepsImg = {
|
||||||
buffer : E.toArrayBuffer(atob("AcAAAAPwAAAH8AAAB/gAAAf4AAAH/AAAD/wAAAf8AAAH/AfAB/wP4Af8H+AH/B/gB/wf4AP8P+AD+D/gAfg/4AGAP+AAPD/gAPw/4AD+P+AAfj/AAH4/wAB+H8AAPAeAAAAwAAAAPgAAAH8AAAB/AAAAfgAAAH4AAAA8AAAAOAA="))
|
buffer : E.toArrayBuffer(atob("AcAAAAPwAAAH8AAAB/gAAAf4AAAH/AAAD/wAAAf8AAAH/AfAB/wP4Af8H+AH/B/gB/wf4AP8P+AD+D/gAfg/4AGAP+AAPD/gAPw/4AD+P+AAfj/AAH4/wAB+H8AAPAeAAAAwAAAAPgAAAH8AAAB/AAAAfgAAAH4AAAA8AAAAOAA="))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var gpsImg = {
|
||||||
|
width : 32, height : 32, bpp : 1,
|
||||||
|
transparent : 0,
|
||||||
|
buffer : E.toArrayBuffer(atob("AAAMAAAAD4AAAAHAAAAA4AAADjABAA8YAYADmAPAAcwD4DzMB/B8zAf4fAAH/HwAB/74AAf/wAAH/4AAB//AAAP/4AAD//AAA//4AAH//AAA//4AAH//AAA//4ABH/4AAYP4AAHgAAAB/AAAA/4AAAP+AAAD/gAAP//gAD//4AA="))
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Based on the great multi clock from https://github.com/jeffmer/BangleApps/
|
* Based on the great multi clock from https://github.com/jeffmer/BangleApps/
|
||||||
|
@ -117,20 +123,27 @@ function drawBackground() {
|
||||||
|
|
||||||
|
|
||||||
function drawState(){
|
function drawState(){
|
||||||
g.setColor(state.color);
|
|
||||||
g.setFontAlign(1,0,0);
|
g.setFontAlign(1,0,0);
|
||||||
|
|
||||||
// Draw alarm
|
// Draw alarm
|
||||||
var highPrioImg = isAlarmEnabled() ? alarmImg :
|
var highPrioImg = isAlarmEnabled() ? alarmImg :
|
||||||
Bangle.isCharging() ? chargeImg : undefined;
|
Bangle.isCharging() ? chargeImg :
|
||||||
|
Bangle.isGPSOn() ? gpsImg :
|
||||||
|
undefined;
|
||||||
|
|
||||||
|
var imgColor = isAlarmEnabled() ? state.color :
|
||||||
|
Bangle.isCharging() ? g.theme.fg :
|
||||||
|
Bangle.isGPSOn() ? g.theme.fg :
|
||||||
|
state.color;
|
||||||
|
|
||||||
// As default, we draw weather if available, otherwise the steps symbol is shown.
|
// As default, we draw weather if available, otherwise the steps symbol is shown.
|
||||||
if(!highPrioImg && state.has_weather){
|
if(!highPrioImg && state.has_weather){
|
||||||
g.setColor(g.theme.fg);
|
g.setColor(g.theme.fg);
|
||||||
g.drawString(state.temp, cx+cx/2+15, cy+cy/2+10);
|
g.drawString(state.temp, cx+cx/2+15, cy+cy/2+10);
|
||||||
} else {
|
} else {
|
||||||
|
g.setColor(imgColor);
|
||||||
var img = highPrioImg ? highPrioImg : stepsImg;
|
var img = highPrioImg ? highPrioImg : stepsImg;
|
||||||
g.drawImage(img, cx+cx/2 - img.width/2, cy+cy/2 - img.height/2+5);
|
g.drawImage(img, cx+cx/2 - img.width/2 + 5, cy+cy/2 - img.height/2+5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +221,16 @@ function drawLock(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function handleState(){
|
function handleState(fastUpdate){
|
||||||
|
// Set theme color
|
||||||
|
state.color = isAlarmEnabled() ? "#FF6A00" :
|
||||||
|
state.steps > state.maxSteps ? "#00ff00" :
|
||||||
|
"#ff0000";
|
||||||
|
|
||||||
|
if(fastUpdate){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Set battery
|
// Set battery
|
||||||
state.bat = E.getBattery();
|
state.bat = E.getBattery();
|
||||||
|
|
||||||
|
@ -216,11 +238,6 @@ function handleState(){
|
||||||
state.steps = getSteps();
|
state.steps = getSteps();
|
||||||
state.maxSteps = 10000;
|
state.maxSteps = 10000;
|
||||||
|
|
||||||
// Set theme color
|
|
||||||
state.color = isAlarmEnabled() ? "#FF6A00" :
|
|
||||||
state.steps > state.maxSteps ? "#00ff00" :
|
|
||||||
"#ff0000";
|
|
||||||
|
|
||||||
// Set weather
|
// Set weather
|
||||||
state.has_weather = true;
|
state.has_weather = true;
|
||||||
try {
|
try {
|
||||||
|
@ -238,21 +255,29 @@ function handleState(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function draw(){
|
function draw(fastUpdate){
|
||||||
// Execute handlers
|
// Execute handlers
|
||||||
handleState();
|
handleState(fastUpdate);
|
||||||
handleAlarm();
|
handleAlarm();
|
||||||
|
|
||||||
// Clear watch face
|
// Clear watch face
|
||||||
g.reset();
|
if(fastUpdate){
|
||||||
g.clearRect(0, 0, g.getWidth(), g.getHeight());
|
var innerRect = 20;
|
||||||
|
g.clearRect(innerRect, innerRect, g.getWidth()-innerRect, g.getHeight()-innerRect);
|
||||||
|
} else {
|
||||||
|
g.reset();
|
||||||
|
g.clearRect(0, 0, g.getWidth(), g.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
// Draw again
|
// Draw again
|
||||||
g.setColor(1,1,1);
|
g.setColor(1,1,1);
|
||||||
|
|
||||||
drawBackground();
|
if(!fastUpdate){
|
||||||
drawLock();
|
drawBackground();
|
||||||
|
}
|
||||||
|
|
||||||
drawDate();
|
drawDate();
|
||||||
|
drawLock();
|
||||||
drawState();
|
drawState();
|
||||||
drawData();
|
drawData();
|
||||||
drawTime();
|
drawTime();
|
||||||
|
@ -267,7 +292,7 @@ function draw(){
|
||||||
*/
|
*/
|
||||||
Bangle.on('lcdPower',on=>{
|
Bangle.on('lcdPower',on=>{
|
||||||
if (on) {
|
if (on) {
|
||||||
draw();
|
draw(false);
|
||||||
} else { // stop draw timer
|
} else { // stop draw timer
|
||||||
if (drawTimeout) clearTimeout(drawTimeout);
|
if (drawTimeout) clearTimeout(drawTimeout);
|
||||||
drawTimeout = undefined;
|
drawTimeout = undefined;
|
||||||
|
@ -275,7 +300,7 @@ Bangle.on('lcdPower',on=>{
|
||||||
});
|
});
|
||||||
|
|
||||||
Bangle.on('charging',function(charging) {
|
Bangle.on('charging',function(charging) {
|
||||||
draw();
|
draw(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
Bangle.on('lock', function(isLocked) {
|
Bangle.on('lock', function(isLocked) {
|
||||||
|
@ -292,13 +317,13 @@ Bangle.on('touch', function(btn, e){
|
||||||
if(is_upper){
|
if(is_upper){
|
||||||
feedback();
|
feedback();
|
||||||
increaseAlarm();
|
increaseAlarm();
|
||||||
draw();
|
draw(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_lower){
|
if(is_lower){
|
||||||
feedback();
|
feedback();
|
||||||
decreaseAlarm();
|
decreaseAlarm();
|
||||||
draw();
|
draw(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -310,7 +335,7 @@ function queueDraw() {
|
||||||
if (drawTimeout) clearTimeout(drawTimeout);
|
if (drawTimeout) clearTimeout(drawTimeout);
|
||||||
drawTimeout = setTimeout(function() {
|
drawTimeout = setTimeout(function() {
|
||||||
drawTimeout = undefined;
|
drawTimeout = undefined;
|
||||||
draw();
|
draw(false);
|
||||||
}, 60000 - (Date.now() % 60000));
|
}, 60000 - (Date.now() % 60000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +405,7 @@ function decreaseAlarm(){
|
||||||
}
|
}
|
||||||
|
|
||||||
function feedback(){
|
function feedback(){
|
||||||
Bangle.buzz(40, 0.3);
|
Bangle.buzz(40, 0.6);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -398,7 +423,7 @@ for (let wd of WIDGETS) {wd.draw=()=>{};wd.area="";}
|
||||||
|
|
||||||
// Clear the screen once, at startup and draw clock
|
// Clear the screen once, at startup and draw clock
|
||||||
// g.setTheme({bg:"#fff",fg:"#000",dark:false}).clear();
|
// g.setTheme({bg:"#fff",fg:"#000",dark:false}).clear();
|
||||||
draw();
|
draw(false);
|
||||||
|
|
||||||
// After drawing the watch face, we can draw the widgets
|
// After drawing the watch face, we can draw the widgets
|
||||||
// Bangle.drawWidgets();
|
// Bangle.drawWidgets();
|
||||||
|
|
Loading…
Reference in New Issue