SIM - how to simulate heart rate history

I enable Simulation > Fit Data > Simulate Data and then I try to do following inside my watchface:

var graphData = [];
		
if (ActivityMonitor has :getHeartRateHistory) {
	var getNext = true;
	var iterator = ActivityMonitor.getHeartRateHistory(120 /* count of entries */, true /* newestFirst */);
	while (getNext) {
		var sample = iterator.next();
		if (sample != null && sample.heartRate != ActivityMonitor.INVALID_HR_SAMPLE) {
			graphData.add(sample.heartRate);
		} else {
			getNext = false;
		}
	}
}

System.println("size=" + graphData.size());
		

And I always get only 1 entry in the SIM (even after waiting a few minutes). Can I somehow simulate the history?

  • It's probably the code where you have

    sample.heartRate != ActivityMonitor.INVALID_HR_SAMPLE

    That's what you see if you take the watch off for a time and put it back on.  You may want to indicate that as a gap in the chart but continue on, but not stop looking at the samples.

    Sample are saved every couple minutes or so, and in the sim, you'll get a bunch right away,

    Here's one of my WF, with the hr history (newest is to the right) and you see the gap right after the newest sample, as well as a 3 more.  It's so you can test if you handle INVALID_HR_SAMPLE correctly.

    And in the sim, the history doesn't change.

  • Thanks, that was the issue