Merge pull request #1 from leer10/style-cleanup

style cleanup
master
leer10 2021-11-28 14:58:18 -08:00 committed by GitHub
commit 918dcba633
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 61 deletions

View File

@ -4462,7 +4462,7 @@
"shortName":"93 Dub", "shortName":"93 Dub",
"icon": "93dub.png", "icon": "93dub.png",
"screenshots": [{"url":"screenshot.png"}], "screenshots": [{"url":"screenshot.png"}],
"version":"0.02", "version":"0.03",
"description": "Fan recreation of orviwan's 91 Dub app for the Pebble smartwatch. Uses assets from his 91-Dub-v2.0 repo", "description": "Fan recreation of orviwan's 91 Dub app for the Pebble smartwatch. Uses assets from his 91-Dub-v2.0 repo",
"tags": "clock", "tags": "clock",
"type": "clock", "type": "clock",

View File

@ -1,2 +1,3 @@
0.01 Initial version for upload 0.01 Initial version for upload
0.02 DiscoMinotaur's adjustments (removed battery and adjusted spacing) 0.02 DiscoMinotaur's adjustments (removed battery and adjusted spacing)
0.03 Code style cleanup

View File

@ -48,72 +48,75 @@ function queueDraw() {
} }
function drawBackground() { function drawBackground() {
// set background g.setBgColor(0,0,0);
g.setBgColor(0,0,0); g.setColor(1,1,1);
g.setColor(1,1,1); g.clear();
g.clear(); g.drawImage(imgBg,0,0);
g.drawImage(imgBg,0,0); g.reset();
g.reset();
} }
function draw(){ function draw(){
drawBackground(); drawBackground();
var date = new Date(); var date = new Date();
var h = date.getHours(), m = date.getMinutes(); var h = date.getHours(), m = date.getMinutes();
var d = date.getDate(), w = date.getDay(); var d = date.getDate(), w = date.getDay();
g.reset(); g.reset();
g.setBgColor(0,0,0); g.setBgColor(0,0,0);
g.setColor(1,1,1); g.setColor(1,1,1);
//draw 24 hr indicator and 12 hr specific behavior //draw 24 hr indicator and 12 hr specific behavior
if (is24hr){ if (is24hr){
g.drawImage(img24hr,32, 65); g.drawImage(img24hr,32, 65);
if (leadingZero){ if (leadingZero){
h = ("0"+h).substr(-2);}} h = ("0"+h).substr(-2);
else if (h > 12) {g.drawImage(imgPM,40, 70); }
h = h - 12; } else if (h > 12) {
if (leadingZero){ g.drawImage(imgPM,40, 70);
h = ("0"+h).substr(-2);} h = h - 12;
else if (leadingZero){
{h = " " + h;} h = ("0"+h).substr(-2);
} } else {
h = " " + h;
//draw separator
if (separator){
g.drawImage(imgSep, 85,98);}
//draw day of week
var imgW = null;
if (w == 0) {imgW = imgSun;}
if (w == 1) {imgW = imgMon;}
if (w == 2) {imgW = imgTue;}
if (w == 3) {imgW = imgWed;}
if (w == 4) {imgW = imgThr;}
if (w == 5) {imgW = imgFri;}
if (w == 6) {imgW = imgSat;}
g.drawImage(imgW, 85, 63);
// draw nums
// draw time
g.setColor(0,0,0);
g.setBgColor(1,1,1);
g.setFontCustom(fontNum, 48, 28, 41);
if (h<10) {
if (leadingZero) {
h = ("0"+h).substr(-2);
} }
else {h = " " + h;} }
}
g.drawString(h, 25, 90, true);
g.drawString(("0"+m).substr(-2), 92, 90, true);
// draw date
g.setFontCustom(fontDate, 48, 12, 15);
g.drawString(("0"+d).substr(-2), 123,63, true);
// widget redraw //draw separator
Bangle.drawWidgets(); if (separator){
queueDraw(); g.drawImage(imgSep, 85,98);}
//draw day of week
var imgW = null;
if (w == 0) {imgW = imgSun;}
if (w == 1) {imgW = imgMon;}
if (w == 2) {imgW = imgTue;}
if (w == 3) {imgW = imgWed;}
if (w == 4) {imgW = imgThr;}
if (w == 5) {imgW = imgFri;}
if (w == 6) {imgW = imgSat;}
g.drawImage(imgW, 85, 63);
// draw nums
// draw time
g.setColor(0,0,0);
g.setBgColor(1,1,1);
g.setFontCustom(fontNum, 48, 28, 41);
if (h<10) {
if (leadingZero) {
h = ("0"+h).substr(-2);
} else {
h = " " + h;
}
}
g.drawString(h, 25, 90, true);
g.drawString(("0"+m).substr(-2), 92, 90, true);
// draw date
g.setFontCustom(fontDate, 48, 12, 15);
g.drawString(("0"+d).substr(-2), 123,63, true);
// widget redraw
Bangle.drawWidgets();
queueDraw();
} }