How do other watch faces show HR ?

Watch faces don't have access to Activity so how do other people show the HR on their watch faces!?

Ta
  • You can only do it on watches with whr (va-hr,235,735,f3-hr, etc) as they do 24/7 HR (with readings taken every few minutes).

    Then to get the HR, use getHeartRateHistory() in Activity.Monitor, and display the newest reading. You can only call getHeartRateHistory() on devices with WHR, so you want do do something like a "has" so it's not called on devices without whr (va,230,630,f3,etc)
  • Ta.

    Looked in the docs under Class: Toybox::System::DeviceSettings and cannot see what the actual setting is to check?

    if(device_settings has : ???)

    I trust the docs are out of date!
  • Here's how it can be done (you don't use DeviceSettings)

    hasHR=(ActivityMonitor has :HeartRateIterator) ? true : false;
  • hasHR=(ActivityMonitor has :HeartRateIterator) ? true : false;


    I realize I'm picking nits here, but I'm going to throw it out there anyway... The result of the has operator should be a Lang.Boolean so the conditional operator (?:) should be unnecessary. i.e., you can just write...

    hasHR = ActivityMonitor has :HeartRateIterator;


    If I were writing this code, I wouldn't check for the existence of the iterator type because you never explicitly instantiate one of them. I'd check for the existence of the function that I want to call instead.

    hasHeartRateHistory = ActivityMonitor has :getHeartRateHistory;


    Travis
  • Seems to me I tried using getHeartRateHistory for the has many moons ago, and for some reason, it at one time wasn't consistent between different targets (I can't recall the specifics), but that's probably been resolved by now.

    For the true/false, you're correct, that it's not really needed in this case, but when I set my booleans, I tend to just always use the same format :) (a few extra byte codes, and this is the type of thing I'll only execute once in initialize() - I recall seeing that "has" is not a cheap operation)
  • 1000 baya

    How can i simulate heart rate history activity in the simulator?

    Also I tried this

    value = Act.getHeartRateHistory();

    but dont get the heart rate
  • Rupert. In you code, value is actually "an iterator for the heart rate history for the given period" and you need to use that to get to a sample which contains the HR.
  • Ok so this shows hr history. Is there a way to pull resting heart rate info?
  • I've not used it, but in UserProfile.getProfile() there is restingHeartRate.
  • This would work for a watchface correct? I'm trying to add Hr to an existing face I made. Wouldn't I need to select somewhere to say that the face does use user data? Or access the user profile?