Skip to content

Instantly share code, notes, and snippets.

@rasor
Last active July 3, 2016 19:36
Show Gist options
  • Save rasor/0b326fb2ad208029f036544df9e1b21c to your computer and use it in GitHub Desktop.
Save rasor/0b326fb2ad208029f036544df9e1b21c to your computer and use it in GitHub Desktop.
Suunto app. Name: BeeDistance From Start, Activity: Running, Category: Competion
/* http://www.movescount.com/apps/app11024800-BeeDistance_From_Start */
/* https://gist.github.com/rasor/0b326fb2ad208029f036544df9e1b21c */
/* Suunto app. Name: BeeDistance From Start, Activity: Running, Category: Competion*/
/* Description: Calculates Beeline distance to your start GPS point.*/
/* Initialize own vars - set in app
prefix = "BDist";
postfix = "m";
timerHasBeenStarted = 0;
startHasBeenSet = 0;
latStart = -90;
lonStart = -180;
lapStartDistanceBeeline = 0; //m. How far is it to start - beeline?
*/
/* While in sport mode do this once per second*/
if (timerHasBeenStarted == 0) {
/* check if timer has been started*/
if ((SUUNTO_DURATION > 0)){ /* || (SUUNTO_DISTANCE > 0)) {*/
timerHasBeenStarted = 1;
/* set some constants */
/* get start position if not read, yet */
if ((startHasBeenSet == 0) && (SUUNTO_GPS_STATE > 4)) {
latStart = SUUNTO_GPS_LATITUDE;
lonStart = SUUNTO_GPS_LONGITUDE;
startHasBeenSet = 1;
}
}
else{
/* read position continuesly until timerHasBeenStarted. In this way we have the startpos from before 1 sec had passed*/
if (SUUNTO_GPS_STATE > 4) {
latStart = SUUNTO_GPS_LATITUDE;
lonStart = SUUNTO_GPS_LONGITUDE;
startHasBeenSet = 1;
}
}
}
/* only calculate laps, when GPS is on and timer is started */
if ((timerHasBeenStarted == 1) && (SUUNTO_GPS_STATE > 4)) {
/* get start position if not read, yet */
if (startHasBeenSet == 0) {
latStart = SUUNTO_GPS_LATITUDE;
lonStart = SUUNTO_GPS_LONGITUDE;
startHasBeenSet = 1;
}
/* calculate laps - start position is now known */
if (startHasBeenSet == 1) {
/* look for start */
lapStartDistanceBeeline = Suunto.distance(latStart, lonStart, SUUNTO_GPS_LATITUDE, SUUNTO_GPS_LONGITUDE);
}
}
RESULT = lapStartDistanceBeeline;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment