Creating a datafield with matching system label and unit formatting?

Hi everyone,

I'd like to create a data field for Edge 840 with the following behavior:

- When there is an active course/navigation, it should show the remaining distance to the destination, labeled "DIST. DEST.".
- When there is no active course, it should fall back to showing the total distance traveled, labeled "DISTANCE".

So both the displayed value *and* the label need to change dynamically depending on navigation state.

I initially looked at SimpleDataField, but it doesn't seem to fit for two reasons:

1. The label is set once at initialization and can't be changed afterward, so I can't switch between "DIST. DEST." and "DISTANCE" at runtime.
2. SimpleDataField doesn't give me the native distance formatting/unit-conversion logic that the built-in system fields use — it just renders whatever numeric value compute() returns, typically as a plain decimal (e.g. "0.00"), without the adaptive behavior of the stock fields.

So it looks like I'll need to use a full DataField with my own onUpdate()/drawing logic. My goal is to make the custom field match the appearance of the system's native distance fields as closely as possible, but this turns out to have quite a few subtleties:

- Unit switching: meters are shown as whole numbers (e.g. "0m", "100m"), then it switches to kilometers with one decimal place once the distance crosses a threshold (e.g. "1.0km", "10.0km", "100.0km").
- The unit text ("m" / "km") is rendered noticeably smaller than the numeric value, not just a smaller version of the same string.
- In smaller/narrower field layouts, the unit appears to shrink further and gets stacked as a "k" above "m" to save space.

Before I start reverse-engineering all of this through trial and error, I wanted to ask the community:

- Does anyone know the exact thresholds and rules the system uses for switching between meters and kilometers (and the decimal formatting at each stage)?
- Is there a recommended approach for reproducing the two-tier font size (large number + small unit) and the compact "k-above-m" layout in small field sizes?
- Is there any existing open-source Connect IQ data field (or a reference implementation) that already replicates the native distance formatting closely, which I could study or adapt?

Any pointers, code snippets, or links to prior discussions would be greatly appreciated. Thanks in advance for your help!

  • You‘re right concerning simple datafield option. No dynamic label is possible, and no unit text is possible.

    I once created a complex datafield named „Radar Overlay“ which reproduced the original datafields in its best way. Unfortunately Garmin took it from the store for security reasons.

    I'd be happy to provide you with some code, but I‘m on vacation and will return to my desk in one week. If the problem still exists then, please write me a PM.

    Note: it is impossible to create a 100% same appearance as stock datafields!

  • I recognise the problems. Here's my answers:

    - What you want cannot be done with SimpleDataField you need the full DataField.

    - There is an excellent introduction tutorial by Peter (afaik he is also on this forum). It handles part of what you want to do. It also learns you the two major different approaches to developing with DataField (layout based versus drawing). Both have their pro's and cons, decide for yourself. The two can be ombined but to be able to do that effectively you first have to master the two.

    url: starttorun.info/.../

    - I don't know on which condition m change to km, maybe you can find out by observing your edge during a ride IRL.

    - as to two-tier font size and the km/h layout - there is nothing in the SDK. You have to program it yourself:(. Can be quite a challenge if you want it close to pixel perfect. And as mcinner1 says it is impossible to make it exactly like the native DataFields. One major reason is that not all native fonts are available in the SDK. If that were the case I am certain I could do it. On Edge that is. On watches, I don't know.

    - I am not aware of an open source sample. My suggestion is the tutorial on runinfo. It contains at least an example of how to make a field with dynamic value and title.

    Have fun

  • Thank you! I ended up this idea by creating two datascreens of the same datafields except distance and elapsed time. One screen has them, other screen has dist dest and time to dest.