Merge pull request #2145 from deirdreobyrne/bigdclock_v0.06

Bigdclock v0.07
master
Gordon Williams 2022-09-26 16:26:07 +01:00 committed by GitHub
commit 4a08dcbaea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 12 deletions

View File

@ -4,3 +4,4 @@
0.04: bug fix 0.04: bug fix
0.05: proper fix for the race condition in queueDraw() 0.05: proper fix for the race condition in queueDraw()
0.06: Tell clock widgets to hide. 0.06: Tell clock widgets to hide.
0.07: Better battery graphic - now has green, yellow and red sections; battery status reflected in the bar across the middle of the screen; current battery state checked only once every 15 minutes, leading to longer-lasting battery charge

View File

@ -11,6 +11,8 @@ Graphics.prototype.setFontOpenSans = function(scale) {
}; };
var drawTimeout; var drawTimeout;
var lastBattCheck = 0;
var width = 0;
function queueDraw(millis_now) { function queueDraw(millis_now) {
if (drawTimeout) clearTimeout(drawTimeout); if (drawTimeout) clearTimeout(drawTimeout);
@ -24,12 +26,15 @@ function draw() {
var date = new Date(); var date = new Date();
var h = date.getHours(), var h = date.getHours(),
m = date.getMinutes(); m = date.getMinutes();
var d = date.getDate(), var d = date.getDate();
w = date.getDay(); // d=1..31; w=0..6
const level = E.getBattery();
const width = level + (level/2);
var is12Hour = (require("Storage").readJSON("setting.json", 1) || {})["12hour"]; var is12Hour = (require("Storage").readJSON("setting.json", 1) || {})["12hour"];
var dows = require("date_utils").dows(0,1); var dow = require("date_utils").dows(0,1)[date.getDay()];
if ((date.getTime() >= lastBattCheck + 15*60000) || Bangle.isCharging()) {
lastBattcheck = date.getTime();
width = E.getBattery();
width += width/2;
}
g.reset(); g.reset();
g.clear(); g.clear();
@ -47,24 +52,35 @@ function draw() {
g.drawString(d, g.getWidth() -6, 98); g.drawString(d, g.getWidth() -6, 98);
g.setFont('Vector', 52); g.setFont('Vector', 52);
g.setFontAlign(-1, -1); g.setFontAlign(-1, -1);
g.drawString(dows[w].slice(0,2).toUpperCase(), 6, 103); g.drawString(dow.slice(0,2).toUpperCase(), 6, 103);
g.fillRect(9,159,166,171); g.fillRect(9,159,166,171);
g.fillRect(167,163,170,167); g.fillRect(167,163,170,167);
if (Bangle.isCharging()) { if (Bangle.isCharging()) {
g.setColor(1,1,0); g.setColor(1,1,0);
} else if (level > 40) { g.fillRect(12,162,12+width,168);
g.setColor(0,1,0);
} else { } else {
g.setColor(1,0,0); g.setColor(1,0,0);
g.fillRect(12,162,57,168);
g.setColor(1,1,0);
g.fillRect(58,162,72,168);
g.setColor(0,1,0);
g.fillRect(73,162,162,168);
} }
g.fillRect(12,162,12+width,168); if (width < 150) {
if (level < 100) {
g.setColor(g.theme.bg); g.setColor(g.theme.bg);
g.fillRect(12+width+1,162,162,168); g.fillRect(12+width+1,162,162,168);
} }
if (Bangle.isCharging()) {
g.setColor(1,1,0);
} else if (width <= 45) {
g.setColor(1,0,0);
} else if (width <= 60) {
g.setColor(1,1,0);
} else {
g.setColor(0, 1, 0); g.setColor(0, 1, 0);
}
g.fillRect(0, 90, g.getWidth(), 94); g.fillRect(0, 90, g.getWidth(), 94);
// widget redraw // widget redraw

View File

@ -1,7 +1,7 @@
{ "id": "bigdclock", { "id": "bigdclock",
"name": "Big digit clock containing just the essentials", "name": "Big digit clock containing just the essentials",
"shortName":"Big digit clk", "shortName":"Big digit clk",
"version":"0.06", "version":"0.07",
"description": "A clock containing just the essentials, made as easy to read as possible for those of us that need glasses. It contains the time, the day-of-week, the day-of-month, and the current battery state-of-charge.", "description": "A clock containing just the essentials, made as easy to read as possible for those of us that need glasses. It contains the time, the day-of-week, the day-of-month, and the current battery state-of-charge.",
"icon": "bigdclock.png", "icon": "bigdclock.png",
"type": "clock", "type": "clock",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB