Skip to content

Commit

Permalink
4.1.0 Fixed issues with heart rate chart size. Reordered interval vib…
Browse files Browse the repository at this point in the history
…ration in menu to show shorter first. Fixed translation string.
  • Loading branch information
dliedke committed Aug 8, 2022
1 parent 5dc6deb commit fd6d024
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 35 deletions.
35 changes: 17 additions & 18 deletions HrvAlgorithms/sources/activity/HrActivity.mc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ using Toybox.Sensor;
module HrvAlgorithms {
class HrActivity {
function initialize(fitSessionSpec) {
//DEBUG
//PopulateFakeHRHistory();
me.mFitSession = ActivityRecording.createSession(fitSessionSpec);
me.createMinHrDataField();
me.onBeforeStart(me.mFitSession);
Expand Down Expand Up @@ -76,27 +78,24 @@ module HrvAlgorithms {
private const MinHrFieldId = 0;
private var mMinHrField;
private var mMinHr;
private var mHRHistory = [];

//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];
//DEBUG - start - test the heart rate chart instantaneously for X minutes
// also change min/max HR fixed in class HeartRateGraphView and
// call this method in initialize() of this class
/*var numMinutes = 20;
var mHRHistory1Min = [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 function PopulateFakeHRHistory() {
//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];
for (var f=1;f<=numMinutes;f++) {
private var mHRHistory = [];
for (var i=0;i<mHRHistory1Min.size();i++)
{
mHRHistory.add(mHRHistory1Min[i]);
}
}
}*/
//DEBUG - end

function refreshActivityStats() {

Expand Down
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="4.0.1">
<iq:application entry="MeditateApp" id="9abb375dcf7c4ace87ff66f4f773f6c8" launcherIcon="@Drawables.launcherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watch-app" version="4.1.0">
<iq:products>
<iq:product id="approachs62"/>
<iq:product id="d2air"/>
Expand Down
2 changes: 1 addition & 1 deletion Meditate/resources-por/strings/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<string id="confirmDeleteAllIntervalAlertsHeader">Deletar todos alertas?</string>

<string id="SummaryTitle">Sumário</string>
<string id="SummaryHR">Sumário HR</string>
<string id="SummaryHR">Sumário FC</string>
<string id="SummaryStress">Sumário\n Stress</string>
<string id="SummaryStressStart">Stress no Início: $1$</string>
<string id="SummaryStressEnd">Stress no Fim: $1$</string>
Expand Down
1 change: 0 additions & 1 deletion Meditate/resources-round-240x240/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<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>
3 changes: 1 addition & 2 deletions Meditate/resources-round-280x280/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<property id="meditateActivityIconsXPos" type="number">90</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="heartRateChartXPosrelocation" type="number">0</property>
<property id="heartRateChartXPosLabelrelocation" type="number">-10</property>
</properties>
1 change: 0 additions & 1 deletion Meditate/resources-round-390x390/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<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">15</property>
<property id="heartRateChartXPosLabelrelocation" type="number">-15</property>
</properties>
1 change: 0 additions & 1 deletion Meditate/resources/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<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>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<menu id="intervalVibePatternMenu" title="@Strings.intervalVibePatternMenu_title">
<menu-item id="mediumContinuous" label="@Strings.vibePatternMenu_mediumContinuous" />
<menu-item id="mediumPulsating" label="@Strings.vibePatternMenu_mediumPulsating" />
<menu-item id="mediumAscending" label="@Strings.vibePatternMenu_mediumAscending" />
<menu-item id="shortContinuous" label="@Strings.vibePatternMenu_shortContinuous" />
<menu-item id="shortPulsating" label="@Strings.vibePatternMenu_shortPulsating" />
<menu-item id="shortAscending" label="@Strings.vibePatternMenu_shortAscending" />
<menu-item id="shorterAscending" label="@Strings.intervalVibePatternMenu_shorterAscending" />
<menu-item id="shorterContinuous" label="@Strings.intervalVibePatternMenu_shorterContinuous" />
<menu-item id="blip" label="@Strings.intervalVibePatternMenu_blip" />
<menu-item id="shorterContinuous" label="@Strings.intervalVibePatternMenu_shorterContinuous" />
<menu-item id="shorterAscending" label="@Strings.intervalVibePatternMenu_shorterAscending" />
<menu-item id="shortAscending" label="@Strings.vibePatternMenu_shortAscending" />
<menu-item id="shortPulsating" label="@Strings.vibePatternMenu_shortPulsating" />
<menu-item id="shortContinuous" label="@Strings.vibePatternMenu_shortContinuous" />
<menu-item id="mediumAscending" label="@Strings.vibePatternMenu_mediumAscending" />
<menu-item id="mediumPulsating" label="@Strings.vibePatternMenu_mediumPulsating" />
<menu-item id="mediumContinuous" label="@Strings.vibePatternMenu_mediumContinuous" />
</menu>
21 changes: 19 additions & 2 deletions Meditate/source/summaryScreen/HeartRateGraphView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,18 @@ class HeartRateGraphView extends ScreenPicker.ScreenPickerView {

// Try adapting the chart for the graph width
var skipSize = 1;
var skipSizeFloatPart = 0;

// If chart would be larger than expected graph width
if (heartRateHistory.size() > graph_width) {
skipSize = Math.round(heartRateHistory.size().toFloat() / graph_width.toFloat()).toNumber();

// Calculate with maximum precision the skip
skipSizeFloatPart = heartRateHistory.size().toFloat() / graph_width.toFloat();
skipSizeFloatPart = skipSizeFloatPart - Math.floor(skipSizeFloatPart);
skipSizeFloatPart = skipSizeFloatPart * 10000000;

// Calculate the basic skip for the for loop
skipSize = Math.floor(heartRateHistory.size().toFloat() / graph_width.toFloat()).toNumber();
}

// Draw HR chart
Expand All @@ -137,6 +147,13 @@ class HeartRateGraphView extends ScreenPicker.ScreenPickerView {
position_y);
}

// Skip to fit the chart in the screen
if (skipSizeFloatPart > 0) {
if ((xStep * 1000000) % (skipSizeFloatPart).toNumber() > 1000000) {
i++;
}
}

xStep++;
}

Expand All @@ -151,7 +168,7 @@ class HeartRateGraphView extends ScreenPicker.ScreenPickerView {
// Draw lines over chart
dc.drawLine(position_x + 3,
position_y - (lineSpacing * i),
position_x + graph_width + App.getApp().getProperty("heartRateChartLineExtra"),
position_x + graph_width,
position_y - (lineSpacing * i));

if (i!=0) {
Expand Down

0 comments on commit fd6d024

Please sign in to comment.