Stress and Heart Rate in Low Power Mode

A few months back I installed the Watch Face shown below on my Venu 2 from the Connect IQ Store. The Watch Face shows Stress and Heart Rate in both normal and Low Power modes. I assume it is a Garmin Watch Face since Stress was only available to developers.to side load.

Using the Connect IQ 4.1.0 beta I created a Watch Face that also shows Stress and Heart Rate in both normal and Low Power mode. The questions i have are:

1. In Low Power mode, the Watch Face pictured above shows constantly changing Heart Rate. My Watch Face, however, only shows Heart Rate changes about once per minute. Is there a way for me to show the constantly changing Heart Rate in Low Power mode and, if so, is this not desirable because it results in too much battery drain or is not recommended for some other reason?

2. The Stress level displayed on my Watch Face does not always correspond to the one shown above or on the Stress glance. Is there a more accurate way to capture this value than the one used in my code below? Also, I have the same question about whether there is a way for me to show the constantly changing Heart Rate in Low Power mode and, if so, is this not desirable because it results in too much battery drain or is not recommended for some other reason?

		if(inLowPower) {

			// Show Heart Rate
			if (Act has :getHeartRateHistory) {
				heartRate=Activity.getActivityInfo().currentHeartRate;
				// If heartRate is null
				if(heartRate != null) {
					// Change color of the Heart Rate based on level
					changeHRcolor("");
					dc.setColor(HRcolor,Gfx.COLOR_BLACK);
					dc.drawText(x-30,y+97,myfont36bold,heartRate,Gfx.TEXT_JUSTIFY_LEFT);
				}
			}

			// Show Heart Icon
			dc.setColor(Gfx.COLOR_RED,Gfx.COLOR_BLACK);
			dc.drawText(x+50,y+97, myfonticons,"m",Gfx.TEXT_JUSTIFY_RIGHT);
			
			// Show Stress Level
			var sensorIter=getStressIterator();
			if (sensorIter != null) {
				StressLevel = sensorIter.next().data;
				// Change color of the Stress Level based on level
				changeStresscolor("");
				dc.setColor(Stresscolor,Gfx.COLOR_BLACK);
				dc.drawText(x-25,y-40,myfont36bold,Lang.format("$1$",[sensorIter.next().data.format("%02d")]),Gfx.TEXT_JUSTIFY_LEFT);
			}
			
			// Show Stress Icon
			dc.setColor(Gfx.COLOR_BLUE,Gfx.COLOR_BLACK);
			dc.drawText(x+50,y-42,myfontIQicons,"u",Gfx.TEXT_JUSTIFY_RIGHT);				
			
		// If watch is not in Low Power
		} else {

  • When you are in low power mode, onUpdate() is only called once a minute so nothing will change more often than that.  With the AMOLED devices, onPartialUpdate() isn't used.

  • Any idea why the Stress level displayed on my Watch Face does not always correspond to the one shown on the other watch face or on the Stress glance?

  • Native watch faces aren't written in Monkey C can can do this differently,

  • Are you still able to see Stress data with today's update of the Venu2System5preview product/device? I used to get a zero value on the simulator (no errors), but now I'm getting the error "Could not find symbol 'getStressHistory'. Not sure if I'm doing something wrong or if the update broke the Stress and Body Battery data.

  • i am still able to access both Stress and Body data on my Venu 2

  • I'm puzzled then... doing as below using SDK 4.1 beta and Venu2system5preview (updated again today), but still getting blank values. If removing the "has :getBodyBatteryHistory" check, getting the "Could not find symbol 'getBodyBatteryHistory'" error.

    if (ActivityMonitor has :getBodyBatteryHistory){
    	var bbIterator = ActivityMonitor.getBodyBatteryHistory();
    	var sample = bbIterator.next(); 
    
    	if (sample != null){
    		dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
    		dc.drawText(x, y, fontSize, sample.bodyBatteryData.bodyBattery, Graphics.TEXT_JUSTIFY_LEFT);
    	}
    }

    Do  or anyone else have any clue of what I might be doing wrong? I assumed that if the simulator is not ready to simulate/show values for BB and stress, it should at least show zero and not throw an error about not finding the getBodyBatteryHistory class.

  • Here is the code i am using for Body Battery

    Since i am blocked from showing Code, i will copy it below ...

                   // Get Body Battery Data             

                   function getBodyBatIterator() {

                       if ((Toybox has :SensorHistory) && (Toybox.SensorHistory has :getBodyBatteryHistory)) {

                           return Toybox.SensorHistory.getBodyBatteryHistory({});

                       }

                       return null;

                   }

                  

                       // Update the view

        function onUpdate(dc as Dc) as Void {

       

                                                 // Show Body Battery

                                                 sensorIter = getBodyBatIterator();

                                                 dc.setColor(Gfx.COLOR_BLUE,Gfx.COLOR_BLACK);

                                                 dc.drawText(358,55,myfontIQicons,"}",Gfx.TEXT_JUSTIFY_RIGHT);              

                                                 if (sensorIter != null) {

                                                                dc.setColor(Gfx.COLOR_GREEN,Gfx.COLOR_BLACK);

                                                                dc.drawText(320,55,myfont48,Lang.format("$1$",[sensorIter.next().data.format("%02d")]),Gfx.TEXT_JUSTIFY_RIGHT);

                                                 }

  • Thanks for sharing that ! However, still getting the symbol not found error on the simulator, even with a code that was adjusted to look very similar to yours... so I'll wait a bit more until the next beta (or final SDK version) is released to test BB and Stress.

    One thing I noticed is that you're using SensorHistory instead of ActivityMonitor, the later being what I found on the API docs from beta SDK. Since you've mentioned the data not corresponding to the default Garmin widgets, then maybe you could give the ActivityMonitor a try to see if it improves the accuracy?

  • So far i have been unable to get Stress info using ActivityMonitor. I get a "Could not find symbol 'stress' error.

  • This is what Garmin wrote on the SDK 4.1 beta API docs:

    using Toybox.ActivityMonitor;
    using Toybox.System;
    
    // get a StressHistoryIterator object
    var stressIterator = ActivityMonitor.getStressHistory();
    var sample = stressIterator.next();                        // get the stress data
    
    while (sample != null) {
        System.println("Sample: " + sample.stressData);        // print the current sample
        sample = stressIterator.next();
    }

    You don't necessarily need the while and next should work just fine, but not working for me either way.