Merge pull request #2899 from halemmerich/messagesoverlay

Messagesoverlay - Fix low memory handling when overlay already visible
master
Gordon Williams 2023-07-24 09:10:04 +01:00 committed by GitHub
commit 577d551432
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 12 deletions

View File

@ -3,3 +3,5 @@
0.03: Scroll six lines per swipe, leaving the previous top/bottom row visible.
0.04: Use the event mechanism for getting messages
0.05: Fix the overlay keeping the LCD on
0.06: Better low memory handling
Fix first message beeing displayed again on unlock

View File

@ -1,3 +1,5 @@
const MIN_FREE_MEM = 1000;
const LOW_MEM = 2000;
const ovrx = 10;
const ovry = 10;
const ovrw = g.getWidth()-2*ovrx;
@ -28,6 +30,7 @@ let callInProgress = false;
let show = function(ovr){
let img = ovr;
LOG("show", img.getBPP());
if (ovr.getBPP() == 1) {
img = ovr.asImage();
img.palette = new Uint16Array([_g.theme.fg,_g.theme.bg]);
@ -162,8 +165,9 @@ let showMessage = function(ovr, msg) {
drawMessage(ovr, msg);
};
let drawBorder = function(ovr) {
let drawBorder = function(img) {
LOG("drawBorder", isQuiet());
if (img) ovr=img;
if (Bangle.isLocked())
ovr.setColor(ovr.theme.fgH);
else
@ -232,13 +236,6 @@ let next = function(ovr) {
showMessage(ovr, eventQueue[0]);
};
let showMapMessage = function(ovr, msg) {
ovr.clearRect(2,2,ovr.getWidth()-3,ovr.getHeight()-3);
drawMessage(ovr, {
body: "Not implemented!"
});
};
let callBuzzTimer = null;
let stopCallBuzz = function() {
if (callBuzzTimer) {
@ -407,7 +404,7 @@ let main = function(ovr, event) {
if (!lockListener) {
lockListener = function (){
drawBorder(ovr);
drawBorder();
};
Bangle.on('lock', lockListener);
}
@ -439,9 +436,15 @@ exports.message = function(type, event) {
if(event.handled) return;
bpp = 4;
if (process.memory().free < 2000) bpp = 1;
if (process.memory().free < LOW_MEM)
bpp = 1;
if (!ovr) {
while (process.memory().free < MIN_FREE_MEM && eventQueue.length > 0){
let dropped = eventQueue.pop();
print("Dropped message because of memory constraints", dropped);
}
if (!ovr || ovr.getBPP() != bpp) {
ovr = Graphics.createArrayBuffer(ovrw, ovrh, bpp, {
msb: true
});

View File

@ -1,7 +1,7 @@
{
"id": "messagesoverlay",
"name": "Messages Overlay",
"version": "0.05",
"version": "0.06",
"description": "An overlay based implementation of a messages UI (display notifications from iOS and Gadgetbridge/Android)",
"icon": "app.png",
"type": "bootloader",