Hello!
I'm trying to make my first analog watchface. So, I'm following some tricks from Analog Sample (Garmin SDK Samples)
So, the main thing which I want to realize - it's make working second hand even in sleep mode
But I've come across the problem with too long Total Time in Watchface Diagnostic.
Can anyone explain me, what I'm doing wrong?
Here is my code
len = dc.getWidth(); secondHand = [ [0.496*len,0.042*len],[0.504*len,0.042*len], [0.504*len,0.538*len],[0.51*len,0.594*len], [0.51*len,0.642*len],[0.5*len,0.646*len], [0.49*len,0.642*len],[0.49*len,0.594*len], [0.496*len,0.538*len]];
function onPartialUpdate( dc ) { dc.drawBitmap(0, 0, offscreenBuffer); var clockTime = System.getClockTime(); var angle = (clockTime.sec / 60.0) * Math.PI * 2; var secondHandPoints = generateHandCoordinates(angle, secondHand); // Update the cliping rectangle to the new location of the second hand. curClip = getBoundingBox( secondHandPoints ); var bboxWidth = curClip[1][0] - curClip[0][0] + 1; var bboxHeight = curClip[1][1] - curClip[0][1] + 1; dc.setClip(curClip[0][0], curClip[0][1], bboxWidth, bboxHeight); dc.setColor(0xFF0000, Gfx.COLOR_TRANSPARENT); dc.fillCircle(cent-1, cent, 0.025*len); dc.fillPolygon(secondHandPoints); }
function generateHandCoordinates(angle, secondHand){ var cos = Math.cos(angle); var sin = Math.sin(angle); // Transform the coordinates for (var i = 0; i < result.size(); i += 1) { var xDigit = (secondHand[i][0] - cent) * cos - (secondHand[i][1] - cent) * sin + cent; var yDigit = (secondHand[i][0] - cent) * sin + (secondHand[i][1] - cent) * cos + cent; result[i] = [xDigit, yDigit]; } return result; }