Skip to content

Commit

Permalink
Fix HR sensor reading
Browse files Browse the repository at this point in the history
It seems that using the Sensor permission has changed how to obtain
HR readings?
  • Loading branch information
kelnage committed Apr 25, 2019
1 parent b798dea commit 3f339bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
Binary file modified design/screenshots/screenshot-va3mlte.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion manifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- 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="DigitalSimplicityApp" id="4bed8f12d5a3471d896a242356411bd7" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watchface" version="1.1.0">
<iq:application entry="DigitalSimplicityApp" id="4bed8f12d5a3471d896a242356411bd7" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="watchface" version="1.1.1">
<iq:products>
<iq:product id="d2charlie"/>
<iq:product id="d2delta"/>
Expand Down
18 changes: 10 additions & 8 deletions source/DigitalSimplicityView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,16 @@ class DigitalSimplicityView extends WatchUi.WatchFace {
case BAR_OPTION_NOTHING:
break;
case BAR_OPTION_HEART_RATE:
if(!(ActivityMonitor.Info has :getHeartRateHistory)) {
return "N/S";
}
var sample = activity.getHeartRateHistory(1, true).next();
if(sample != null && sample.heartRate != ActivityMonitor.INVALID_HR_SAMPLE) {
return Lang.format(
barFormatList[index],
[Math.floor(sample.heartRate).format("%d")]);
if((Toybox has :SensorHistory) && (Toybox.SensorHistory has :getHeartRateHistory)) {
var sampleIterator = Toybox.SensorHistory.getHeartRateHistory({});
if(sampleIterator != null) {
var sample = sampleIterator.next();
if(sample != null && sample.data != null) {
return Lang.format(
barFormatList[index],
[Math.floor(sample.data).format("%d")]);
}
}
}
break;
case BAR_OPTION_SUN_EVENT:
Expand Down

0 comments on commit 3f339bf

Please sign in to comment.