Showing the steps and HR each second

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?

  • Yes, that's the f5x.  When you go to the watch face picker, you are running on the main processor.  When you are just running normally, it's the display processor and it won't see the HR. It's not a problem, it's something specific to the f5x hardware.  Nothing will change. for Hr.

    While I didn't include it, if Activity.Info.currentHeratrate is null, you can fall back to getHeartRateHistory and grab the newest sample, but 

  • It's really useful information. It's strange that I couldn't find it in the public domain.
    I'll have to come to terms with this fact and save up for a new watch. I'm sorry. Thank you very much for informing me!
    Do you know if there is a similar situation in the case of Fenix 5S?

  • Just the f5x, and it's because of the way they did maps on it.  Any of the f5+ devices, f6 device, 935,945 will work.

    There's a number of threads right here about the f5x and this, going back years.

  • Thanks! You have solved a great problem for me!