Optimized when lcd off, back lcd on screen

pull/774/head
peeweek 2021-07-22 15:46:39 +02:00
parent 54b961d7d6
commit 09ee8a5cf9
1 changed files with 15 additions and 7 deletions

View File

@ -81,8 +81,14 @@ let mins = -1;
let hour = -1; let hour = -1;
let day = -1; let day = -1;
function refresh() function redraw() {
{ mins = -1;
hour = -1;
day = -1;
refresh();
}
function refresh() {
g.setColor(bg,bg,bg); g.setColor(bg,bg,bg);
g.fillRect(0,45,240,210); g.fillRect(0,45,240,210);
Bangle.drawWidgets(); Bangle.drawWidgets();
@ -127,6 +133,9 @@ function updateTime()
function drawDigits(x, value) function drawDigits(x, value)
{ {
if(!Bangle.isLCDOn()) // No need to draw when LCD Off
return;
drawChar(Math.floor(value/10), 15, x, 115, x+50); drawChar(Math.floor(value/10), 15, x, 115, x+50);
if(value%10 == 1) if(value%10 == 1)
drawChar(value%10, 55, x, 155, x+50); drawChar(value%10, 55, x, 155, x+50);
@ -177,10 +186,7 @@ function flipColors()
let t = bg; let t = bg;
bg = fg; bg = fg;
fg = t; fg = t;
mins = -1; redraw();
hour = -1;
day = -1;
refresh();
} }
////////////////////////////////////////// //////////////////////////////////////////
@ -191,7 +197,7 @@ function flipColors()
// Initialize // Initialize
g.clear(); g.clear();
Bangle.loadWidgets(); Bangle.loadWidgets();
refresh(); redraw();
// Define Refresh Interval // Define Refresh Interval
setInterval(updateTime, interval); setInterval(updateTime, interval);
@ -200,3 +206,5 @@ setInterval(updateTime, interval);
setWatch(flipColors, BTN1, true); setWatch(flipColors, BTN1, true);
setWatch(Bangle.showLauncher, BTN2, false); setWatch(Bangle.showLauncher, BTN2, false);
// Handle redraw on LCD on
Bangle.on('lcdPower', (on) => { if(on) redraw(); });