Is there any boiler plate code to creating a 4 fields B layout for the Fenix 7?


I am new to this and am coming in as a JS React Developer.

I am trying to make a simple app that builds upon the kite surfing activity. It records everything in that activity but then I want to create a custom metric that I calculate using the sensors. My question is, when it comes to designing layouts, isn't there some boiler plate code for layouts to achieve the above? The idea would be to display the following: 1) heart rate gauge. Same exact as the example. 2) distance (total distance traveled since activity started) 3) Custom Metric. 4) the current time of day.


  • So far I have this, but its missing the dividers and I feel like adding the actual metrics to it will be difficult

    <layout id="KitesurfLayout">
    <label id="HeartRateLabel" text="Heart Rate" x="50%" y="10" font="Gfx.FONT_SMALL" color="Gfx.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER"/>
    <label id="DistanceLabel" text="Distance" x="25%" y="35%" font="Gfx.FONT_SMALL" color="Gfx.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER"/>
    <label id="Custom" text="custom" x="75%" y="35%" font="Gfx.FONT_SMALL" color="Gfx.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER"/>
    <label id="TimeOfDayLabel" text="Time" x="50%" y="70%" font="Gfx.FONT_SMALL" color="Gfx.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER"/>
    </layout>
  • Understand if you have a four field layout for the data screen, that's 4 different data fields.  You can use a 1 field layout and do your own 4 different values.  Watches usually have a limit to 2 ciq data fields per activity.

    With a full screen data fields, if you want separator lines, you have to draw them yourself

  • Thanks for taking the time to answer. And I apologize if this is obvious. I am not sure I follow. Do you have some sample code I can look at? Or point me to some documentation? Thanks really appreciate it.

  • Is there any boiler plate code to creating a 4 fields B layout for the Fenix 7?

    No. You have to do everything yourself :/.

    Understand if you have a four field layout for the data screen, that's 4 different data fields.  You can use a 1 field layout and do your own 4 different values.  Watches usually have a limit to 2 ciq data fields per activity.

    With a full screen data fields, if you want separator lines, you have to draw them yourself

    I am not sure I follow.

    To be clear, he means you have to do everything yourself. He's also saying that another conceivable option would be to release multiple data field apps (one for each value), but you can only have up to 2 for a given activity, so that doesn't really accomplish what you want.

    i.e.

    1) The data field layouts you see in the device reference that you screenshotted are layouts the user can select for a given (custom) data page, as you probably know. They're not really readily available to CIQ data field apps themselves, except that a data field will always find itself *within* one of these layouts

    2) A Connect IQ data field can only occupy one field in any given layout

    3) The only way to make a Connect IQ data field occupy an entire page (such that it can mimic an existing layout such as 4 fields B for Fenix 7) is to ask the user to set their layout to 1 field, and set your CIQ field as the sole field on the page.

    4) Once you've done 3), the responsibility for laying out the values and labels, choosing fonts (especially choosing a font for the values that dynamically scales to fit the available area *), and drawing the field separators falls solely on the your app code. You're basically reinventing the wheel. There's no way to ask the CIQ API to "mimic data page layout X", for example.

    (* this is harder than it sounds, since the fonts for some devices have a significant of extra whitespace, which means that a font which just barely "fits" according to an API call such as getFontHeight() may actually be too small from the user's POV.)

    Basically, "full page CIQ data field which provides multiple application-defined fields" is not a use case that's explicitly supported by CIQ. Sure, nobody is going to stop you from doing it (since there's no conceivable way or reason to do so), but Garmin is not going to help you do it either.

    As far as an example goes, here is a CIQ data field which has its own custom 9-10 field layouts where:

    - the layout is done in run-time code, not resources

    - the dimensions/coordinates are calculated at run-time such that multiple watches of different screen resolutions are supported:

    https://apps.garmin.com/en-US/apps/bf56e088-aefe-4fb4-8f16-b2e136b996a9

    Not exactly what you're looking for, but it is an example.

  • If you want to stick with layouts defined in resources, I can think of two solutions off the top of my head:

    - Use labels or text areas for everything (field labels and values), and hardcode all the x/y pixel values (which obviously sucks unless you only support one screen shape/resolution or you generate code). For the dividers, maybe you could use polygon shapes?

    - Implement a custom drawable "data field" class which knows how to draw its field value and label (which are set at run-time) and also knows how to draw its divider(s). For the divider, you could pass in a custom parameter in the resource definition (e.g. border = "left" | "right" | "top" | "bottom"). You'd still hardcode x and y values, but at least this could conceivably work with % values and not just pixel values (since the class itself would handle the positioning of the label and value within each field.)

    I've actually made a few full-screen CIQ data fields which implement multiple fields in the app, similar to what you're trying to do. I chose the worst possible solution (from a maintenance POV), which was to create my layout system which uses my own compact layout data format and renders the fields at run-time based on the layout (which selected by the user from a set that's applicable for the current device.) I did this to save memory (as I support a lot of old devices), but if you're only going to dev for Fenix 7, it's probably not the best choice. (If you care about other recent devices, note that Vivoactve 4/4S still have a very low limit for datafield memory, equal to that of very old devices from 7 years ago.)

    The reason for that is Garmin layouts are pretty memory-intensive at run time (and they don't give you what you want out of the box anyway). The app I linked above is also memory intensive, due to the complexity of the code which dynamically calculates layouts. Believe it or not, it's actually cheaper in terms of memory to hardcode layouts using your own bespoke "layout engine" (if you use a very compact format such as an array of bitpacked integers.)

  • feels like the OP is asking how a custom app can offer the user the standard layout options - 1 field, 2 fields, 3 fields, etc., without writing it as custom code.  I am also seeking a way to do this.  There's lots of info about building a custom DataField, and how to have a FIT Field, but not how to surface those on a standard 4 field layout (and have the associated settings to user select which ones to have in that layout)

  • For your example, the user would need to select 4B layout on their watch and add your data field to all four fields.

    1. Your datafield can tell where it is on the 4B layout by checking the obscurity flag value. 
    2. Create four layouts plus a default layout 

    I’d name them

    L7 - this layout is for the top curved part of the screen. If you wish to draw the arc your x,y origin needs to be the centre of the screen. This isn’t always 0,0 it varies by datafield position.

    L1 - Left middle half width field

    L4 - Right middle half width field

    L13 this layout is for the bottom curved part of the screen.

    3. During run time, in onLayout set the layout based on obscurity flag.  I have a lookup dictionary to get from obscurity to the resource symbol for the layout thus {“L7” => Rez.Layouts.L7(dc) , …]

    4. During OnUpdate set your values or if you use custom drawables the class can set them.

    5. Text Areas using % and Graphics.Text-Justify-Center and Text-Justify-Vcenter works really well and will scale to every watch layout out there, if it’s not too complex.

    6. if you do layouts this way using the obscurity flags, text areas, and custom drawable classes (with params in the layout definition) you only need a total of 10 layout definitions to cover every watch size and DF placement,  As a base that comes to about 18KB, then layer your code on top.

  • feels like the OP is asking how a custom app can offer the user the standard layout options - 1 field, 2 fields, 3 fields, etc., without writing it as custom code.  I am also seeking a way to do this.  There's lots of info about building a custom DataField, and how to have a FIT Field, but not how to surface those on a standard 4 field layout (and have the associated settings to user select which ones to have in that layout)

    As already explained in the thread:

    You have to do everything yourself :/.

    This applies whether you are writing a device app (which completely replaces/implements a whole activity) or a full screen data field app (which is added to an existing activity.)'

    In other words, you have to write the "standard" layout stuff as custom code, and what you're asking is impossible.

    It probably doesn't help that different watch models / firmware versions have different data field layout options. e.g. Some watches support 8 fields, other do not.

    There may be other differences which aren't always obvious to devs but which may immediately apparent to end users - e.g.older watches use title case for data field labels (e.g. "Timer") while newer watches use all caps (e.g. "TIMER").

    So any custom solution you create will either have to ignore these differences (e.g. just use all caps for all watches, or don't bother to support old watches) or it will have take them into account (just identifying the differences is a lot of work.)

  • For your example, the user would need to select 4B layout on their watch and add your data field to all four fields.

    That isn't possible (in general) on watches because there's a limit of 2 Connect IQ fields per activity, as already mentioned in this thread. That's assuming you want to have a unique instance of the CIQ app (with its own settings and memory) for each field placement. (Which isn't the case in your example)

    Sure, you could add the same instance of a CIQ data field app to different fields, but then you wouldn't be able to have different settings for each field (for example.) I guess you could have a single set of settings with different options for each field placement.

    It is an interesting solution but I don't think many devs have taken this approach. I seem to recall a post which mentioned that obscurity flags can't distinguish between all possible field placements. (i.e. there's a few cases where obscurity flags are the same for different placements)

    Have you run into any interesting challenges with this solution? I'm a bit curious why more devs haven't taken this approach, unless it's just hard to explain to users.

  • That isn't possible (in general) on watches because there's a limit of 2 Connect IQ fields per activity,


    Yes it’s possible, because you’re using 1 datafield in all 4 positions. The datafield decides what it is drawing  based on where it is in the layout. It absolutely is possible to do the above in a 4B layout with a single datafield.