forked from FOSS/BangleApps
Display info message when phone (dis)connectes and battery level <= 10%
parent
cab228f47e
commit
1c68ea0d1b
|
@ -914,7 +914,7 @@
|
|||
{ "id": "marioclock",
|
||||
"name": "Mario Clock",
|
||||
"icon": "marioclock.png",
|
||||
"version":"0.11",
|
||||
"version":"0.12",
|
||||
"description": "Animated retro Mario clock, with Gameboy style 8-bit grey-scale graphics.",
|
||||
"tags": "clock,mario,retro",
|
||||
"type": "clock",
|
||||
|
|
|
@ -8,4 +8,5 @@
|
|||
0.08: Update date panel to be info panel toggling between Date, Battery and Temperature. Add Princes Daisy
|
||||
0.09: Add GadgetBridge functionality. Mario shows message type in speach bubble, while message scrolls in info panel
|
||||
0.10: Swiping left to enable night-mode now also reduces LCD brightness through 3 levels before returning to day-mode.
|
||||
0.11: User settings persisted and read to file.
|
||||
0.11: User settings persisted and read to file.
|
||||
0.12: Add info banner message when phone (dis)connects. Display low-battery warning (<=10%)
|
|
@ -346,16 +346,20 @@ function drawToadFrame(idx, x, y) {
|
|||
function drawNotice(x, y) {
|
||||
if (phone.message === null) return;
|
||||
|
||||
let img;
|
||||
switch (phone.messageType) {
|
||||
case "call":
|
||||
const callImg = require("heatshrink").decompress(atob("h8PxH+AAMHABIND6wAJB4INEw9cAAIPFBxAPEBw/WBxYACDrQ7QLI53OSpApDBoQAHB4INLByANNAwo="));
|
||||
g.drawImage(callImg, characterSprite.x, characterSprite.y - 16);
|
||||
img = require("heatshrink").decompress(atob("h8PxH+AAMHABIND6wAJB4INEw9cAAIPFBxAPEBw/WBxYACDrQ7QLI53OSpApDBoQAHB4INLByANNAwo="));
|
||||
break;
|
||||
case "notify":
|
||||
const msgImg = require("heatshrink").decompress(atob("h8PxH+AAMHABIND6wAJB4INCrgAHB4QOEDQgOIAIQFGBwovDA4gOGFooOVLJR3OSpApDBoQAHB4INLByANNAwoA="));
|
||||
g.drawImage(msgImg, characterSprite.x, characterSprite.y - 16);
|
||||
img = require("heatshrink").decompress(atob("h8PxH+AAMHABIND6wAJB4INCrgAHB4QOEDQgOIAIQFGBwovDA4gOGFooOVLJR3OSpApDBoQAHB4INLByANNAwoA="));
|
||||
break;
|
||||
case "lowBatt":
|
||||
img = require("heatshrink").decompress(atob("h8PxH+AAMHABIND6wAJB4INFrgABB4oOEBoQPFBwwDGB0uHAAIOLJRB3OSpApDBoQAHB4INLByANNAwo"));
|
||||
break;
|
||||
}
|
||||
|
||||
g.drawImage(img, characterSprite.x, characterSprite.y - 16);
|
||||
}
|
||||
|
||||
function drawCharacter(date, character) {
|
||||
|
@ -598,6 +602,14 @@ function updateSettings() {
|
|||
writeSettings(newSettings);
|
||||
}
|
||||
|
||||
function checkBatteryLevel() {
|
||||
if (Bangle.isCharging()) return;
|
||||
if (E.getBattery() > 10) return;
|
||||
if (phone.message !== null) return;
|
||||
|
||||
phoneNewMessage("lowBatt", "Warning, battery is low");
|
||||
}
|
||||
|
||||
// Main
|
||||
function init() {
|
||||
loadSettings();
|
||||
|
@ -658,17 +670,25 @@ function init() {
|
|||
// Phone connectivity
|
||||
try { NRF.wake(); } catch (e) {}
|
||||
|
||||
NRF.on('disconnect', () => Bangle.buzz());
|
||||
NRF.on('disconnect', () => {
|
||||
Bangle.buzz();
|
||||
phoneNewMessage(null, "Phone disconnected");
|
||||
});
|
||||
|
||||
NRF.on('connect', () => {
|
||||
setTimeout(() => {
|
||||
phoneOutbound({ t: "status", bat: E.getBattery() });
|
||||
}, ONE_SECOND * 2);
|
||||
Bangle.buzz();
|
||||
phoneNewMessage(null, "Phone connected");
|
||||
});
|
||||
|
||||
GB = (evt) => phoneInbound(evt);
|
||||
|
||||
startTimers();
|
||||
|
||||
setInterval(checkBatteryLevel, ONE_SECOND * 60 * 10);
|
||||
checkBatteryLevel();
|
||||
}
|
||||
|
||||
// Initialise!
|
||||
|
|
Loading…
Reference in New Issue