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!