Data field is active even without activity

Hello,

I made a SimpleDataField for my Vivoactive 4 which detects few conditions (like speed too high) and vibrates to warn me. I put it to Walk activity. But my problem now is that it activates even when I don't launch the activity.

E.g. I walk for few minutes and then drive a car and watch (usually) go crazy vibrating like my speed is too high for a minute or two, then it stops.

I have auto activity enabled, but set it to 10 minutes and this happens even if I walk for only like 3 minutes. If I disable auto activity, it probably doesn't happens (I tried it only two times).

Main code of my SimpleDataField is basically this:

//This is just pseudocode
function compute(info)
{
	//every 10 seconds
	if ((info.timerTime/1000)%10==0)
	{
	    //speed too high
		if (info.currentSpeed*3.6 > 30)
		{
			Attention.vibrate(vibrator);
		} 

		// ... other warnings
	}
	return new Time.Duration(info.timerTime/1000);
}

Is this normal behaviour? And is there a way to prevent my watch acting like this, like checking some variable to determine it runs in background as auto activity or something?

Thanks for replies!

Top Replies

All Replies

  • TL;DR try creating a custom activity that's a copy of Walk and only using your custom data field there.

    I have auto activity enabled, but set it to 10 minutes and this happens even if I walk for only like 3 minutes.

    My guess is that the auto activity feature "invisibly" starts "in the background" as soon as it detects an activity (like within a few seconds or so), but it will only "finalize" an auto activity that lasts at least 10 minutes.

    Otherwise, if it waited 10 minutes to actually start the activity, there'd be no way of retroactively gathering and writing all the data it would have if you started it manually. This has the unfortunate consequence of running your data field when you don't want it to.

    In other words, every walk that's less than 10 minutes probably creates a temporary auto activity which is never saved, but nonetheless, all the same stuff happens during the activity that would normally happen for an auto activity of 10 minutes or longer, such as running CIQ data fields (CIQ data fields can write to the FIT file and save data to storage, so it makes sense to run them even if the user can't see what they would normally display.)

    Seems like you could work around this by creating a custom activity that's a copy of Walk, adding your CIQ data field to the custom activity and removing it from the built-in Walk activity. The built-in Walk activity is probably what's used for auto activities, and you can use the custom activity when you want to start a walk manually and use your data field.

    There won't be any impact on your activities in Connect - they'll be categorized and named just like the built-in walk activity (unless your Activity Name preference is set to "Location & Device Activity Name").

  • another way is to move the vibration code from compute to onUpdate

  • Thanks, that's a workaround I was thinking about too, but just wanted to confirm I haven't missed some variable to circumvent this programmatically.

  • Unfortunately, there isn't onUpdate in SimpleDataField.