Skip to content

Commit

Permalink
4.0.0 Implemented amazing heart rate chart in summary and optimized f…
Browse files Browse the repository at this point in the history
…or all devices screen sizes
  • Loading branch information
dliedke committed Aug 7, 2022
1 parent 4be5478 commit 154d460
Show file tree
Hide file tree
Showing 16 changed files with 260 additions and 91 deletions.
38 changes: 33 additions & 5 deletions HrvAlgorithms/sources/activity/HrActivity.mc
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,44 @@ module HrvAlgorithms {
private const MinHrFieldId = 0;
private var mMinHrField;
private var mMinHr;


//DEBUG - to test the heart rate chart instantaneously, also change min/max HR fixed in class HeartRateGraphView
//1min
//private var mHRHistory = [55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68];

//2min
//private var mHRHistory = [55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68];

//3min
//private var mHRHistory = [55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68];

//5min
//private var mHRHistory = [55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68];

//10min
//private var mHRHistory = [55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68];

//20min
//private var mHRHistory = [55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68,55,55,55,55,56,56,56,56,56,58,58,58,62,62,62,65,65,65,65,70,70,70,70,72,72,72,72,73,73,73,73,74,74,76,76,76,76,78,78,78,78,80,80,78,78,77,77,74,74,72,72,67,67,67,67,68,68,68,68,68];

private var mHRHistory = [];

function refreshActivityStats() {

var activityInfo = Activity.getActivityInfo();
if (activityInfo == null) {
return;
}

if (activityInfo.currentHeartRate != null && (me.mMinHr == null || me.mMinHr > activityInfo.currentHeartRate)) {
me.mMinHr = activityInfo.currentHeartRate;
}
if (me.mFitSession.isRecording()) {

if (activityInfo.currentHeartRate != null && (me.mMinHr == null || me.mMinHr > activityInfo.currentHeartRate)) {
me.mMinHr = activityInfo.currentHeartRate;
}

mHRHistory.add(activityInfo.currentHeartRate);
}

me.onRefreshHrActivityStats(activityInfo, me.mMinHr);
}

Expand All @@ -104,7 +131,8 @@ module HrvAlgorithms {
summary.averageHr = activityInfo.averageHeartRate;
summary.minHr = me.mMinHr;
summary.elapsedTimeSeconds = activityInfo.timerTime / 1000;

summary.hrHistory = me.mHRHistory;

return summary;
}

Expand Down
1 change: 1 addition & 0 deletions HrvAlgorithms/sources/activity/HrSummary.mc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ module HrvAlgorithms {
var averageHr;
var minHr;
var elapsedTimeSeconds;
var hrHistory;
}
}
2 changes: 1 addition & 1 deletion Meditate/manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!-- This is a generated file. It is highly recommended that you DO NOT edit this file. -->
<iq:manifest xmlns:iq="http://www.garmin.com/xml/connectiq" version="3">
<iq:application entry="MeditateApp" id="9abb375dcf7c4ace87ff66f4f773f6c8" launcherIcon="@Drawables.launcherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watch-app" version="3.1.4">
<iq:application entry="MeditateApp" id="9abb375dcf7c4ace87ff66f4f773f6c8" launcherIcon="@Drawables.launcherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watch-app" version="4.0.0">
<iq:products>
<iq:product id="approachs62"/>
<iq:product id="d2air"/>
Expand Down
4 changes: 4 additions & 0 deletions Meditate/resources-round-218x218/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
<property id="sessionDetailsValueXPos" type="number">55</property>
<property id="meditateActivityIconsXPos" type="number">70</property>
<property id="summaryLinesYOffset" type="number">-7</property>
<property id="heartRateChartWidth" type="number">120</property>
<property id="heartRateChartLineExtra" type="number">15</property>
<property id="heartRateChartXPosrelocation" type="number">0</property>
<property id="heartRateChartXPosLabelrelocation" type="number">-10</property>
</properties>
14 changes: 14 additions & 0 deletions Meditate/resources-round-240x240/constants.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<properties>
<property id="progressBarWidth" type="number">180</property>
<property id="globalSettingsIconsXPos" type="number">50</property>
<property id="globalSettingsValueXPos" type="number">70</property>
<property id="globalSettingsLinesYOffset" type="number">10</property>
<property id="sessionDetailsIconsXPos" type="number">35</property>
<property id="sessionDetailsValueXPos" type="number">60</property>
<property id="meditateActivityIconsXPos" type="number">90</property>
<property id="summaryLinesYOffset" type="number">10</property>
<property id="heartRateChartWidth" type="number">160</property>
<property id="heartRateChartLineExtra" type="number">-5</property>
<property id="heartRateChartXPosrelocation" type="number">0</property>
<property id="heartRateChartXPosLabelrelocation" type="number">-10</property>
</properties>
4 changes: 4 additions & 0 deletions Meditate/resources-round-260x260/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
<property id="sessionDetailsValueXPos" type="number">60</property>
<property id="meditateActivityIconsXPos" type="number">90</property>
<property id="summaryLinesYOffset" type="number">10</property>
<property id="heartRateChartWidth" type="number">180</property>
<property id="heartRateChartLineExtra" type="number">20</property>
<property id="heartRateChartXPosrelocation" type="number">11</property>
<property id="heartRateChartXPosLabelrelocation" type="number">-10</property>
</properties>
6 changes: 5 additions & 1 deletion Meditate/resources-round-280x280/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
<property id="sessionDetailsIconsXPos" type="number">40</property>
<property id="sessionDetailsValueXPos" type="number">65</property>
<property id="meditateActivityIconsXPos" type="number">90</property>
<property id="summaryLinesYOffset" type="number">15</property>
<property id="summaryLinesYOffset" type="number">15</property>
<property id="heartRateChartWidth" type="number">180</property>
<property id="heartRateChartLineExtra" type="number">22</property>
<property id="heartRateChartXPosrelocation" type="number">10</property>
<property id="heartRateChartXPosLabelrelocation" type="number">-10</property>
</properties>
4 changes: 4 additions & 0 deletions Meditate/resources-round-360x360/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@
<property id="detailsModelIconHeight" type="number">52</property>
<property id="hmmTimePickerOutputXOffset" type="number">140</property>
<property id="mmssTimePickerOutputXOffset" type="number">130</property>
<property id="heartRateChartWidth" type="number">320</property>
<property id="heartRateChartLineExtra" type="number">-15</property>
<property id="heartRateChartXPosrelocation" type="number">22</property>
<property id="heartRateChartXPosLabelrelocation" type="number">-10</property>
</properties>
6 changes: 5 additions & 1 deletion Meditate/resources-round-390x390/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@
<property id="detailsModelLineHeight" type="number">50</property>
<property id="detailsModelIconHeight" type="number">52</property>
<property id="hmmTimePickerOutputXOffset" type="number">140</property>
<property id="mmssTimePickerOutputXOffset" type="number">130</property>
<property id="mmssTimePickerOutputXOffset" type="number">130</property>
<property id="heartRateChartWidth" type="number">320</property>
<property id="heartRateChartLineExtra" type="number">-15</property>
<property id="heartRateChartXPosrelocation" type="number">15</property>
<property id="heartRateChartXPosLabelrelocation" type="number">-15</property>
</properties>
6 changes: 5 additions & 1 deletion Meditate/resources-round-416x416/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@
<property id="detailsModelLineHeight" type="number">50</property>
<property id="detailsModelIconHeight" type="number">52</property>
<property id="hmmTimePickerOutputXOffset" type="number">140</property>
<property id="mmssTimePickerOutputXOffset" type="number">130</property>
<property id="mmssTimePickerOutputXOffset" type="number">130</property>
<property id="heartRateChartWidth" type="number">320</property>
<property id="heartRateChartLineExtra" type="number">-15</property>
<property id="heartRateChartXPosrelocation" type="number">10</property>
<property id="heartRateChartXPosLabelrelocation" type="number">-15</property>
</properties>
4 changes: 4 additions & 0 deletions Meditate/resources/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@
<property id="detailsModelIconHeight" type="number">32</property>
<property id="hmmTimePickerOutputXOffset" type="number">85</property>
<property id="mmssTimePickerOutputXOffset" type="number">75</property>
<property id="heartRateChartWidth" type="number">120</property>
<property id="heartRateChartLineExtra" type="number">15</property>
<property id="heartRateChartXPosrelocation" type="number">0</property>
<property id="heartRateChartXPosLabelrelocation" type="number">-10</property>
</properties>
26 changes: 5 additions & 21 deletions Meditate/source/activity/MeditateDelegate.mc
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ class MeditateDelegate extends Ui.BehaviorDelegate {

//this reads/writes session settings and needs to happen before saving session to avoid FIT file corruption
private function showSummaryView(summaryModel) {
var summaryViewDelegate = new SummaryViewDelegate(summaryModel, mMeditateModel.isRespirationRateOn(), me.mMeditateActivity.method(:discardDanglingActivity));
Ui.switchToView(summaryViewDelegate.createScreenPickerView(), summaryViewDelegate, Ui.SLIDE_LEFT);
var summaryViewDelegate = new SummaryViewDelegate(summaryModel, mMeditateModel.isRespirationRateOn(), me.mMeditateActivity.method(:discardDanglingActivity));
var view = summaryViewDelegate.createScreenPickerView();
if (view!=null) {
Ui.switchToView(view, summaryViewDelegate, Ui.SLIDE_LEFT);
}
}

function onShowNextViewConfirmDialog() {
Expand Down Expand Up @@ -94,23 +97,4 @@ class MeditateDelegate extends Ui.BehaviorDelegate {
}
return false;
}

var backlightOn = false;

function onTap(clickEvent) {
try {

// Touch screen to disable/enable backlight during activity
// This will still respect the backligh timeout configured in the device
backlightOn = !backlightOn;
Attention.backlight(backlightOn);

} catch(ex) {

// Just in case we get a BacklightOnTooLongException for OLED display devices,
// disable backlight
backlightOn = false;
Attention.backlight(backlightOn);
}
}
}
Loading

0 comments on commit 154d460

Please sign in to comment.