Getting values for a watch face

Hi,

I am about creating my first watch face. Nevertheless, I have some problems in getting some values:

I have seen a lot of watch faces which shows altitude or heart rate. But I can't find that information in the ActivityMonitor.Info field. For heart rate I could also utilize the sensor class but realized that the class is only for widgets and apps. The SensorHistory class is only accessible for fast devices like FR735.

Indeed I want to depict altitude, pressure, heart rate, temperature and sunrise/sunset, but can't find any of those values. Can someone give me a hint?

Furthermore (a little off topic to this thread, but I don't want to open a new one for this little topic): I have realized that some watchfaces let customize the color of the icons. How can I effectly draw an icon like bluetooth or steps with Garmin's drawable functions?
  • For a watchface:

    With HR, you do get it from getHeartRateHistory(), (you use the newest sample, and yes, it's only available on watches with a ohrm like the 735). The version in ActivityMonitor is available on devices with 1.3 or 1.4 CIQ and a oHrm, while the SensorHistory version, only devices with 2.x. and a oHrm

    Elevation, pressure, you can get the last values from activity.info (from the last activity and may go stale) (or SensorHistory on the va-hr). Also lat/lon in Activity.info, which you use to calculate the sunrise/sunset for a location.

    Temperature is only available on the va-hr, using getTemperatureHistory() in SensorHistory.
  • Oh, and for changing the color of icons... I don't use bitmaps - I use a custom font for the icons, so you can set the color just like you do with the native fonts.

    For example, in my icon font,

    dc.drawText(x,y,iconfont,"P",Gfx.TEXT_JUSTIFY_RIGHT)

    Draws the "phone" (bluetooth) icon, in whatever the current color is set to. (I current have about 20 icons in the custom font)

    You could use a bunch of different colored bitmaps, but using a custom font seems easier to me.

    Another option is to just draw the icon in your code. I have a watchface called "Fontless", which as the name implies, uses no fonts (native or custom). Just things like dc.drawRectangle(), dc.drawPolygon(), etc. Using a custom font would be more efficient, but with "draw your own", you can not only change the color, but the size.
  • Hi Jim,

    is there something you don't know? You give this forum such a high quality. Thanks for supporting us.

    Here are some questions:
    - It seems that e. g. the watchface Optimus which is also ready to show altitude updates the elevation right. It seems that it is not rely on the last activity. Or did I misunderstood something?
    - I used getHistory() now from activity monitor. What I have realized is, that I will get a symbol not found if I want to access floors climbed as well as floors climbed goal whereas steps and step goal works pretty well. Is this a bug or a restriction? I used the Fenix 3 HR in the simulator and the Fenix should have these values.
    - A further oddity: as soon as I access the steps, drawing an arc is messed up. I use this:

    using Toybox.WatchUi as Ui;
    using Toybox.Graphics as Gfx;
    using Toybox.System as Sys;
    using Toybox.Lang as Lang;
    using Toybox.ActivityMonitor as Amo;

    function onUpdate(dc) {
    var curSteps = Amo.getInfo().steps;

    dc.setColor(Gfx.COLOR_WHITE, colBackground);
    dc.clear();

    dc.setColor(colHoursBackground, Gfx.COLOR_TRANSPARENT);

    dc.setPenWidth(5);

    dc.drawArc(109, 109, 108, Gfx.ARC_COUNTER_CLOCKWISE, 315, 45);

    return true;
    }




    and I get this:


    If I delete the first line which gets the steps the arc is drawn correctly. This is very odd since I don't use the variable curSteps anywhere. This cost me a lot of track down time yesterday to find that out, but I have no solution. Any comments?
  • What if instead of
    dc.drawArc(109, 109, 108, Gfx.ARC_COUNTER_CLOCKWISE, 315, 45);
    you do
    dc.drawArc(109, 109, 108, Gfx.ARC_COUNTER_CLOCKWISE, 45, 315);
    (swapping the last two values) What SDK are you using?? When you see something odd in the sim with arcs, it might help to sideload to a watch and see what happens there.

    As far as floors, That's only available on some devices

    You need to check if it's available

    hasFloors =(ActivityMonitor.getInfo() has :floorsClimbed) ? true : false;
  • Hey,

    I just had another issue with drawArc reported in the Sim that looks similar. I have a ticket created that will be prioritized this week. I'll reply back with more info when we know a little more.

    Thanks,
    -Coleman
  • Elevation, pressure, you can get the last values from activity.info (from the last activity and may go stale) (or SensorHistory on the va-hr). Also lat/lon in Activity.info, which you use to calculate the sunrise/sunset for a location.



    Hi Jim,

    I found elevation in Activity.info but not pressure. Nevertheless, I found in the API to get pressure from Sensor.getInfo() but Sensor is not accessible from a watchface. Is there a workaround for this?

    Elevation, pressure, you can get the last values from activity.info (from the last activity and may go stale)


    Furthermore I used also the watchface Optimus HR on my Fenix 3 HR and realized that the altitude was refresehed during I climbed a floor. How did the developer do this? As I understood the information from activity.info is maybe outdated....
  • Hi Jim,

    I found elevation in Activity.info but not pressure. Nevertheless, I found in the API to get pressure from Sensor.getInfo() but Sensor is not accessible from a watchface. Is there a workaround for this?


    Ok, I'm an old guy and sometimes have senior moments :) I thought it was in Activity.info, but it's not.


    Furthermore I used also the watchface Optimus HR on my Fenix 3 HR and realized that the altitude was refresehed during I climbed a floor. How did the developer do this? As I understood the information from activity.info is maybe outdated....



    I'm interest to find how it's done too! If you find out, let me know! You might want to check if altitude in Activity.info changes while not in an activity (and if so, it's likely only on devices with a baro altimiter).
  • Hi Jim,

    I grabbed the altitude info as you suggested from activity.info and huuu, the values are also updated on my Fenix 3 HR every minute (if the altitude value changes). Saying this I haven't understand when the watchface is updated. In principal I put the code into onUpdate(dc) which is triggered every minute. Nevertheless, I got some issues with that: if I update the settings in GCM the watchface is not updated at once but I have to switch for and back to any other widget to get the watchface updated. The API says:

    For watchfaces and datafields the lifecycle is onLayout(), onShow() and onUpdate()

    I assume that the switching for and back to another widget also triggers onShow() which (in my understanding) triggers again onUpdate. If I change the settings in GCM, I sometimes annotate also settings back to GCM. This behavior is also done only if I switch temporarily to another widget. And finally there are some watchfaces which offers a switch which says: only update every minute. Therefore I assume there is another method which triggers onUpdate also. Do you know where I can find more documentation about this?


    This was a little bit off topic to the thread. Back to the thread: I can't access the sensor class from a watch face. Is there any other way to get the pressure? It's a shame if infos are there but you can't grab it.....

    Thanks again for your support.