Use LCDOverlay for notificiation on Bangle.js 2
parent
6358325ec4
commit
dd8040af5d
|
|
@ -104,12 +104,26 @@ function handleStepGoalNotification() {
|
||||||
const now = new Date(Date.now()).toISOString().split('T')[0]; // yyyy-mm-dd
|
const now = new Date(Date.now()).toISOString().split('T')[0]; // yyyy-mm-dd
|
||||||
if (!settings.stepGoalNotificationDate || settings.stepGoalNotificationDate < now) { // notification not yet shown today?
|
if (!settings.stepGoalNotificationDate || settings.stepGoalNotificationDate < now) { // notification not yet shown today?
|
||||||
Bangle.buzz(200, 0.5);
|
Bangle.buzz(200, 0.5);
|
||||||
E.showPrompt(/*LANG*/"You reached your daily goal of " + settings.stepGoal + " steps!", {
|
if (process.env.BOARD == "BANGLEJS2") {
|
||||||
title: /*LANG*/"Step goal reached!",
|
var medal = atob("MDCBAAAAAAAAAAAAAAAAAAA/+D/4AAB//H/8AAB//H/8AAB//v/4AAA8H/B4AAA+H/D4AAAeD+DwAAAfD+HwAAAPB8HgAAAPh8PgAAAHg8PAAAAHw8PAAAADw+eAAAAD4eeAAAAB4f+AAAAB8P8AAAAA//8AAAAA//4AAAAA//8AAAAB//+AAAAD+B/AAAAH4AfgAAAPgAHwAAAPAADwAAAfAAD4AAAeAAB4AAA+AAB8AAA8AAA8AAA8AAA8AAA8AAA8AAA8AAA8AAA8AAA8AAA8AAA8AAA+AAB4AAAeAAB4AAAfAAD4AAAPAADwAAAPgAHwAAAH4AfgAAAD+B/AAAAB//+AAAAA//8AAAAAP/wAAAAAD+AAAAAAAAAAAAAAAAAAAA==");
|
||||||
buttons: { "Ok": 1}
|
var ovr = Graphics.createArrayBuffer(g.getWidth(),g.getHeight(),1,{msb:true});
|
||||||
}).then(function (v) {
|
ovr.drawImage(medal, 10, 10);
|
||||||
load();
|
ovr.setFont("Vector:18").setFontAlign(0, 0, 0);
|
||||||
});
|
ovr.drawString(/*LANG*/settings.stepGoal + " steps", g.getWidth() / 2 + 24 , 10 + 24);
|
||||||
|
ovr.drawString(/*LANG*/"Step goal reached!", g.getWidth() / 2, g.getHeight() / 2);
|
||||||
|
Bangle.setLCDOverlay(ovr,0,0);
|
||||||
|
setWatch(function() {
|
||||||
|
Bangle.setLCDOverlay();
|
||||||
|
}, BTN);
|
||||||
|
} else {
|
||||||
|
E.showPrompt(/*LANG*/"You reached your daily goal of " + settings.stepGoal + " steps!", {
|
||||||
|
title: /*LANG*/"Step goal reached!",
|
||||||
|
buttons: { "Ok": 1}
|
||||||
|
}).then(function (v) {
|
||||||
|
load();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
settings.stepGoalNotificationDate = now;
|
settings.stepGoalNotificationDate = now;
|
||||||
require("Storage").writeJSON("health.json", settings);
|
require("Storage").writeJSON("health.json", settings);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue