Skip to content

Commit

Permalink
Added the following fields: Lap Time, Lap Distance, Lap Pace
Browse files Browse the repository at this point in the history
  • Loading branch information
GCorm authored and GCorm committed Dec 18, 2018
1 parent 7cb8638 commit b9d1043
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 8 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Configurable Garmin Watch datafield
![GRun Cover Image](/doc/GRunWatch.png)

## Release Notes
### Version 1.14
- Added the following fields: Lap Time, Lap Distance, Lap Pace

### Version 1.13
- Adjust font vertical position for fenix 5s and fenix chronos

### Version 1.11
- Area 4 and 6 expand vertically: If values 4A/4B or 5 are missing, area 4A/4B or 5 will expand vertically
- ETA Auto-Switch: If one area is configured with "ETA 5K" and you reach 5 km during your run. the value will automatically change to "ETA 10K", then "ETA 21K", then "ETA 42K". Same apply to "ETA 10K" and "ETA 21K".
Expand Down
2 changes: 1 addition & 1 deletion resources/settings/properties.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<properties>
<property id="AppVersion" type="string">1.13</property>
<property id="AppVersion" type="string">1.14</property>
<property id="HeaderPosition" type="number">1</property>
<property id="MinPace" type="number">315</property>
<property id="MaxPace" type="number">345</property>
Expand Down
30 changes: 30 additions & 0 deletions resources/settings/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
<listEntry value="22">@Strings.Field22</listEntry>
<listEntry value="23">@Strings.Field23</listEntry>
<listEntry value="24">@Strings.Field24</listEntry>
<listEntry value="25">@Strings.Field25</listEntry>
<listEntry value="26">@Strings.Field26</listEntry>
<listEntry value="27">@Strings.Field27</listEntry>
</settingConfig>
</setting>

Expand Down Expand Up @@ -80,6 +83,9 @@
<listEntry value="22">@Strings.Field22</listEntry>
<listEntry value="23">@Strings.Field23</listEntry>
<listEntry value="24">@Strings.Field24</listEntry>
<listEntry value="25">@Strings.Field25</listEntry>
<listEntry value="26">@Strings.Field26</listEntry>
<listEntry value="27">@Strings.Field27</listEntry>
</settingConfig>
</setting>

Expand Down Expand Up @@ -110,6 +116,9 @@
<listEntry value="22">@Strings.Field22</listEntry>
<listEntry value="23">@Strings.Field23</listEntry>
<listEntry value="24">@Strings.Field24</listEntry>
<listEntry value="25">@Strings.Field25</listEntry>
<listEntry value="26">@Strings.Field26</listEntry>
<listEntry value="27">@Strings.Field27</listEntry>
</settingConfig>
</setting>

Expand Down Expand Up @@ -140,6 +149,9 @@
<listEntry value="22">@Strings.Field22</listEntry>
<listEntry value="23">@Strings.Field23</listEntry>
<listEntry value="24">@Strings.Field24</listEntry>
<listEntry value="25">@Strings.Field25</listEntry>
<listEntry value="26">@Strings.Field26</listEntry>
<listEntry value="27">@Strings.Field27</listEntry>
</settingConfig>
</setting>

Expand Down Expand Up @@ -170,6 +182,9 @@
<listEntry value="22">@Strings.Field22</listEntry>
<listEntry value="23">@Strings.Field23</listEntry>
<listEntry value="24">@Strings.Field24</listEntry>
<listEntry value="25">@Strings.Field25</listEntry>
<listEntry value="26">@Strings.Field26</listEntry>
<listEntry value="27">@Strings.Field27</listEntry>
</settingConfig>
</setting>

Expand Down Expand Up @@ -200,6 +215,9 @@
<listEntry value="22">@Strings.Field22</listEntry>
<listEntry value="23">@Strings.Field23</listEntry>
<listEntry value="24">@Strings.Field24</listEntry>
<listEntry value="25">@Strings.Field25</listEntry>
<listEntry value="26">@Strings.Field26</listEntry>
<listEntry value="27">@Strings.Field27</listEntry>
</settingConfig>
</setting>

Expand Down Expand Up @@ -230,6 +248,9 @@
<listEntry value="22">@Strings.Field22</listEntry>
<listEntry value="23">@Strings.Field23</listEntry>
<listEntry value="24">@Strings.Field24</listEntry>
<listEntry value="25">@Strings.Field25</listEntry>
<listEntry value="26">@Strings.Field26</listEntry>
<listEntry value="27">@Strings.Field27</listEntry>
</settingConfig>
</setting>

Expand Down Expand Up @@ -260,6 +281,9 @@
<listEntry value="22">@Strings.Field22</listEntry>
<listEntry value="23">@Strings.Field23</listEntry>
<listEntry value="24">@Strings.Field24</listEntry>
<listEntry value="25">@Strings.Field25</listEntry>
<listEntry value="26">@Strings.Field26</listEntry>
<listEntry value="27">@Strings.Field27</listEntry>
</settingConfig>
</setting>

Expand Down Expand Up @@ -290,6 +314,9 @@
<listEntry value="22">@Strings.Field22</listEntry>
<listEntry value="23">@Strings.Field23</listEntry>
<listEntry value="24">@Strings.Field24</listEntry>
<listEntry value="25">@Strings.Field25</listEntry>
<listEntry value="26">@Strings.Field26</listEntry>
<listEntry value="27">@Strings.Field27</listEntry>
</settingConfig>
</setting>

Expand Down Expand Up @@ -320,6 +347,9 @@
<listEntry value="22">@Strings.Field22</listEntry>
<listEntry value="23">@Strings.Field23</listEntry>
<listEntry value="24">@Strings.Field24</listEntry>
<listEntry value="25">@Strings.Field25</listEntry>
<listEntry value="26">@Strings.Field26</listEntry>
<listEntry value="27">@Strings.Field27</listEntry>
</settingConfig>
</setting>

Expand Down
5 changes: 4 additions & 1 deletion resources/strings/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<string id="Field08">Current Speed</string>
<string id="Field09">Average Heart Rate</string>
<string id="Field10">Average Pace</string>
<string id="Field11">Average Pace (Calculated mnually using timer/distance)</string>
<string id="Field11">Average Pace (Calculated manually using timer/distance)</string>
<string id="Field12">Average Speed</string>
<string id="Field13">Calories</string>
<string id="Field14">Current Cadence</string>
Expand All @@ -38,6 +38,9 @@
<string id="Field22">ETA 10K</string>
<string id="Field23">ETA Half Marathon (21.075.5 km)</string>
<string id="Field24">ETA Marathon (42.195 km)</string>
<string id="Field25">Lap Time</string>
<string id="Field26">Lap Distance</string>
<string id="Field27">Lap Pace</string>

<string id="PARAM_AREA1">Field 1</string>
<string id="PARAM_AREA2">Field 2A</string>
Expand Down
76 changes: 70 additions & 6 deletions source/GRunView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ class GRunView extends WatchUi.DataField
private var avgSpeed = 0;
// Integer indicating the current km or mile. For example, if the distance currently traveled is 3.25 km, the variable will be equal to 3.
private var currentKM = 0;
// Time taken on current km/mile
private var timerCurrentKM = 0;
// Time taken on previous km or mile
private var timerLastKM = 0;
// Exact time when "currentKM" was last changed
private var startTimerCurrentKM = 0;
// Distance reset every km or mile
private var distanceOnCurrentKM = 0;

// Exact time when lap has changed
private var startTimerCurrentLap = 0;
// Exact distance when lap has changed
private var startDistanceCurrentLap = 0;

// Display data in Metric or Imperial
private var isPaceUnitsImperial;
private var isDistanceUnitsImperial;
Expand Down Expand Up @@ -111,7 +114,10 @@ class GRunView extends WatchUi.DataField
OPTION_ETA_5K = 21,
OPTION_ETA_10K = 22,
OPTION_ETA_HALF_MARATHON = 23,
OPTION_ETA_MARATHON = 24
OPTION_ETA_MARATHON = 24,
OPTION_CURRENT_LAP_TIME = 25,
OPTION_CURRENT_LAP_DISTANCE = 26,
OPTION_CURRENT_LAP_PACE = 27
/*
OPTION_AMBIENT_PRESSURE = 25,
OPTION_AVERAGE_CADENCE = 26,
Expand Down Expand Up @@ -347,6 +353,15 @@ class GRunView extends WatchUi.DataField
case OPTION_ETA_MARATHON:
return "OPTION_ETA_MARATHON";
case OPTION_CURRENT_LAP_TIME:
return "OPTION_CURRENT_LAP_TIME";
case OPTION_CURRENT_LAP_DISTANCE:
return "OPTION_CURRENT_LAP_DISTANCE";
case OPTION_CURRENT_LAP_PACE:
return "OPTION_CURRENT_LAP_PACE";
}
}
*/
Expand Down Expand Up @@ -412,6 +427,9 @@ class GRunView extends WatchUi.DataField
// - OPTION_ETA_10K = 22
// - OPTION_ETA_HALF_MARATHON = 23
// - OPTION_ETA_MARATHON = 24
// - OPTION_CURRENT_LAP_TIME = 25
// - OPTION_CURRENT_LAP_DISTANCE = 26
// - OPTION_CURRENT_LAP_PACE = 27
v1 = getParameter("Area1", OPTION_CURRENT_HEART_RATE);
v2 = getParameter("Area2", OPTION_TIMER_TIME_ON_PREVIOUS_KM_OR_MILE);
v3 = getParameter("Area3", OPTION_CURRENT_CADENCE);
Expand All @@ -422,7 +440,7 @@ class GRunView extends WatchUi.DataField
v8 = getParameter("Area8", OPTION_TIMER_TIME);
v9 = getParameter("Area9", OPTION_CURRENT_TIME);
v10 = getParameter("Area10", OPTION_CURRENT_LOCATION_ACCURACY_AND_BATTERY);

hrZones = UserProfile.getHeartRateZones(UserProfile.HR_ZONE_SPORT_RUNNING);
deviceModel = WatchUi.loadResource(Rez.Strings.DeviceModel);
deviceWidth = deviceSettings.screenWidth;
Expand Down Expand Up @@ -655,6 +673,20 @@ class GRunView extends WatchUi.DataField
{
}

// A lap event has occurred.
// This method is called when a lap is added to the current activity. A notification is triggered after the lap record has been written to the FIT file.
function onTimerLap()
{
startTimerCurrentLap = timer;
startDistanceCurrentLap = distance;
}


function onWorkoutStepComplete()
{
onTimerLap();
}


function configureID(id, selectedOption)
{
Expand Down Expand Up @@ -770,7 +802,6 @@ class GRunView extends WatchUi.DataField
}

distanceOnCurrentKM = distance - Math.floor(distance);
timerCurrentKM = timer - startTimerCurrentKM;
}

// Time taken on previous km or mile
Expand All @@ -782,7 +813,29 @@ class GRunView extends WatchUi.DataField
// Elapsed time for the current km or mile
if (value == OPTION_TIMER_TIME_ON_CURRENT_KM_OR_MILE)
{
return timerCurrentKM;
return (timer - startTimerCurrentKM);
}

// Elapsed time for the current lap
if (value == OPTION_CURRENT_LAP_TIME)
{
return (timer - startTimerCurrentLap);
}

// Elapsed distance for the current lap
if (value == OPTION_CURRENT_LAP_DISTANCE)
{
return (distance - startDistanceCurrentLap);
}

// Average Pace for the current lap
if (value == OPTION_CURRENT_LAP_PACE)
{
var lapTimer = timer - startTimerCurrentLap;
var lapDistance = distance - startDistanceCurrentLap;

if (lapDistance <= 0) { return 0; }
return lapTimer.toFloat() / lapDistance;
}

// Current altitude in meters (m)
Expand Down Expand Up @@ -1481,6 +1534,15 @@ class GRunView extends WatchUi.DataField

case OPTION_TIMER_TIME_ON_CURRENT_KM_OR_MILE:
return (isDistanceUnitsImperial == true) ? "CUR MI" : "CUR KM";

case OPTION_CURRENT_LAP_TIME:
return "LAP TIME";

case OPTION_CURRENT_LAP_DISTANCE:
return "LAP DIST";

case OPTION_CURRENT_LAP_PACE:
return "LAP PACE";

case OPTION_TOTAL_ASCENT:
return "ASCENT";
Expand Down Expand Up @@ -1533,13 +1595,15 @@ class GRunView extends WatchUi.DataField
case OPTION_AVERAGE_PACE_MANUAL_CALC:
case OPTION_TIMER_TIME_ON_PREVIOUS_KM_OR_MILE:
case OPTION_TIMER_TIME_ON_CURRENT_KM_OR_MILE:
case OPTION_CURRENT_LAP_PACE:
return formatDuration(value, false);

case OPTION_TIMER_TIME:
case OPTION_ETA_5K:
case OPTION_ETA_10K:
case OPTION_ETA_HALF_MARATHON:
case OPTION_ETA_MARATHON:
case OPTION_CURRENT_LAP_TIME:
return formatDuration(value, true);

case OPTION_CURRENT_TIME:
Expand Down

0 comments on commit b9d1043

Please sign in to comment.