questions on watchface creation

Former Member
Former Member
Hello to everyone
I wanted to create my own watch face so i started trying
I want to point that i have programmed before in a couple other languages so i am quite familiar
Despite that, i have some problems i can't seem to find solution for
So here we go

1)
I want to add an icon for Bluetooth
At the default watch face when you have Bluetooth off you have no icon being displayed
Once you enable Bluetooth you have an icon being displayed(Bluetooth on but not connected)
Once you connect your phone you have another icon being displayed(Bluetooth on and connected)
So i would say i have 3 "states" for the Bluetooth
I only managed to find this:
Sys.getDeviceSettings().phoneConnected
Which checks if the phone is connected or not
So i have 2 "states" and missing the one where Bluetooth is off
In short i want something to check if Bluetooth is enabled or not before checking if it is connected
How do i do that?

2)
All my code is onUpdate
Meaning that it is being updated every second
Two questions here
Is this effective?
I am asking because i am used to writing very little code at my main class and building other
files for classes functions etc rather than having one huge
Also there are data i would like to record less often
For example i would like to record steps less often for battery saving reasons
I guess i could do that in an if statement but is there anything else better?

3)
Can i test my watch face on my actual watch rather than the simulator?
If yes than how?

4)
I have seen many watch faces that have their own custom settings
I would like to do something like that as well
To start with i haven't yet found a way to check System Settings
I did find 4-5 on the api but that's it
I mean something like that:
"getDeviceSettings().is24Hour"
i would like for example to have two versions of my watch face
one with black background and one with white
Meaning i would have to change icons and colours for many graphics depending on
the backgrounds colour
Are there more on the api that i am missing?
And then how can i create my own custom settings to change from the mobile app?
  • If you use bitmaps, remember that you can't change the colors. That's why I use a custom font for icons. You can draw the rectangle itself and fill what's needed, and use any color you want. You can also do a bit of a hybrid where you use a bitmap or font for an empty battery and fill what's needed.

    With custom font icons I have a full battery and an empty one that I use - 10% or less, it's empty, greater than than that, the full one, but I change the color at 25%. So you can do things like that too. I also display the actual percentage next to the icon. Consider if you have a icon that's 20 pxls high (leaving maybe 16pxls once you have the outline), and if you fill it based on percent, you really don't have much space and maybe a change of 15-20% will be noticed by the user due to resolution.

    The most efficient in my opinion would be to show the same icon and the %, and maybe change colors at certain points. Multiple icons (more bitmaps or characters in the font) next (again with the %) and draw/fills the least.
  • Former Member
    Former Member over 8 years ago
    It seems that with every answer i get even more questions are created
    I am now facing new "problems" :p

    Firstly i want to show altimeter and hr
    I know that i cann't show those info from the sensor directly
    but read that i can do so from history and that is how i am trying to get both
    I have attached a screenshot showing exactly what i am doing for hr(same applies for altimeter)
    (The code is taken exactly as is from SensorHistory API)
    I tried starting and saving an acrivity after i got a gps lock and still no luck at any of the two

    I also wanted to add settings that would appear at the connect app and would allow me to change watch appearance
    I created a folder named settings and placed it in the resources folder
    Then created two files:
    properties.xml
    settings.xml
    I also attatched screenshots of the files contents
    I also edited the strings.xml file in the resources/string folder and added two lines(strings screenshot)
    I also changed my code for the background to read the color from the files(onupdate screenshot)
    If i remove the if statement i get an exception that the value is null
    i moved the app at my watch for testing and the background color was black(meaning it entered the if statement and was null at the beginning)
    Also there is not setting option on garmin connect app like other apps, just uninstall option
    What am i missing?
    *Sorry for the too many screenshots...i just couldn't find a way of posting without getting an errorcommunity.garmin.com/.../1242704.png
  • Ok, one at a time here.. Heartrate.

    On some CIQ 2.x devices you can use getHeartRateHistory, either in ActivityMonitor or SensorHistory. On some devices, you can use Activity.Info.currentHeartRate.

    I ususally check Activity.Info first, and if that's non-null use it.
    if it is null, and getHeartRateHistory is available I use the newest reading.

    It's kind of the same for altitude - Check Activity.info, the if not available, getElevationHistory in SensorHistory.

    In both cases, the history can be a few minutes old, and in the sim, never changes.

    For your settings, nothing jumps out at me. Are you sure the key you are using in getProperty is the same as the id of the property?
  • Former Member
    Former Member over 8 years ago
    I have a fenix 3 hr
    So no CIQ 2 for me
    I use 1.4.x
    That said the only way to get hr is getHeartRateHistory and altimeter is getElevationHistory
    I am using the two functions exactly as written here:

    https://developer.garmin.com/connect-iq/api-docs/

    Both functions for hr and altimeter return null although i just saved a run
    Other watch faces i tried where fine
    Any other idea?

    For Settings i just checked again and everything seems correct at my code
    App.getApp().getProperty("BackgroundColor");
    Where BackgroundColor is the id at the properties.xml file
    I cann't figure out anything else..
    I noticed two checkboxes when i built the watchface for the watch but ticked none
    I don't think that is a problem but i am just saying it just in case
    What else?
  • On the f3hr - use ActivityMonitor.getHeartRateHistory. Thats available even if you can't use SensorHistory on devices with WHR.

    Have you tried running the ObjectStore sample in the SDK? That will show how to do app settings (the second screen)
  • Former Member
    Former Member over 8 years ago
    So i first try to get hr from history with SensorHistory
    then i have a statement which checks if it is null
    if it is, which in my case for every time it is for some reason, i have the code shown in the picture
    I get this result Obj:135 instead of my hr
    and no 135 is not even close to my hr at the momment

    as for the settings i will try them later again
    for the momment i want to fix hr and altimetercommunity.garmin.com/.../1242771.png
  • I'm not sure what you're doing with sample.when. That's a timestamp - a moment. The HR is in sample.heartRate.