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.04: Shows day of week
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,137 +1,163 @@
/* 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 startOffsetHeight = 40;
var startOffsetY = 30;
var checkBarWidth = 10;
var checkBarHeight = 140;
let startBarOffsetX = startOffsetX;
let startBarOffsetY = startOffsetY;
var digitWidth = 14;
var digitHeight = 120;
let upperTextBarLeftOffsetX = startBarOffsetX + checkBarWidth;
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);
var drawTimeout;
function renderWatch(l) {
g.setFont("4x6",2);
g.setFont("4x6",2);
// 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 h = d.getHours(), m = d.getMinutes();
var time = h + ":" + ("0"+m).substr(-2);
//var month = ("0" + (d.getMonth()+1)).slice(-2);
var dayOfMonth = ('0' + d.getDate()).slice(-2);
var dayOfWeek = d.getDay() || 7;
var concatTime = ("0"+h).substr(-2) + ("0"+m).substr(-2) + dayOfMonth + dayOfWeek;
var d = new Date();
var h = d.getHours(), m = d.getMinutes();
var time = h + ":" + ("0"+m).substr(-2);
//var month = ("0" + (d.getMonth()+1)).slice(-2);
var dayOfMonth = ('0' + d.getDate()).slice(-2);
var dayOfWeek = d.getDay() || 7;
var concatTime = ("0"+h).substr(-2) + ("0"+m).substr(-2) + dayOfMonth + dayOfWeek;
const chars = String(concatTime).split("").map((concatTime) => {
return Number(concatTime);
});
const checkSum = calculateChecksum(chars);
concatTime += checkSum;
const chars = String(concatTime).split("").map((concatTime) => {
return Number(concatTime);
});
drawCheckBar(startBarOffsetX, startBarOffsetY);
drawStart(startOffsetX, offsetY);
drawLDigit(chars[0], 0, leftBarsStartY);
drawLDigit(chars[1], 1, leftBarsStartY);
drawLDigit(chars[2], 2, leftBarsStartY);
drawLDigit(chars[3], 3, leftBarsStartY);
drawLDigit(chars[0], 0, offsetY);
drawLDigit(chars[1], 1, offsetY);
drawLDigit(chars[2], 2, offsetY);
drawLDigit(chars[3], 3, offsetY);
g.drawString(Bangle.getStepCount(), startOffsetX + checkBarWidth + 3, startOffsetY + 4);
g.drawString(concatTime.substring(0,4), startOffsetX + checkBarWidth + 3, startOffsetY + textBarHeight + digitBarHeight + 6);
drawMid(midCheckBarOffsetX, offsetY);
drawCheckBar(midBarOffsetX, midBarOffsetY);
drawRDigit(chars[4], 0, offsetY);
drawRDigit(chars[5], 1, offsetY);
drawRDigit(chars[6], 2, offsetY);
drawRDigit(calculateChecksum(chars), 3, offsetY);
drawRDigit(chars[4], 0, rightBarsStartY);
drawRDigit(chars[5], 1, rightBarsStartY);
drawRDigit(chars[6], 2, rightBarsStartY);
drawRDigit(checkSum, 3, rightBarsStartY);
drawEnd(endCheckBarOffsetX, offsetY);
g.drawString(concatTime.substring(4), midBarOffsetX + checkBarWidth + 3, startOffsetY + textBarHeight + digitBarHeight + 6);
// schedule a draw for the next minute
if (drawTimeout) {
clearTimeout(drawTimeout);
}
drawTimeout = setTimeout(function() {
drawTimeout = undefined;
layout.render(layout.watch);
}, 60000 - (Date.now() % 60000));
drawCheckBar(endBarOffsetX, endBarOffsetY);
// schedule a draw for the next minute
if (drawTimeout) {
clearTimeout(drawTimeout);
}
drawTimeout = setTimeout(function() {
drawTimeout = undefined;
layout.render(layout.watch);
}, (1000 * 60 * 5) - (Date.now() % (1000 * 60 * 5)));
}
function drawLDigit(digit, index, offsetY) {
switch(digit) {
case 0:
drawLZeroWithOffset(startDigitOffsetX+(digitWidth*index), offsetY);
break;
case 1:
drawLOneWithOffset(startDigitOffsetX+(digitWidth*index), offsetY);
break;
case 2:
drawLTwoWithOffset(startDigitOffsetX+(digitWidth*index), offsetY);
break;
case 3:
drawLThreeWithOffset(startDigitOffsetX+(digitWidth*index), offsetY);
break;
case 4:
drawLFourWithOffset(startDigitOffsetX+(digitWidth*index), offsetY);
break;
case 5:
drawLFiveWithOffset(startDigitOffsetX+(digitWidth*index), offsetY);
break;
case 6:
drawLSixWithOffset(startDigitOffsetX+(digitWidth*index), offsetY);
break;
case 7:
drawLSevenWithOffset(startDigitOffsetX+(digitWidth*index), offsetY);
break;
case 8:
drawLEightWithOffset(startDigitOffsetX+(digitWidth*index), offsetY);
break;
case 9:
drawLNineWithOffset(startDigitOffsetX+(digitWidth*index), offsetY);
break;
}
switch(digit) {
case 0:
drawLZeroWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break;
case 1:
drawLOneWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break;
case 2:
drawLTwoWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break;
case 3:
drawLThreeWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break;
case 4:
drawLFourWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break;
case 5:
drawLFiveWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break;
case 6:
drawLSixWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break;
case 7:
drawLSevenWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break;
case 8:
drawLEightWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break;
case 9:
drawLNineWithOffset(leftBarsStartX+(digitBarWidth*index), offsetY);
break;
}
}
function drawRDigit(digit, index, offsetY) {
switch(digit) {
case 0:
drawRZeroWithOffset(midDigitOffsetX+(digitWidth*index), offsetY);
break;
case 1:
drawROneWithOffset(midDigitOffsetX+(digitWidth*index), offsetY);
break;
case 2:
drawRTwoWithOffset(midDigitOffsetX+(digitWidth*index), offsetY);
break;
case 3:
drawRThreeWithOffset(midDigitOffsetX+(digitWidth*index), offsetY);
break;
case 4:
drawRFourWithOffset(midDigitOffsetX+(digitWidth*index), offsetY);
break;
case 5:
drawRFiveWithOffset(midDigitOffsetX+(digitWidth*index), offsetY);
break;
case 6:
drawRSixWithOffset(midDigitOffsetX+(digitWidth*index), offsetY);
break;
case 7:
drawRSevenWithOffset(midDigitOffsetX+(digitWidth*index), offsetY);
break;
case 8:
drawREightWithOffset(midDigitOffsetX+(digitWidth*index), offsetY);
break;
case 9:
drawRNineWithOffset(midDigitOffsetX+(digitWidth*index), offsetY);
break;
}
switch(digit) {
case 0:
drawRZeroWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break;
case 1:
drawROneWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break;
case 2:
drawRTwoWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break;
case 3:
drawRThreeWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break;
case 4:
drawRFourWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break;
case 5:
drawRFiveWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break;
case 6:
drawRSixWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break;
case 7:
drawRSevenWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break;
case 8:
drawREightWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break;
case 9:
drawRNineWithOffset(rightBarsStartX+(digitBarWidth*index), offsetY);
break;
}
}
/*
@ -150,83 +176,83 @@ LEAN
xxxx xx
*/
function drawLOneWithOffset(offset, offsetY) {
let barOneX = 4;
let barTwoX = 12;
g.fillRect(barOneX+offset,offsetY+0,barOneX+3+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight);
g.drawString("1",offset+3,offsetY+digitHeight+5);
let barOneX = 4;
let barTwoX = 12;
g.fillRect(barOneX+offset,offsetY+0,barOneX+3+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
//g.drawString("1",offset+3,offsetY+digitHeight+5);
}
function drawLTwoWithOffset(offset, offsetY) {
let barOneX = 4;
let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+3+offset,offsetY+digitHeight);
g.drawString("2",offset+3,offsetY+digitHeight+5);
let barOneX = 4;
let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+3+offset,offsetY+digitBarHeight);
//g.drawString("2",offset+3,offsetY+digitHeight+5);
}
function drawLThreeWithOffset(offset, offsetY) {
let barOneX = 2;
let barTwoX = 12;
g.fillRect(barOneX+offset,offsetY+0,barOneX+7+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight);
g.drawString("3",offset+3,offsetY+digitHeight+5);
let barOneX = 2;
let barTwoX = 12;
g.fillRect(barOneX+offset,offsetY+0,barOneX+7+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
//g.drawString("3",offset+3,offsetY+digitHeight+5);
}
function drawLFourWithOffset(offset, offsetY) {
let barOneX = 2;
let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+3+offset,offsetY+digitHeight);
g.drawString("4",offset+3,offsetY+digitHeight+5);
let barOneX = 2;
let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+3+offset,offsetY+digitBarHeight);
//g.drawString("4",offset+3,offsetY+digitHeight+5);
}
function drawLFiveWithOffset(offset, offsetY) {
let barOneX = 2;
let barTwoX = 12;
g.fillRect(barOneX+offset,offsetY+0,barOneX+3+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight);
g.drawString("5",offset+3,offsetY+digitHeight+5);
let barOneX = 2;
let barTwoX = 12;
g.fillRect(barOneX+offset,offsetY+0,barOneX+3+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
//g.drawString("5",offset+3,offsetY+digitHeight+5);
}
function drawLSixWithOffset(offset, offsetY) {
let barOneX = 2;
let barTwoX = 6;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+7+offset,offsetY+digitHeight);
g.drawString("6",offset+3,offsetY+digitHeight+5);
let barOneX = 2;
let barTwoX = 6;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+7+offset,offsetY+digitBarHeight);
//g.drawString("6",offset+3,offsetY+digitHeight+5);
}
function drawLSevenWithOffset(offset, offsetY) {
let barOneX = 2;
let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+5+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+3+offset,offsetY+digitHeight);
g.drawString("7",offset+3,offsetY+digitHeight+5);
let barOneX = 2;
let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+5+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+3+offset,offsetY+digitBarHeight);
//g.drawString("7",offset+3,offsetY+digitHeight+5);
}
function drawLEightWithOffset(offset, offsetY) {
let barOneX = 2;
let barTwoX = 8;
g.fillRect(barOneX+offset,offsetY+0,barOneX+3+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+5+offset,offsetY+digitHeight);
g.drawString("8",offset+3,offsetY+digitHeight+5);
let barOneX = 2;
let barTwoX = 8;
g.fillRect(barOneX+offset,offsetY+0,barOneX+3+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+5+offset,offsetY+digitBarHeight);
//g.drawString("8",offset+3,offsetY+digitHeight+5);
}
function drawLNineWithOffset(offset, offsetY) {
let barOneX = 6;
let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+3+offset,offsetY+digitHeight);
g.drawString("9",offset+3,offsetY+digitHeight+5);
let barOneX = 6;
let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+3+offset,offsetY+digitBarHeight);
//g.drawString("9",offset+3,offsetY+digitHeight+5);
}
function drawLZeroWithOffset(offset, offsetY) {
let barOneX = 6;
let barTwoX = 12;
g.fillRect(barOneX+offset,offsetY+0,barOneX+3+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight);
g.drawString("0",offset+3,offsetY+digitHeight+5);
let barOneX = 6;
let barTwoX = 12;
g.fillRect(barOneX+offset,offsetY+0,barOneX+3+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
//g.drawString("0",offset+3,offsetY+digitHeight+5);
}
@ -248,125 +274,109 @@ xxxxxx xx
*/
function drawROneWithOffset(offset, offsetY) {
let barOneX = 0;
let barTwoX = 8;
g.fillRect(offset+barOneX,offsetY+0,offset+barOneX+3,offsetY+digitHeight);
g.fillRect(offset+barTwoX,offsetY+0,offset+barTwoX+3,offsetY+digitHeight);
g.drawString("1",offset+2,offsetY+digitHeight+5);
let barOneX = 0;
let barTwoX = 8;
g.fillRect(offset+barOneX,offsetY+0,offset+barOneX+3,offsetY+digitBarHeight);
g.fillRect(offset+barTwoX,offsetY+0,offset+barTwoX+3,offsetY+digitBarHeight);
//g.drawString("1",offset+2,offsetY+textHeight+5);
}
function drawRTwoWithOffset(offset, offsetY) {
let barOneX = 0;
let barTwoX = 6;
g.fillRect(offset+barOneX,offsetY+0,offset+barOneX+3,offsetY+digitHeight);
g.fillRect(offset+barTwoX,offsetY+0,offset+barTwoX+3,offsetY+digitHeight);
g.drawString("2",offset+2,offsetY+digitHeight+5);
let barOneX = 0;
let barTwoX = 6;
g.fillRect(offset+barOneX,offsetY+0,offset+barOneX+3,offsetY+digitBarHeight);
g.fillRect(offset+barTwoX,offsetY+0,offset+barTwoX+3,offsetY+digitBarHeight);
//g.drawString("2",offset+2,offsetY+textHeight+5);
}
function drawRThreeWithOffset(offset, offsetY) {
let barOneX = 0;
let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight);
g.drawString("3",offset+2,offsetY+digitHeight+5);
let barOneX = 0;
let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
//g.drawString("3",offset+2,offsetY+textHeight+5);
}
function drawRFourWithOffset(offset, offsetY) {
let barOneX = 0;
let barTwoX = 4;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+5+offset,offsetY+digitHeight);
g.drawString("4",offset+2,offsetY+digitHeight+5);
let barOneX = 0;
let barTwoX = 4;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+5+offset,offsetY+digitBarHeight);
//g.drawString("4",offset+2,offsetY+textHeight+5);
}
function drawRFiveWithOffset(offset, offsetY) {
let barOneX = 0;
let barTwoX = 6;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+5+offset,offsetY+digitHeight);
g.drawString("5",offset+2,offsetY+digitHeight+5);
let barOneX = 0;
let barTwoX = 6;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+5+offset,offsetY+digitBarHeight);
//g.drawString("5",offset+2,offsetY+textHeight+5);
}
function drawRSixWithOffset(offset, offsetY) {
let barOneX = 0;
let barTwoX = 4;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight);
g.drawString("6",offset+2,offsetY+digitHeight+5);
let barOneX = 0;
let barTwoX = 4;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
//g.drawString("6",offset+2,offsetY+textHeight+5);
}
function drawRSevenWithOffset(offset, offsetY) {
let barOneX = 0;
let barTwoX = 8;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight);
g.drawString("7",offset+2,offsetY+digitHeight+5);
let barOneX = 0;
let barTwoX = 8;
g.fillRect(barOneX+offset,offsetY+0,barOneX+1+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
//g.drawString("7",offset+2,offsetY+textHeight+5);
}
function drawREightWithOffset(offset, offsetY) {
let barOneX = 0;
let barTwoX = 6;
g.fillRect(offset+barOneX,offsetY+0,offset+barOneX+1,offsetY+digitHeight);
g.fillRect(offset+barTwoX,offsetY+0,offset+barTwoX+1,offsetY+digitHeight);
g.drawString("8",offset+2,offsetY+digitHeight+5);
let barOneX = 0;
let barTwoX = 6;
g.fillRect(offset+barOneX,offsetY+0,offset+barOneX+1,offsetY+digitBarHeight);
g.fillRect(offset+barTwoX,offsetY+0,offset+barTwoX+1,offsetY+digitBarHeight);
//g.drawString("8",offset+2,offsetY+textHeight+5);
}
function drawRNineWithOffset(offset, offsetY) {
let barOneX = 0;
let barTwoX = 8;
g.fillRect(barOneX+offset,offsetY+0,barOneX+5+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight);
g.drawString("9",offset+2,offsetY+digitHeight+5);
let barOneX = 0;
let barTwoX = 8;
g.fillRect(barOneX+offset,offsetY+0,barOneX+5+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
//g.drawString("9",offset+2,offsetY+textHeight+5);
}
function drawRZeroWithOffset(offset, offsetY) {
let barOneX = 0;
let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+5+offset,offsetY+digitHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitHeight);
g.drawString("0",offset+2,offsetY+digitHeight+5);
let barOneX = 0;
let barTwoX = 10;
g.fillRect(barOneX+offset,offsetY+0,barOneX+5+offset,offsetY+digitBarHeight);
g.fillRect(barTwoX+offset,offsetY+0,barTwoX+1+offset,offsetY+digitBarHeight);
//g.drawString("0",offset+2,offsetY+textHeight+5);
}
function drawStart(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 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 drawCheckBar(offsetX, offsetY) {
const barOneX = offsetX+2;
const barOneWidth = 1;
const barTwoX = offsetX+6;
const barTwoWidth = 1;
g.fillRect(barOneX,offsetY,barOneX+barOneWidth,offsetY+checkBarHeight);
g.fillRect(barTwoX,offsetY,barTwoX+barTwoWidth,offsetY+checkBarHeight);
}
function calculateChecksum(digits) {
let oddSum = digits[6] + digits[4] + digits[2] + digits[0];
let evenSum = digits[5] + digits[3] + digits[1];
let oddSum = digits[6] + digits[4] + digits[2] + digits[0];
let evenSum = digits[5] + digits[3] + digits[1];
let checkSum = (10 - ((3 * oddSum + evenSum) % 10)) % 10;
let checkSum = (10 - ((3 * oddSum + evenSum) % 10)) % 10;
return checkSum;
return checkSum;
}
// The layout, referencing the custom renderer
var Layout = require("Layout");
var layout = new Layout( {
type:"v", c: [
{type:"custom", render:renderWatch, id:"watch", bgCol:g.theme.bg, fillx:1, filly:1 }
]
type:"v", c: [
{type:"custom", render:renderWatch, id:"watch", bgCol:g.theme.bg, fillx:1, filly:1 }
]
});
// Clear the screen once, at startup
@ -375,3 +385,7 @@ Bangle.loadWidgets();
Bangle.drawWidgets();
Bangle.setUI("clock");
layout.render();
Bangle.on('lock', function(locked) {
layout.render();
});

View File

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