Step counter and more restrictive time updates.

master
Matrixes 2022-05-15 15:15:00 +02:00
parent 6bded83f77
commit a8436b96ea
3 changed files with 251 additions and 236 deletions

View File

@ -3,3 +3,4 @@
0.03: Interaction 0.03: Interaction
0.04: Shows day of week 0.04: Shows day of week
0.05: Shows day of month 0.05: Shows day of month
0.06: Updates every 5 minutes when locked, or when unlock occurs. Also shows nr of steps.

View File

@ -1,19 +1,40 @@
/* Sizes */
let checkBarWidth = 10;
let checkBarHeight = 140;
let digitBarWidth = 14;
let digitBarHeight = 100;
let textBarWidth = 56;
let textBarHeight = 20;
let textWidth = 14;
let textHeight = 20;
/* Offsets */
var startOffsetX = 17; var startOffsetX = 17;
var startOffsetHeight = 40; var startOffsetY = 30;
var checkBarWidth = 10; let startBarOffsetX = startOffsetX;
var checkBarHeight = 140; let startBarOffsetY = startOffsetY;
var digitWidth = 14; let upperTextBarLeftOffsetX = startBarOffsetX + checkBarWidth;
var digitHeight = 120; let upperTextBarLeftOffsetY = startOffsetY;
var startDigitOffsetX = startOffsetX + checkBarWidth; let midBarOffsetX = upperTextBarLeftOffsetX + textBarWidth;
let midBarOffsetY = startOffsetY;
var midCheckBarOffsetX = startOffsetX + checkBarWidth + digitWidth * 4; let upperTextBarRightOffsetX = midBarOffsetX + checkBarWidth;
let upperTextBarRightOffsetY = startOffsetY;
var midDigitOffsetX = startOffsetX + checkBarWidth + digitWidth * 4 + checkBarWidth; let endBarOffsetX = upperTextBarRightOffsetX + textBarWidth;
let endBarOffsetY = startOffsetY;
var endCheckBarOffsetX = startOffsetX + checkBarWidth + digitWidth * 4 + checkBarWidth + digitWidth * 4; let leftBarsStartX = startBarOffsetX + checkBarWidth;
let leftBarsStartY = upperTextBarLeftOffsetY + textBarHeight;
let rightBarsStartX = midBarOffsetX + checkBarWidth;
let rightBarsStartY = upperTextBarRightOffsetY + textBarHeight;
let intCaster = num => Number(num); let intCaster = num => Number(num);
@ -24,8 +45,6 @@ function renderWatch(l) {
// work out how to display the current time // work out how to display the current time
var offsetY = l.y;
var d = new Date(); var d = new Date();
var h = d.getHours(), m = d.getMinutes(); var h = d.getHours(), m = d.getMinutes();
var time = h + ":" + ("0"+m).substr(-2); var time = h + ":" + ("0"+m).substr(-2);
@ -37,22 +56,29 @@ function renderWatch(l) {
const chars = String(concatTime).split("").map((concatTime) => { const chars = String(concatTime).split("").map((concatTime) => {
return Number(concatTime); return Number(concatTime);
}); });
const checkSum = calculateChecksum(chars);
concatTime += checkSum;
drawStart(startOffsetX, offsetY); drawCheckBar(startBarOffsetX, startBarOffsetY);
drawLDigit(chars[0], 0, offsetY); drawLDigit(chars[0], 0, leftBarsStartY);
drawLDigit(chars[1], 1, offsetY); drawLDigit(chars[1], 1, leftBarsStartY);
drawLDigit(chars[2], 2, offsetY); drawLDigit(chars[2], 2, leftBarsStartY);
drawLDigit(chars[3], 3, offsetY); drawLDigit(chars[3], 3, leftBarsStartY);
drawMid(midCheckBarOffsetX, offsetY); g.drawString(Bangle.getStepCount(), startOffsetX + checkBarWidth + 3, startOffsetY + 4);
g.drawString(concatTime.substring(0,4), startOffsetX + checkBarWidth + 3, startOffsetY + textBarHeight + digitBarHeight + 6);
drawRDigit(chars[4], 0, offsetY); drawCheckBar(midBarOffsetX, midBarOffsetY);
drawRDigit(chars[5], 1, offsetY);
drawRDigit(chars[6], 2, offsetY);
drawRDigit(calculateChecksum(chars), 3, offsetY);
drawEnd(endCheckBarOffsetX, offsetY); drawRDigit(chars[4], 0, rightBarsStartY);
drawRDigit(chars[5], 1, rightBarsStartY);
drawRDigit(chars[6], 2, rightBarsStartY);
drawRDigit(checkSum, 3, rightBarsStartY);
g.drawString(concatTime.substring(4), midBarOffsetX + checkBarWidth + 3, startOffsetY + textBarHeight + digitBarHeight + 6);
drawCheckBar(endBarOffsetX, endBarOffsetY);
// schedule a draw for the next minute // schedule a draw for the next minute
if (drawTimeout) { if (drawTimeout) {
@ -61,40 +87,40 @@ function renderWatch(l) {
drawTimeout = setTimeout(function() { drawTimeout = setTimeout(function() {
drawTimeout = undefined; drawTimeout = undefined;
layout.render(layout.watch); layout.render(layout.watch);
}, 60000 - (Date.now() % 60000)); }, (1000 * 60 * 5) - (Date.now() % (1000 * 60 * 5)));
} }
function drawLDigit(digit, index, offsetY) { function drawLDigit(digit, index, offsetY) {
switch(digit) { switch(digit) {
case 0: case 0:
drawLZeroWithOffset(startDigitOffsetX+(digitWidth*index), offsetY); drawLZeroWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 1: case 1:
drawLOneWithOffset(startDigitOffsetX+(digitWidth*index), offsetY); drawLOneWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 2: case 2:
drawLTwoWithOffset(startDigitOffsetX+(digitWidth*index), offsetY); drawLTwoWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 3: case 3:
drawLThreeWithOffset(startDigitOffsetX+(digitWidth*index), offsetY); drawLThreeWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 4: case 4:
drawLFourWithOffset(startDigitOffsetX+(digitWidth*index), offsetY); drawLFourWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 5: case 5:
drawLFiveWithOffset(startDigitOffsetX+(digitWidth*index), offsetY); drawLFiveWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 6: case 6:
drawLSixWithOffset(startDigitOffsetX+(digitWidth*index), offsetY); drawLSixWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 7: case 7:
drawLSevenWithOffset(startDigitOffsetX+(digitWidth*index), offsetY); drawLSevenWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 8: case 8:
drawLEightWithOffset(startDigitOffsetX+(digitWidth*index), offsetY); drawLEightWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 9: case 9:
drawLNineWithOffset(startDigitOffsetX+(digitWidth*index), offsetY); drawLNineWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break; break;
} }
} }
@ -102,34 +128,34 @@ function drawLDigit(digit, index, offsetY) {
function drawRDigit(digit, index, offsetY) { function drawRDigit(digit, index, offsetY) {
switch(digit) { switch(digit) {
case 0: case 0:
drawRZeroWithOffset(midDigitOffsetX+(digitWidth*index), offsetY); drawRZeroWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 1: case 1:
drawROneWithOffset(midDigitOffsetX+(digitWidth*index), offsetY); drawROneWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 2: case 2:
drawRTwoWithOffset(midDigitOffsetX+(digitWidth*index), offsetY); drawRTwoWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 3: case 3:
drawRThreeWithOffset(midDigitOffsetX+(digitWidth*index), offsetY); drawRThreeWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 4: case 4:
drawRFourWithOffset(midDigitOffsetX+(digitWidth*index), offsetY); drawRFourWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 5: case 5:
drawRFiveWithOffset(midDigitOffsetX+(digitWidth*index), offsetY); drawRFiveWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 6: case 6:
drawRSixWithOffset(midDigitOffsetX+(digitWidth*index), offsetY); drawRSixWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 7: case 7:
drawRSevenWithOffset(midDigitOffsetX+(digitWidth*index), offsetY); drawRSevenWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 8: case 8:
drawREightWithOffset(midDigitOffsetX+(digitWidth*index), offsetY); drawREightWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break; break;
case 9: case 9:
drawRNineWithOffset(midDigitOffsetX+(digitWidth*index), offsetY); drawRNineWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break; break;
} }
} }
@ -152,81 +178,81 @@ LEAN
function drawLOneWithOffset(offset, offsetY) { function drawLOneWithOffset(offset, offsetY) {
let barOneX = 4; let barOneX = 4;
let barTwoX = 12; let barTwoX = 12;
g.fillRect(barOneX+offset,offsetY+0,barOneX+3+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+3+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
g.drawString("1",offset+3,offsetY+digitHeight+5); //g.drawString("1",offset+3,offsetY+digitHeight+5);
} }
function drawLTwoWithOffset(offset, offsetY) { function drawLTwoWithOffset(offset, offsetY) {
let barOneX = 4; let barOneX = 4;
let barTwoX = 10; let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+3+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+3+offset,offsetY+digitBarHeight);
g.drawString("2",offset+3,offsetY+digitHeight+5); //g.drawString("2",offset+3,offsetY+digitHeight+5);
} }
function drawLThreeWithOffset(offset, offsetY) { function drawLThreeWithOffset(offset, offsetY) {
let barOneX = 2; let barOneX = 2;
let barTwoX = 12; let barTwoX = 12;
g.fillRect(barOneX+offset,offsetY+0,barOneX+7+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+7+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
g.drawString("3",offset+3,offsetY+digitHeight+5); //g.drawString("3",offset+3,offsetY+digitHeight+5);
} }
function drawLFourWithOffset(offset, offsetY) { function drawLFourWithOffset(offset, offsetY) {
let barOneX = 2; let barOneX = 2;
let barTwoX = 10; let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+3+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+3+offset,offsetY+digitBarHeight);
g.drawString("4",offset+3,offsetY+digitHeight+5); //g.drawString("4",offset+3,offsetY+digitHeight+5);
} }
function drawLFiveWithOffset(offset, offsetY) { function drawLFiveWithOffset(offset, offsetY) {
let barOneX = 2; let barOneX = 2;
let barTwoX = 12; let barTwoX = 12;
g.fillRect(barOneX+offset,offsetY+0,barOneX+3+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+3+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
g.drawString("5",offset+3,offsetY+digitHeight+5); //g.drawString("5",offset+3,offsetY+digitHeight+5);
} }
function drawLSixWithOffset(offset, offsetY) { function drawLSixWithOffset(offset, offsetY) {
let barOneX = 2; let barOneX = 2;
let barTwoX = 6; let barTwoX = 6;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+7+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+7+offset,offsetY+digitBarHeight);
g.drawString("6",offset+3,offsetY+digitHeight+5); //g.drawString("6",offset+3,offsetY+digitHeight+5);
} }
function drawLSevenWithOffset(offset, offsetY) { function drawLSevenWithOffset(offset, offsetY) {
let barOneX = 2; let barOneX = 2;
let barTwoX = 10; let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+5+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+5+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+3+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+3+offset,offsetY+digitBarHeight);
g.drawString("7",offset+3,offsetY+digitHeight+5); //g.drawString("7",offset+3,offsetY+digitHeight+5);
} }
function drawLEightWithOffset(offset, offsetY) { function drawLEightWithOffset(offset, offsetY) {
let barOneX = 2; let barOneX = 2;
let barTwoX = 8; let barTwoX = 8;
g.fillRect(barOneX+offset,offsetY+0,barOneX+3+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+3+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+5+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+5+offset,offsetY+digitBarHeight);
g.drawString("8",offset+3,offsetY+digitHeight+5); //g.drawString("8",offset+3,offsetY+digitHeight+5);
} }
function drawLNineWithOffset(offset, offsetY) { function drawLNineWithOffset(offset, offsetY) {
let barOneX = 6; let barOneX = 6;
let barTwoX = 10; let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+3+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+3+offset,offsetY+digitBarHeight);
g.drawString("9",offset+3,offsetY+digitHeight+5); //g.drawString("9",offset+3,offsetY+digitHeight+5);
} }
function drawLZeroWithOffset(offset, offsetY) { function drawLZeroWithOffset(offset, offsetY) {
let barOneX = 6; let barOneX = 6;
let barTwoX = 12; let barTwoX = 12;
g.fillRect(barOneX+offset,offsetY+0,barOneX+3+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+3+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
g.drawString("0",offset+3,offsetY+digitHeight+5); //g.drawString("0",offset+3,offsetY+digitHeight+5);
} }
@ -250,106 +276,90 @@ xxxxxx xx
function drawROneWithOffset(offset, offsetY) { function drawROneWithOffset(offset, offsetY) {
let barOneX = 0; let barOneX = 0;
let barTwoX = 8; let barTwoX = 8;
g.fillRect(offset+barOneX,offsetY+0,offset+barOneX+3,offsetY+digitHeight); g.fillRect(offset+barOneX,offsetY+0,offset+barOneX+3,offsetY+digitBarHeight);
g.fillRect(offset+barTwoX,offsetY+0,offset+barTwoX+3,offsetY+digitHeight); g.fillRect(offset+barTwoX,offsetY+0,offset+barTwoX+3,offsetY+digitBarHeight);
g.drawString("1",offset+2,offsetY+digitHeight+5); //g.drawString("1",offset+2,offsetY+textHeight+5);
} }
function drawRTwoWithOffset(offset, offsetY) { function drawRTwoWithOffset(offset, offsetY) {
let barOneX = 0; let barOneX = 0;
let barTwoX = 6; let barTwoX = 6;
g.fillRect(offset+barOneX,offsetY+0,offset+barOneX+3,offsetY+digitHeight); g.fillRect(offset+barOneX,offsetY+0,offset+barOneX+3,offsetY+digitBarHeight);
g.fillRect(offset+barTwoX,offsetY+0,offset+barTwoX+3,offsetY+digitHeight); g.fillRect(offset+barTwoX,offsetY+0,offset+barTwoX+3,offsetY+digitBarHeight);
g.drawString("2",offset+2,offsetY+digitHeight+5); //g.drawString("2",offset+2,offsetY+textHeight+5);
} }
function drawRThreeWithOffset(offset, offsetY) { function drawRThreeWithOffset(offset, offsetY) {
let barOneX = 0; let barOneX = 0;
let barTwoX = 10; let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
g.drawString("3",offset+2,offsetY+digitHeight+5); //g.drawString("3",offset+2,offsetY+textHeight+5);
} }
function drawRFourWithOffset(offset, offsetY) { function drawRFourWithOffset(offset, offsetY) {
let barOneX = 0; let barOneX = 0;
let barTwoX = 4; let barTwoX = 4;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+5+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+5+offset,offsetY+digitBarHeight);
g.drawString("4",offset+2,offsetY+digitHeight+5); //g.drawString("4",offset+2,offsetY+textHeight+5);
} }
function drawRFiveWithOffset(offset, offsetY) { function drawRFiveWithOffset(offset, offsetY) {
let barOneX = 0; let barOneX = 0;
let barTwoX = 6; let barTwoX = 6;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+5+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+5+offset,offsetY+digitBarHeight);
g.drawString("5",offset+2,offsetY+digitHeight+5); //g.drawString("5",offset+2,offsetY+textHeight+5);
} }
function drawRSixWithOffset(offset, offsetY) { function drawRSixWithOffset(offset, offsetY) {
let barOneX = 0; let barOneX = 0;
let barTwoX = 4; let barTwoX = 4;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
g.drawString("6",offset+2,offsetY+digitHeight+5); //g.drawString("6",offset+2,offsetY+textHeight+5);
} }
function drawRSevenWithOffset(offset, offsetY) { function drawRSevenWithOffset(offset, offsetY) {
let barOneX = 0; let barOneX = 0;
let barTwoX = 8; let barTwoX = 8;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
g.drawString("7",offset+2,offsetY+digitHeight+5); //g.drawString("7",offset+2,offsetY+textHeight+5);
} }
function drawREightWithOffset(offset, offsetY) { function drawREightWithOffset(offset, offsetY) {
let barOneX = 0; let barOneX = 0;
let barTwoX = 6; let barTwoX = 6;
g.fillRect(offset+barOneX,offsetY+0,offset+barOneX+1,offsetY+digitHeight); g.fillRect(offset+barOneX,offsetY+0,offset+barOneX+1,offsetY+digitBarHeight);
g.fillRect(offset+barTwoX,offsetY+0,offset+barTwoX+1,offsetY+digitHeight); g.fillRect(offset+barTwoX,offsetY+0,offset+barTwoX+1,offsetY+digitBarHeight);
g.drawString("8",offset+2,offsetY+digitHeight+5); //g.drawString("8",offset+2,offsetY+textHeight+5);
} }
function drawRNineWithOffset(offset, offsetY) { function drawRNineWithOffset(offset, offsetY) {
let barOneX = 0; let barOneX = 0;
let barTwoX = 8; let barTwoX = 8;
g.fillRect(barOneX+offset,offsetY+0,barOneX+5+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+5+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
g.drawString("9",offset+2,offsetY+digitHeight+5); //g.drawString("9",offset+2,offsetY+textHeight+5);
} }
function drawRZeroWithOffset(offset, offsetY) { function drawRZeroWithOffset(offset, offsetY) {
let barOneX = 0; let barOneX = 0;
let barTwoX = 10; let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+5+offset,offsetY+digitHeight); g.fillRect(barOneX+offset,offsetY+0,barOneX+5+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight); g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
g.drawString("0",offset+2,offsetY+digitHeight+5); //g.drawString("0",offset+2,offsetY+textHeight+5);
} }
function drawCheckBar(offsetX, offsetY) {
const barOneX = offsetX+2;
const barOneWidth = 1;
const barTwoX = offsetX+6;
function drawStart(offset, offsetY) { const barTwoWidth = 1;
let barOneX = 2; g.fillRect(barOneX,offsetY,barOneX+barOneWidth,offsetY+checkBarHeight);
let barTwoX = 6; g.fillRect(barTwoX,offsetY,barTwoX+barTwoWidth,offsetY+checkBarHeight);
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight+15);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight+15);
}
function drawMid(offset, offsetY) {
let barOneX = 2;
let barTwoX = 6;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight+15);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight+15);
}
function drawEnd(offset, offsetY) {
let barOneX = 2;
let barTwoX = 6;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight+15);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight+15);
} }
function calculateChecksum(digits) { function calculateChecksum(digits) {
@ -375,3 +385,7 @@ Bangle.loadWidgets();
Bangle.drawWidgets(); Bangle.drawWidgets();
Bangle.setUI("clock"); Bangle.setUI("clock");
layout.render(); layout.render();
Bangle.on('lock', function(locked) {
layout.render();
});

View File

@ -2,7 +2,7 @@
"name": "Barcode clock", "name": "Barcode clock",
"shortName":"Barcode clock", "shortName":"Barcode clock",
"icon": "barcode.icon.png", "icon": "barcode.icon.png",
"version":"0.05", "version":"0.06",
"description": "EAN-8 compatible barcode clock.", "description": "EAN-8 compatible barcode clock.",
"tags": "barcode,ean,ean-8,watchface,clock,clockface", "tags": "barcode,ean,ean-8,watchface,clock,clockface",
"type": "clock", "type": "clock",