Skip to content

New bug in bigdclock.app.js #3320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/bigdclock/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
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
0.08: Minor code improvements
0.09: Something was changing the value of the "width" variable, which caused the battery usage feature to malfunction. The "width" variable has been renamed - the cause remains a mystery.
16 changes: 8 additions & 8 deletions apps/bigdclock/bigdclock.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Graphics.prototype.setFontOpenSans = function(scale) {

var drawTimeout;
var lastBattCheck = 0;
var width = 0;
var batteryUsedWidth = 0;

function queueDraw(millis_now) {
if (drawTimeout) clearTimeout(drawTimeout);
Expand All @@ -32,8 +32,8 @@ function draw() {

if ((date.getTime() >= lastBattCheck + 15*60000) || Bangle.isCharging()) {
lastBattCheck = date.getTime();
width = E.getBattery();
width += width/2;
batteryUsedWidth = E.getBattery();
batteryUsedWidth += batteryUsedWidth/2;
}

g.reset();
Expand All @@ -58,7 +58,7 @@ function draw() {
g.fillRect(167,163,170,167);
if (Bangle.isCharging()) {
g.setColor(1,1,0);
g.fillRect(12,162,12+width,168);
g.fillRect(12,162,12+batteryUsedWidth,168);
} else {
g.setColor(1,0,0);
g.fillRect(12,162,57,168);
Expand All @@ -67,16 +67,16 @@ function draw() {
g.setColor(0,1,0);
g.fillRect(73,162,162,168);
}
if (width < 150) {
if (batteryUsedWidth < 150) {
g.setColor(g.theme.bg);
g.fillRect(12+width+1,162,162,168);
g.fillRect(12+batteryUsedWidth+1,162,162,168);
}

if (Bangle.isCharging()) {
g.setColor(1,1,0);
} else if (width <= 45) {
} else if (batteryUsedWidth <= 45) {
g.setColor(1,0,0);
} else if (width <= 60) {
} else if (batteryUsedWidth <= 60) {
g.setColor(1,1,0);
} else {
g.setColor(0, 1, 0);
Expand Down
2 changes: 1 addition & 1 deletion apps/bigdclock/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ "id": "bigdclock",
"name": "Big digit clock containing just the essentials",
"shortName":"Big digit clk",
"version": "0.08",
"version": "0.09",
"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",
"type": "clock",
Expand Down