Last active
July 3, 2016 19:36
-
-
Save rasor/0b326fb2ad208029f036544df9e1b21c to your computer and use it in GitHub Desktop.
Suunto app. Name: BeeDistance From Start, Activity: Running, Category: Competion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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