function compute(info) {
if (info != null and info has :offCourseDistance) {
if (info.offCourseDistance == null) {
return "null";
} else {
return info.offCourseDistance;
}
} else {
return "-";
}
Next, I have uploaded a course on my Garmin Edge 1030, and started riding it. The Off Course Warnings setting on the Edge is off.
While I am not riding off course, the simple data field shows null (which indicates that info.offCoursedistance is null).
When I am riding deliberately off course, the simple data field still shows null. At the same time the native data field Dist. to Next, however, shows the distance between my current location and the nearest point on the course. (This behavior of this native data field is not documented, but from experience I have learned that this is the case.) Therefore, the Edge has detected that I am indeed off course.
When I repeat this test with the Off Course Warnings setting switched on, info.offCoursedistance is still null when I am not riding off course, but some value is showing in my simple data field when I ride off course. This value, however, is sometimes null, and sometimes a numeric value, but never a value that is equal to the value in the native data field Dist. to Next.
This is not at all what I expected. I would expect info.offCoursedistance to have the following value:
- null when I am not riding a course
- 0 when I am riding a course, and I am not off course
- The same value shown in native data field Dist. to Next when I am riding a course and I am off course
I would expect these values to be independent from the Off Course Warnings setting. Specifically, if Off Course Warnings is off, info.offCoursedistance should still have a value when I am riding off course. Switching on Off Course Warnings has undesired side effects (buzzes, pop-ups). And what is more, there is no way in Connect IQ to check the value of the Off Course Warnings setting.
Some additional information:
- Garmin Edge 1030, firmware version 3.90
- Code sample created with Eclipse IDE for Java Developers Version: Oxygen.3a Release (4.7.3a) and Connect IQ SDK 3.0.7