Hello, guys!
I've faced with the problem of showing of the steps and HR for every second
Here is my code
function onUpdate(dc) { View.onUpdate(dc); drawInterface(dc); if (System.getClockTime().sec%5 == 0){ System.println("GO"); onPartialUpdate(dc); } } function onPartialUpdate(dc){ new ODR001Fields().drawFieldsPart(dc); }
function drawFieldsPart(dc){ if (info has :steps) { steps = info.steps; } dc.setColor(BGF, Graphics.COLOR_TRANSPARENT); dc.setClip( 0.207*length - dc.getTextDimensions(steps.toString(), digitFieldsFont)[0]*0.5, 0.5728*length - dc.getTextDimensions(steps.toString(), digitFieldsFont)[1]*0.5, dc.getTextDimensions(steps.toString(), digitFieldsFont)[0]*1, dc.getTextDimensions(steps.toString(), digitFieldsFont)[1]*1); dc.fillRectangle( 0.207*length - dc.getTextDimensions(steps.toString(), digitFieldsFont)[0]*0.5, 0.5728*length - dc.getTextDimensions(steps.toString(), digitFieldsFont)[1]*0.5, dc.getTextDimensions(steps.toString(), digitFieldsFont)[0]*1, dc.getTextDimensions(steps.toString(), digitFieldsFont)[1]*1); dc.setColor(TBGF, Graphics.COLOR_TRANSPARENT); dc.drawText(0.207*length, 0.5728*length, digitFieldsFont, steps, Graphics.TEXT_JUSTIFY_CENTER|Graphics.TEXT_JUSTIFY_VCENTER); dc.clearClip(); var previous = ""; if ((Toybox has :SensorHistory) && (Toybox.SensorHistory has :getHeartRateHistory)) { var sensorIter = Toybox.SensorHistory.getHeartRateHistory({}); System.println(sensorIter.next().data); previous = sensorIter.next().data; } if (previous == null) { previous = "00"; } dc.setClip( x - dc.getTextDimensions(previous.toString(), pulseDigitFont)[0]*0.5, 0.78*length - dc.getTextDimensions(previous.toString(), pulseDigitFont)[1]*0.5, dc.getTextDimensions(previous.toString(), pulseDigitFont)[0]*1, dc.getTextDimensions(previous.toString(), pulseDigitFont)[1]*1); dc.setColor(BGA, Graphics.COLOR_TRANSPARENT); dc.fillRectangle( x - dc.getTextDimensions(previous.toString(), pulseDigitFont)[0]*0.5, 0.78*length - dc.getTextDimensions(previous.toString(), pulseDigitFont)[1]*0.5, dc.getTextDimensions(previous.toString(), pulseDigitFont)[0]*1, dc.getTextDimensions(previous.toString(), pulseDigitFont)[1]*1); dc.setColor(TBGA, Graphics.COLOR_TRANSPARENT); dc.drawText(x, 0.775*length, pulseDigitFont, previous, Graphics.TEXT_JUSTIFY_CENTER|Graphics.TEXT_JUSTIFY_VCENTER); dc.clearClip(); }
So, it's working just fine in the sim, but on my Fenix 5X neither steps neither HR updates every second. These fields update in a minute instead
What I'm doing wrong?