Multiple Data Fields

OK Newbie alert whilst I've a number of years of IT behind me in both infrastructure and programming I am new to developing for the Garmin Edge (targeting the 1000, 1030 and 1040 as I own these)

I am looking at having a Complex Data Field (5 fields) with various calculated functions based on activity.  

My challenge/question is - If I wanted one of the fields from my 5 (say field 3) to appear as the 10th field on a data screen how could I do this or do I need to create 5 individual apps with a field in each.

I've download a few apps (hopposite) as testers as well as an app that does mutlifield.  Adding individual hopposite works but means I would have 5 separate developments each with its own field/calculation rather than 1.  If I add a 10 field multifield app onto the remaining app space I just get the first field if that makes sense.

Any guidance/example code/project would be great :-)

Top Replies

All Replies

  • Are you saying that you want build a data field which works one of two ways?

    1) If you add it as a "full-screen" data field (on a 1-field layout), it draws multiple fields on its own

    2) If you add it as a "normal" data field (on a multi-field layout), it only draws a single field

    You could try to do this by calling DataField.getObscurity() to try to determine if the data field is running in "full-screen" or not.

    developer.garmin.com/.../DataField.html

    e.g.

    https://forums.garmin.com/developer/connect-iq/f/discussion/208071/obscurity-combos---cheat-sheet-ambiguity

    If you're asking whether it's possible for a single app to provide data for multiple fields in an activity, that's not strictly possible. (You can add the same data field app more than once, but it's the same instance running for field. You *could* try to use getObscurity() to distinguish between the different "instances" but I don't think that will work since getObscurity() won't return unique values for every single possible data field placement.)

    So I think your practical options are:
    1) Build data field app which only ever draws 1 field. If you need multiple instances, you have to upload multiple versions to the store. (This is very impractical for watches, since they're only allowed to have two CIQ data fields in a single activity, but you're on Edge so you have more options.)

    2) Build data field app which draws multiple fields (and it only works when you add it as a full-screen data field)

    3) Build app which tries to select between 1 and 2, based on getObscurity().

  • You can figure things out using dc.getWith() and dc.getHeight() and comparing it to System.DeviceSettings.screenWidth/screenHeight.  I use that when my DF will run in either full screen or half screen.

  • You can figure things out using dc.getWith() and dc.getHeight() and comparing it to System.DeviceSettings.screenWidth/screenHeight.  I use that when my DF will run in either full screen or half screen.

    Much better solution, thanks!

  • Was focused on Question 2 from your list but assumed that Quest 1 would be a given - See image for what I am trying to create.  I think sticking to Practical Option 1 is the easiest as that'd give me an answer to both screens albeit with 5 separate   developments.

  • I think sticking to Practical Option 1 is the easiest as that'd give me an answer to both screens albeit with 5 separate   developments.

    Yeah, for an Edge device that would work, since Edge supports lots of CIQ data fields in the same activity, right? It just becomes a pain to deploy all of that stuff to the store. You can automate exporting multiple apps with scripting, but you still have to manually upload them one by one.

    Most CIQ dev stuff is focused on watches (afaik), so it's less of a practical option there since you can only have up to 2 CIQ data fields in the same activity. Even so, I've had requests for some of my apps to have up to 4 "clones" (including the original), as people also want to have different app settings across multiple activities.

    So due to the 2 CIQ field limit, people with watches actually prefer the "single page / multi-field" option where a single CIQ data field app takes up the full screen and draws 6 or more fields. (Another consideration here is that most watches in the past only supported 4 fields on the screen at the time, although for some newer watches the limit is now 6, and for some bigger watches the limit is 8.)

  • I've never tried this, only played with the different DF layouts in the simulator, but I'll throw in an idea, I'm sure that the more experienced will tell me why it won't work though.

    In theory you can count how many "instances" of your DF are running. The POC I made just printed a line at the beginning of compute and onUpdate. In the simulator I can see that depending on the layout onUpdate is called N times between two calls of compute. I'm not sure though if it would behave like that on a real device.

    So you could use this to somehow allocate a number to each one of them, but I don't know how reliable that could be.
    Assuming it works this is what I would do:

    1. count the number of fields (ah, and it can change in the sim or even on real device, when you enter the activity settings and change the layout...)
    2. create an array: var configs as Array<Conf>; and display in each field it's id number (somewhat similar to when in your desktop OS you connect more than one monitor to the computer and you can identify them)
    3. from the settings (lets say from the phone) you can set the configuration of each "instance" and that way choose what information to display in each of them.

     

  • That's a cool idea but what if the multiple instances of the same CIQ data field are on different pages, each page has the same layout, and each instance is in the same part of the layout?

    I will say that I don't know of any data field which actually tries to do anything like this (behave differently for multiple instances), but it would be cool if there were a reliable way to do so. There's def no officially supported way to do it.

    All of this would be moot if Garmin would allow more than 2 CIQ data fields in the same activity on watches. Not sure why the limit hasn't changed after all this time, as CPU speed and RAM have surely increased by a lot since the older generations which also had the same limit.

    Then again, given that the current gen of watches has issues with CIQ data fields crashing depending on what order you add them in, it seems like 2 CIQ fields is more than enough.

    It also seems like having a "full-screen" CIQ data field which renders 6 to 8 fields (or more) sidesteps these issues for the most part, assuming that it supports all the metrics/features you need it to. Dozen Run was my favorite field for the longest time. I still use it for races.

  • All of this would be moot if Garmin would allow more than 2 CIQ data fields in the same activity on watches

    Adding the same ciq field to 1 layout twice would also count as 2.

  • All of this would be moot if Garmin would allow more than 2 CIQ data fields in the same activity on watches

    Adding the same ciq field to 1 layout twice would also count as 2.

    You're absolutely right -- sorry, it's been a while since I tried that, and I had forgotten how it works.

    As a matter of fact, multiple instances of the same CIQ data field app on different pages (not just the same layout) are also counted the same as multiple distinct CIQ apps, so there isn't much point in trying to distinguish between instances. May as well just create multiple clones in the store.