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",
|
{ "id": "marioclock",
|
||||||
"name": "Mario Clock",
|
"name": "Mario Clock",
|
||||||
"icon": "marioclock.png",
|
"icon": "marioclock.png",
|
||||||
"version":"0.11",
|
"version":"0.12",
|
||||||
"description": "Animated retro Mario clock, with Gameboy style 8-bit grey-scale graphics.",
|
"description": "Animated retro Mario clock, with Gameboy style 8-bit grey-scale graphics.",
|
||||||
"tags": "clock,mario,retro",
|
"tags": "clock,mario,retro",
|
||||||
"type": "clock",
|
"type": "clock",
|
||||||
|
|
|
@ -9,3 +9,4 @@
|
||||||
0.09: Add GadgetBridge functionality. Mario shows message type in speach bubble, while message scrolls in info panel
|
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.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) {
|
function drawNotice(x, y) {
|
||||||
if (phone.message === null) return;
|
if (phone.message === null) return;
|
||||||
|
|
||||||
|
let img;
|
||||||
switch (phone.messageType) {
|
switch (phone.messageType) {
|
||||||
case "call":
|
case "call":
|
||||||
const callImg = require("heatshrink").decompress(atob("h8PxH+AAMHABIND6wAJB4INEw9cAAIPFBxAPEBw/WBxYACDrQ7QLI53OSpApDBoQAHB4INLByANNAwo="));
|
img = require("heatshrink").decompress(atob("h8PxH+AAMHABIND6wAJB4INEw9cAAIPFBxAPEBw/WBxYACDrQ7QLI53OSpApDBoQAHB4INLByANNAwo="));
|
||||||
g.drawImage(callImg, characterSprite.x, characterSprite.y - 16);
|
|
||||||
break;
|
break;
|
||||||
case "notify":
|
case "notify":
|
||||||
const msgImg = require("heatshrink").decompress(atob("h8PxH+AAMHABIND6wAJB4INCrgAHB4QOEDQgOIAIQFGBwovDA4gOGFooOVLJR3OSpApDBoQAHB4INLByANNAwoA="));
|
img = require("heatshrink").decompress(atob("h8PxH+AAMHABIND6wAJB4INCrgAHB4QOEDQgOIAIQFGBwovDA4gOGFooOVLJR3OSpApDBoQAHB4INLByANNAwoA="));
|
||||||
g.drawImage(msgImg, characterSprite.x, characterSprite.y - 16);
|
break;
|
||||||
|
case "lowBatt":
|
||||||
|
img = require("heatshrink").decompress(atob("h8PxH+AAMHABIND6wAJB4INFrgABB4oOEBoQPFBwwDGB0uHAAIOLJRB3OSpApDBoQAHB4INLByANNAwo"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g.drawImage(img, characterSprite.x, characterSprite.y - 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawCharacter(date, character) {
|
function drawCharacter(date, character) {
|
||||||
|
@ -598,6 +602,14 @@ function updateSettings() {
|
||||||
writeSettings(newSettings);
|
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
|
// Main
|
||||||
function init() {
|
function init() {
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
@ -658,17 +670,25 @@ function init() {
|
||||||
// Phone connectivity
|
// Phone connectivity
|
||||||
try { NRF.wake(); } catch (e) {}
|
try { NRF.wake(); } catch (e) {}
|
||||||
|
|
||||||
NRF.on('disconnect', () => Bangle.buzz());
|
NRF.on('disconnect', () => {
|
||||||
|
Bangle.buzz();
|
||||||
|
phoneNewMessage(null, "Phone disconnected");
|
||||||
|
});
|
||||||
|
|
||||||
NRF.on('connect', () => {
|
NRF.on('connect', () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
phoneOutbound({ t: "status", bat: E.getBattery() });
|
phoneOutbound({ t: "status", bat: E.getBattery() });
|
||||||
}, ONE_SECOND * 2);
|
}, ONE_SECOND * 2);
|
||||||
Bangle.buzz();
|
Bangle.buzz();
|
||||||
|
phoneNewMessage(null, "Phone connected");
|
||||||
});
|
});
|
||||||
|
|
||||||
GB = (evt) => phoneInbound(evt);
|
GB = (evt) => phoneInbound(evt);
|
||||||
|
|
||||||
startTimers();
|
startTimers();
|
||||||
|
|
||||||
|
setInterval(checkBatteryLevel, ONE_SECOND * 60 * 10);
|
||||||
|
checkBatteryLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialise!
|
// Initialise!
|
||||||
|
|
Loading…
Reference in New Issue