Skip to content

Commit

Permalink
Fix two bugs related to average power and remaining distance, null va… (
Browse files Browse the repository at this point in the history
#35)

* Fix two bugs related to average power and remaining distance, null values not properly handled

* Add the fenix 7 + Epix + Venu2 Plus, and display a fraction of miles instead of yards

* Use the proper CIQ version cache and fix the build process for new devices

Co-authored-by: Samuel Dumont <samuel@dataroots.io>
  • Loading branch information
sam-dumont and Samuel Dumont authored Feb 7, 2022
1 parent ee4b9e8 commit 73d84bf
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 89 deletions.
23 changes: 14 additions & 9 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
release:
types: [published]

env:
CIQ_VERSION: 4.0.9

jobs:
install-connect-iq:
name: "Install ConnectIQ"
Expand All @@ -24,18 +27,18 @@ jobs:
id: ciq
with:
path: /opt/ciq
key: ciq-${{ hashFiles('manifest.xml') }}
key: ciq-${{ env.CIQ_VERSION }}-${{ hashFiles('manifest.xml') }}

- uses: actions/cache@v2
id: devices
with:
path: ~/.Garmin/ConnectIQ
key: devices-${{ hashFiles('manifest.xml') }}
key: devices-${{ env.CIQ_VERSION }}-${{ hashFiles('manifest.xml') }}

- run: |
sudo apt-get install --reinstall unzip wget git ssh tar gzip ca-certificates
cd /opt;
wget -q https://developer.garmin.com/downloads/connect-iq/sdks/connectiq-sdk-lin-4.0.3-2021-06-01-b7cc78017.zip -O ciq.zip;
wget -q https://developer.garmin.com/downloads/connect-iq/sdks/connectiq-sdk-lin-${{ env.CIQ_VERSION }}-2022-01-24-2154651d3.zip -O ciq.zip;
unzip ciq.zip -d ciq;
rm -f ciq.zip;
if: steps.ciq.outputs.cache-hit != 'true'
Expand All @@ -59,7 +62,7 @@ jobs:
- uses: actions/setup-java@v2
with:
distribution: "adopt" # See 'Supported distributions' for available options
java-version: "8"
java-version: "16"
- uses: actions/setup-python@v2
with:
python-version: "3.x"
Expand All @@ -68,13 +71,13 @@ jobs:
id: ciq
with:
path: /opt/ciq
key: ciq-${{ hashFiles('manifest.xml') }}
key: ciq-${{ env.CIQ_VERSION }}-${{ hashFiles('manifest.xml') }}

- uses: actions/cache@v2
id: devices
with:
path: ~/.Garmin/ConnectIQ
key: devices-${{ hashFiles('manifest.xml') }}
key: devices-${{ env.CIQ_VERSION }}-${{ hashFiles('manifest.xml') }}

- run: |
sed -i "s/0.0.0/${{ github.event.release.tag_name }}/g" manifest.xml
Expand All @@ -97,8 +100,9 @@ jobs:
- run: |
echo /opt/ciq/bin >> $GITHUB_PATH
echo "$CIQ_DEV_KEY" | base64 -d > /tmp/dev.key
java -Xms1g -Dfile.encoding=UTF-8 -Dapple.awt.UIElement=true -jar /opt/ciq/bin/monkeybrains.jar -v
for i in $(grep "product id=" manifest.xml | cut -d \" -f2); do
if [[ "$i" =~ ^(venu2|venu2s)$ ]]; then
if [[ "$i" =~ ^(venu2|venu2s|venu2plus|fenix7|fenix7s|fenix7x|epix2)$ ]]; then
export SDK=4.0.0
elif [[ "$i" =~ ^(approachs60)$ ]]; then
export SDK=2.4.0
Expand All @@ -109,9 +113,10 @@ jobs:
else
export SDK=3.2.0
fi
java -Dfile.encoding=UTF-8 -Dapple.awt.UIElement=true -jar /opt/ciq/bin/monkeybrains.jar -o /tmp/RunPowerWorkout-$i.prg -w -y /tmp/dev.key -d $i -c $SDK -f monkey.jungle
echo "BUILDING $i with sdk $SDK"
java -jar /opt/ciq/bin/monkeybrains.jar -o /tmp/RunPowerWorkout-$i.prg -w -y /tmp/dev.key -d $i -c $SDK -f monkey.jungle || true
done
java -Dfile.encoding=UTF-8 -Dapple.awt.UIElement=true -jar /opt/ciq/bin/monkeybrains.jar -o /tmp/RunPowerWorkout.iq -e -w -y /tmp/dev.key -r -f monkey.jungle;
java -jar /opt/ciq/bin/monkeybrains.jar -o /tmp/RunPowerWorkout.iq -e -w -y /tmp/dev.key -r -f monkey.jungle
name: Build IQ file
env:
CIQ_DEV_KEY: ${{ secrets.CIQ_DEVELOPER_KEY }}
Expand Down
20 changes: 0 additions & 20 deletions .vscode/launch.json

This file was deleted.

119 changes: 62 additions & 57 deletions manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,73 @@
<iq:manifest xmlns:iq="http://www.garmin.com/xml/connectiq" version="3">
<iq:application entry="RunPowerWorkoutApp" id="4fa3fd29424b46819c4f4d4229cf8051" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="2.0.0" name="@Strings.AppName" type="datafield" version="0.0.0">
<iq:products>
<iq:product id="approachs60" />
<iq:product id="approachs62" />
<iq:product id="d2air" />
<iq:product id="d2charlie" />
<iq:product id="d2delta" />
<iq:product id="d2deltapx" />
<iq:product id="d2deltas" />
<iq:product id="descentmk1" />
<iq:product id="descentmk2s" />
<iq:product id="fenix5" />
<iq:product id="fenix5plus" />
<iq:product id="fenix5s" />
<iq:product id="fenix5splus" />
<iq:product id="fenix5x" />
<iq:product id="fenix5xplus" />
<iq:product id="fr55" />
<iq:product id="fr645" />
<iq:product id="fr645m" />
<iq:product id="fr745" />
<iq:product id="fr935" />
<iq:product id="fr945lte" />
<iq:product id="venu2" />
<iq:product id="venu2s" />
<iq:product id="vivoactive3" />
<iq:product id="vivoactive3d" />
<iq:product id="vivoactive3m" />
<iq:product id="vivoactive3mlte" />
<iq:product id="vivoactive4s" />
<iq:product id="vivoactive4" />
<iq:product id="fenix6xpro" />
<iq:product id="fenix6spro" />
<iq:product id="fenix6s" />
<iq:product id="fenix6pro" />
<iq:product id="fenix6" />
<iq:product id="venud" />
<iq:product id="venu" />
<iq:product id="legacysagarey" />
<iq:product id="marqgolfer" />
<iq:product id="marqexpedition" />
<iq:product id="marqaviator" />
<iq:product id="marqdriver" />
<iq:product id="marqcommander" />
<iq:product id="marqathlete" />
<iq:product id="marqadventurer" />
<iq:product id="marqcaptain" />
<iq:product id="fr945" />
<iq:product id="fr245m" />
<iq:product id="fr245" />
<iq:product id="legacyherofirstavenger" />
<iq:product id="enduro" />
<iq:product id="descentmk2" />
<iq:product id="legacysagadarthvader" />
<iq:product id="legacyherocaptainmarvel" />
<iq:product id="approachs60"/>
<iq:product id="approachs62"/>
<iq:product id="legacyherocaptainmarvel"/>
<iq:product id="d2air"/>
<iq:product id="d2charlie"/>
<iq:product id="d2delta"/>
<iq:product id="d2deltapx"/>
<iq:product id="d2deltas"/>
<iq:product id="legacysagadarthvader"/>
<iq:product id="descentmk1"/>
<iq:product id="descentmk2"/>
<iq:product id="descentmk2s"/>
<iq:product id="enduro"/>
<iq:product id="epix2"/>
<iq:product id="fenix5"/>
<iq:product id="fenix5plus"/>
<iq:product id="fenix5s"/>
<iq:product id="fenix5splus"/>
<iq:product id="fenix5x"/>
<iq:product id="fenix5xplus"/>
<iq:product id="fenix6"/>
<iq:product id="fenix6pro"/>
<iq:product id="fenix6s"/>
<iq:product id="fenix6spro"/>
<iq:product id="fenix6xpro"/>
<iq:product id="fenix7"/>
<iq:product id="fenix7s"/>
<iq:product id="fenix7x"/>
<iq:product id="legacyherofirstavenger"/>
<iq:product id="fr55"/>
<iq:product id="fr245"/>
<iq:product id="fr245m"/>
<iq:product id="fr645"/>
<iq:product id="fr645m"/>
<iq:product id="fr745"/>
<iq:product id="fr935"/>
<iq:product id="fr945"/>
<iq:product id="fr945lte"/>
<iq:product id="marqadventurer"/>
<iq:product id="marqathlete"/>
<iq:product id="marqaviator"/>
<iq:product id="marqcaptain"/>
<iq:product id="marqcommander"/>
<iq:product id="marqdriver"/>
<iq:product id="marqexpedition"/>
<iq:product id="marqgolfer"/>
<iq:product id="legacysagarey"/>
<iq:product id="venu"/>
<iq:product id="venu2"/>
<iq:product id="venu2plus"/>
<iq:product id="venu2s"/>
<iq:product id="venud"/>
<iq:product id="vivoactive3"/>
<iq:product id="vivoactive3d"/>
<iq:product id="vivoactive3m"/>
<iq:product id="vivoactive3mlte"/>
<iq:product id="vivoactive4"/>
<iq:product id="vivoactive4s"/>
</iq:products>
<iq:permissions>
<iq:uses-permission id="Ant" />
<iq:uses-permission id="DataFieldAlert" />
<iq:uses-permission id="UserProfile" />
<iq:uses-permission id="Ant"/>
<iq:uses-permission id="DataFieldAlert"/>
<iq:uses-permission id="UserProfile"/>
</iq:permissions>
<iq:languages>
<iq:language>eng</iq:language>
</iq:languages>
<iq:barrels />
<iq:barrels/>
</iq:application>
</iq:manifest>
11 changes: 11 additions & 0 deletions monkey.jungle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ legacysagarey.sourcePath = source;source-ant
venu.sourcePath = source;source-ant
venud.sourcePath = source;source-ant
venu2.sourcePath = source;source-ant
venu2plus.sourcePath = source;source-ant
venu2s.sourcePath = source;source-ant
vivoactive3.sourcePath = source;source-ant
vivoactive3d.sourcePath = source;source-ant
Expand All @@ -40,6 +41,7 @@ descentmk1.resourcePath = resources-highmem;resources-hm-240;resources;resources
descentmk2.resourcePath = resources-highmem;resources-hm-280;resources
descentmk2s.resourcePath = resources-highmem;resources-hm-240;resources
enduro.resourcePath = resources;resources-lowmem
epix2.resourcePath = resources;resources-60x60;resources-highmem;resources-hm-416
fenix5.resourcePath = resources-lowmem;resources-noworkout;resources
fenix5plus.resourcePath = resources-highmem;resources-hm-240;resources
fenix5s.resourcePath = resources;resources-lowmem;resources-36x36;resources-noworkout
Expand All @@ -51,6 +53,9 @@ fenix6pro.resourcePath = resources-highmem;resources-hm-260;resources
fenix6s.resourcePath = resources;resources-lowmem
fenix6spro.resourcePath = resources-highmem;resources-hm-240;resources
fenix6xpro.resourcePath = resources-highmem;resources-hm-280;resources
fenix7.resourcePath = resources-highmem;resources-hm-260;resources
fenix7s.resourcePath = resources-highmem;resources-hm-240;resources
fenix7x.resourcePath = resources-highmem;resources-hm-280;resources
fr245.resourcePath = resources-lowmem;resources-ant;resources
fr245m.resourcePath = resources-ant;resources-highmem;resources-hm-240;resources
fr55.resourcePath = resources-lowmem;resources-35x35;resources
Expand All @@ -75,6 +80,7 @@ marqgolfer.resourcePath = resources-highmem;resources-hm-240;resources
venu.resourcePath = resources;resources-60x60;resources-lowmem;resources-ant
venud.resourcePath = resources;resources-60x60;resources-lowmem;resources-ant
venu2.resourcePath = resources;resources-70x70;resources-highmem;resources-hm-416
venu2plus.resourcePath = resources;resources-70x70;resources-highmem;resources-hm-360
venu2s.resourcePath = resources;resources-61x61;resources-highmem;resources-hm-360
vivoactive3.resourcePath = resources;resources-40x33;resources-ant;resources-noworkout;resources-lowmem
vivoactive3d.resourcePath = resources;resources-40x33;resources-ant;resources-noworkout;resources-lowmem
Expand Down Expand Up @@ -117,6 +123,7 @@ descentmk1.excludeAnnotations = $(descentmk1.excludeAnnotations);$(high_mem_excl
descentmk2.excludeAnnotations = $(descentmk2.excludeAnnotations);$(high_mem_excludes);ant;noworkout
descentmk2s.excludeAnnotations = $(descentmk2s.excludeAnnotations);$(high_mem_excludes);ant;noworkout
enduro.excludeAnnotations = $(enduro.excludeAnnotations);$(low_mem_excludes);ant;noworkout
epix2.excludeAnnotations = $(epix2.excludeAnnotations);$(high_mem_excludes);ant;noworkout
fenix5.excludeAnnotations = $(fenix5.excludeAnnotations);$(low_mem_excludes);ant;workout
fenix5plus.excludeAnnotations = $(fenix5plus.excludeAnnotations);$(high_mem_excludes);ant;noworkout
fenix5s.excludeAnnotations = $(fenix5s.excludeAnnotations);$(low_mem_excludes);ant;workout
Expand All @@ -128,6 +135,9 @@ fenix6pro.excludeAnnotations = $(fenix6pro.excludeAnnotations);$(high_mem_exclud
fenix6s.excludeAnnotations = $(fenix6s.excludeAnnotations);$(low_mem_excludes);ant;noworkout
fenix6spro.excludeAnnotations = $(fenix6spro.excludeAnnotations);$(high_mem_excludes);ant;noworkout
fenix6xpro.excludeAnnotations = $(fenix6xpro.excludeAnnotations);$(high_mem_excludes);ant;noworkout
fenix7.excludeAnnotations = $(fenix7.excludeAnnotations);$(high_mem_excludes);ant;noworkout
fenix7s.excludeAnnotations = $(fenix7s.excludeAnnotations);$(high_mem_excludes);ant;noworkout
fenix7x.excludeAnnotations = $(fenix7x.excludeAnnotations);$(high_mem_excludes);ant;noworkout
fr245.excludeAnnotations = $(fr245.excludeAnnotations);$(low_mem_excludes);noant;noworkout
fr245m.excludeAnnotations = $(fr245m.excludeAnnotations);$(high_mem_excludes);noant;noworkout
fr55.excludeAnnotations = $(fr55.excludeAnnotations);$(low_mem_low_excludes);noant;noworkout
Expand All @@ -152,6 +162,7 @@ marqgolfer.excludeAnnotations = $(marqgolfer.excludeAnnotations);$(high_mem_excl
venu.excludeAnnotations = $(venu.excludeAnnotations);$(low_mem_large_excludes);noant;noworkout
venud.excludeAnnotations = $(venud.excludeAnnotations);$(low_mem_large_excludes);noant;noworkout
venu2.excludeAnnotations = $(venu2.excludeAnnotations);$(high_mem_excludes);noant;noworkout
venu2plus.excludeAnnotations = $(venu2plus.excludeAnnotations);$(high_mem_excludes);noant;noworkout
venu2s.excludeAnnotations = $(venu2s.excludeAnnotations);$(high_mem_excludes);noant;noworkout
vivoactive3.excludeAnnotations = $(vivoactive3.excludeAnnotations);$(low_mem_excludes);noant;workout
vivoactive3d.excludeAnnotations = $(vivoactive3d.excludeAnnotations);$(low_mem_excludes);noant;workout
Expand Down
4 changes: 2 additions & 2 deletions source/RunPowerWorkoutView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ class RunPowerWorkoutView extends WatchUi.DataField {
workout.step.durationType == 1) {

stepType = (targetHigh > 0 && targetLow > 0) ? 1 : 98;
if (workout.step.durationValue != null && remainingDistance >= 0) {
if (workout.step.durationValue != null && elapsedDistance != null && remainingDistance >= 0) {
remainingDistance = workout.step.durationValue -
(elapsedDistance.toNumber() -
stepStartDistance);
Expand Down Expand Up @@ -673,7 +673,7 @@ class RunPowerWorkoutView extends WatchUi.DataField {

if (avgPower == 0) {
avgPower = currentPower;
} else if (lapTime != 0) {
} else if (timer != 0) {
avgPower = (((avgPower * (timer - 1)) + currentPower) / (timer * 1.0));
}

Expand Down
2 changes: 1 addition & 1 deletion source/Utils.mc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Utils {
smallunit = "YD";
}

if ((distance / factor) >= 1) {
if ((distance / factor) >= 1 || !useMetric) {
var formatted = ((distance * 1.0) / (factor * 1.0)).format("%.2f");
var index = formatted.find(".");
if (index != null && showSmallDecimals) {
Expand Down

0 comments on commit 73d84bf

Please sign in to comment.