Locus Map - forum

Development => Developers => Topic started by: mzperx on January 05, 2017, 16:19:37

Title: Locus API, get heart rate value
Post by: mzperx on January 05, 2017, 16:19:37
Hi,

is it possible to retrieve the actual heart rate value from Locus API? I would like to extend the "Locus Map - add-on Wearables" to see the actual heart rate on the watch.
Title: Re: Locus API, get heart rate value
Post by: Menion on January 06, 2017, 06:58:03
Hello,

to fill track recording screen on watches is used this method: https://github.com/asamm/locus-addon-wearables/blob/master/wear/src/main/java/com/asamm/locus/addon/wearables/gui/TrackRecordActivity.java#L189

Here is a key object : TrackStats . This object contains also Heart rate values, see here: https://github.com/asamm/locus-api/blob/master/locus-api/src/main/java/locus/api/objects/extra/TrackStats.java#L376 , so you may simple use getHrmAvg() or getHrmMax() functions. Value '0' means that no HRM was recorded yet.
Title: Re: Locus API, get heart rate value
Post by: mzperx on January 06, 2017, 11:54:18
Hello Menion,

thank you for your fast reply!
I have already found the function and the object and I have already added hrmAvg and hrmMax to my fork of the add-on, but I would like to add the actual heart rate value too (the actual heart beatings) this is what I have referred to in my first post.
I have found neither UpdateContainer nor TrackStats contains this value this is why I think I should extend they with this value. But the question is how can I obtain the actual heart rate value. Is it supported by Locus API?
Title: Re: Locus API, get heart rate value
Post by: Menion on January 06, 2017, 12:01:47
Ah sorry, my bad.

All current sensor data are attached to current users location. So from received UpdateContainer object, just get Location with

container.getLocMyLocation()

In this location object are then all sensor data, so something like
if (myLocation.hasSensorHeartRate()) {
  myLocation.getSensorHeartRate();
}


More here:
https://github.com/asamm/locus-api/blob/master/locus-api/src/main/java/locus/api/objects/extra/Location.java#L762

Simply:
TrackStats - container for complete statistics of currently recording track
Location - object that has not just users location at certain time, but also sensor values at this time
Title: Re: Locus API, get heart rate value
Post by: mzperx on January 06, 2017, 12:34:59
Thank you I think this is what I'm looking for, I will try it!