Target specific devices/families in source?

Former Member
Former Member
Hi,

I've made a couple watch faces for the Fenix 5 watch family and would now like to now adapt the code for use with the Vivoactive 3 family.
Parts of my code definitely need tweaking for this specific device as text appears to be rendered differently on VA3 family.

Is there any way in my code to differentiate between watch families?
example:

if (vivoactive3 || vivoactive3m) {
doThis();
}
if (fenix5) {
doThat()
}

  • There's really two ways to do this - one at compile time with Jungles, one at runtime by detecting the difference

    with jungles, you can do something with annotations and excludeAnnotaions such as:
    (:va3like) function doIt() {
    //va3/va3m code
    }

    (:f5like) function doIt() {
    //f5 code
    }


    then use excludeAnnotations and exclude f5like on va3/va3m devices, and exclude va3like on f5 devices

    With runtime and these two families, they are both round and except the f5s, 240x240, but you can key off something such as Sys.getDeviceSettings().isTouchScreen. (that indicates va3/va3m)
    With a runtime check, I tend to do that in onLayout and set things (x,y, font, etc) up so you don't need to check and do that each time onUpdate is called.
  • Oh, by the way. If you support the f5, you likely already support some other devices, like the f5 variants (D2 Charlie, etc), the 935, the 645/645m, and the f5+ devices and variants.

    and when you support the va3/va3m, the Approach S60 is close, but there are differences in that it doesn't have OHRM or SensorHistory.
  • Former Member
    Former Member over 6 years ago
    That's great help, although using jungle is a bit beyond my skill set.
    I found another way though, by using
    device_settings = Sys.getDeviceSettings();
    deviceId = device_settings.partNumber;

    which returns a string with the exact device model number, eg. 006-B2697-00, which is the fenix5

    then simply ran a test
    if (deviceId.equals("006-B2697-00")) {
    deviceCatch = true; //fenix5
    } else if (deviceId.equals("006-B2700-00")) {
    deviceCatch = false; //vivoactive3
    }

    if (deviceCatch == true) {
    doThis()
    } else {
    doFoo()
    }

    etc. etc.

    It's a bit of a weird approach but I can confirm it works.
    There appears to be precisely ZERO documentation on model numbers from Garmin so had to deduce most of them myself by using the devices I have and the simulator.
  • That is actually kind of a complex way, in that the same device can have different part numbers. For example there are ROW ("Rest of World") devices as well as APAC ("Asian-Pacific"), and each with different part numbers. And you can't simulate APAC devices in the sim.

    The info is in devices.xml though.

    Using isTouchScreen to differentiate between the va3 like devices and f5 like devices is far simpler.

    (no f5 devices are touch screen, and all va3 devices are touch screen)
  • Or... try to use build exclusions or jungles and just ask questions as they come up.
  • Former Member
    Former Member over 6 years ago
    jim_m_58 that's actually a good idea; seeing whether the device is touchscreen or not, at least in my case it is. Like you say, that will differentiate between fenix and va3 family. Good stuff!
  • apologies to bring this topic up again. I've been trying to use excludeAnnotations as per the example above ie a list of annotated functions with the same name. The compiler throws a Duplicate declaration of symbol error for the functions, x() in the pseudo example below.

    Jungle:

    round.excludeAnnotations = $(round.excludeAnnotations);newSampleProcessing

    code:

    (:newSampleProcessing) function x() {}

    (:oldSampleProcessing) function x() {}

    I've tried separate jungle files as well for setting excludes but they only seem to work in the monkey.jungle file.

    Note that if I use separate names and use a has operator then the exclude seems to work ie

    func choose () {

     if ( object has :x_1 }

      call x_1(); // which has (:newSampleProcessing) annotation

    else

    call x_2(); // which has (:oldSampleProcessing) annotation

    }

    but this means I have to introduce a selector function and have separate names for each function.

    Ideas welcome.

  • answered my own question after lots of google searches...

    The compiler error is because the base.excludeAnnotations was not being set in the default compile!

    base.excludeAnnotations = newSampleProcessing

    means it compiles and works as expected.