Use LCDOverlay for notificiation on Bangle.js 2

master
Marco H 2023-01-04 10:24:12 +01:00
parent 6358325ec4
commit dd8040af5d
1 changed files with 20 additions and 6 deletions

View File

@ -104,12 +104,26 @@ function handleStepGoalNotification() {
const now = new Date(Date.now()).toISOString().split('T')[0]; // yyyy-mm-dd
if (!settings.stepGoalNotificationDate || settings.stepGoalNotificationDate < now) { // notification not yet shown today?
Bangle.buzz(200, 0.5);
E.showPrompt(/*LANG*/"You reached your daily goal of " + settings.stepGoal + " steps!", {
title: /*LANG*/"Step goal reached!",
buttons: { "Ok": 1}
}).then(function (v) {
load();
});
if (process.env.BOARD == "BANGLEJS2") {
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==");
var ovr = Graphics.createArrayBuffer(g.getWidth(),g.getHeight(),1,{msb:true});
ovr.drawImage(medal, 10, 10);
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;
require("Storage").writeJSON("health.json", settings);
}