Skip to content

Commit

Permalink
Add sounds alerts (#45)
Browse files Browse the repository at this point in the history
* Adding sounds

* Adding sounds

* Add the newest SDK

* Fix alerts for workouts

Co-authored-by: Samuel Dumont <samuel@dataroots.io>
  • Loading branch information
sam-dumont and Samuel Dumont authored Aug 10, 2022
1 parent faa02f2 commit 1f9b25b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
types: [published]

env:
CIQ_VERSION: 4.1.4
CIQ_VERSION: 4.1.5

jobs:
install-connect-iq:
Expand Down Expand Up @@ -38,7 +38,7 @@ jobs:
- 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.1.4-2022-06-07-f86da2dee.zip -O ciq.zip;
wget -q https://developer.garmin.com/downloads/connect-iq/sdks/connectiq-sdk-lin-4.1.5-2022-08-03-6e17bf167.zip -O ciq.zip;
unzip ciq.zip -d ciq;
rm -f ciq.zip;
if: steps.ciq.outputs.cache-hit != 'true'
Expand Down
2 changes: 1 addition & 1 deletion bin/RunPowerWorkout-settings.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions resources/properties/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<property id="B" type="number">330</property>
<property id="C" type="boolean">true</property>
<property id="D" type="boolean">true</property>
<property id="DD" type="boolean">true</property>
<property id="E" type="number">3</property>
<property id="F" type="number">1</property>
<property id="G" type="number">1</property>
Expand Down
3 changes: 3 additions & 0 deletions resources/settings/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<setting propertyKey="@Properties.D" title="@Strings.VIBRATE">
<settingConfig type="boolean" />
</setting>
<setting propertyKey="@Properties.DD" title="@Strings.SOUNDS">
<settingConfig type="boolean" />
</setting>
<setting propertyKey="@Properties.E" title="@Strings.POWER_AVERAGE">
<settingConfig type="numeric" min="1" max="30" />
</setting>
Expand Down
1 change: 1 addition & 0 deletions resources/strings/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<string id="FTP">What is your FTP/CP?</string>
<string id="ALERT">Display alerts?</string>
<string id="VIBRATE">Vibrate on alerts?</string>
<string id="SOUNDS">Play a sound on alerts?</string>
<string id="POWER_AVERAGE">Power averaging in seconds (1-30)</string>
<string id="SHOW_COLORS">Show Colors in Datafield</string>
<string id="SHOW_COLORS_1">Text + Background</string>
Expand Down
19 changes: 18 additions & 1 deletion source/RunPowerWorkoutView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RunPowerWorkoutView extends WatchUi.DataField {
(:highmem) hidden var etaPower = 0;
(:highmem) hidden var etaSpeed = 0;
(:highmem) hidden var fieldsAlt;
(:highmem) hidden var lapStartDistance;
(:highmem) hidden var lapStartDistance = 0;
(:highmem) hidden var switchAlternativeLayout = 0;
(:highmem) hidden var topMetric;
(:highmem) hidden var totalAscent = 0;
Expand Down Expand Up @@ -68,6 +68,7 @@ class RunPowerWorkoutView extends WatchUi.DataField {
hidden var layout;
hidden var maxAlerts = 3;
hidden var paused = true;
hidden var playSounds;
hidden var powerAverage;
hidden var pwrZones;
hidden var pwrZonesColors;
Expand Down Expand Up @@ -119,6 +120,8 @@ class RunPowerWorkoutView extends WatchUi.DataField {
Utils.replaceNull(Application.getApp().getProperty("C"), true);
vibrate =
Utils.replaceNull(Application.getApp().getProperty("D"), true);
playSounds =
Utils.replaceNull(Application.getApp().getProperty("DD"), true);
powerAverage =
Utils.replaceNull(Application.getApp().getProperty("E"), 3);
showColors =
Expand Down Expand Up @@ -452,6 +455,13 @@ class RunPowerWorkoutView extends WatchUi.DataField {
(currentPower < targetZoneLow || currentPower > targetZoneHigh))) {
if (alertDisplayed == false) {
if (alertCount < maxAlerts) {
if (Attention has :ToneProfile && playSounds) {
if (currentPower > targetZoneHigh){
Attention.playTone(Attention.TONE_ALERT_HI);
} else {
Attention.playTone(Attention.TONE_ALERT_LO);
}
}
if (Attention has :vibrate && vibrate) {
Attention.vibrate([
new Attention.VibeProfile(100, 300),
Expand Down Expand Up @@ -736,6 +746,13 @@ class RunPowerWorkoutView extends WatchUi.DataField {
(currentPower < targetLow || currentPower > targetHigh))) {
if (alertDisplayed == false) {
if (alertCount < maxAlerts) {
if (Attention has :ToneProfile && playSounds) {
if (currentPower > targetHigh){
Attention.playTone(Attention.TONE_ALERT_HI);
} else {
Attention.playTone(Attention.TONE_ALERT_LO);
}
}
if (Attention has :vibrate && vibrate) {
Attention.vibrate([
new Attention.VibeProfile(100, 300),
Expand Down

0 comments on commit 1f9b25b

Please sign in to comment.