Has anyone an example of DataField with access to Sensor

Hello:

I own a Garmin Edge 520 and I would like to learn some Monkey C in order to write my own data fields. I've installed Eclipse and the Connect IQ SDK in Debian and I've run the sample Simple Data Field.

Now I would like to read the temperature and pressure builtin sensors in the 520. I think this data must be retrieved via the Toybox.Sensor class, am I rigth? But all my attempts were wrong. Has someone a code example of such project? It's important for me that work with a DataField instead of App, because the first is esier and simpler.

Thanks
  • Interesting math insight. I use simple averages but my window is variable. I provide a user setting so I can adjust the window size on the fly to experiment. I've settled on the last 5 readings (seconds). But then I add intelligence to limit grade change per second, and limit max grade allowable. For example, I only allow X% grade change per second. If you instantly go from -10% to 20% grade, it'll take 6 seconds to get there (5% per second). But if that 20% was due to a bad reading, then it'll smooth that out. Also if you stop, I reset grade to zero and clear the 5 sec history. There are a few other little things I do to try to present an accurate grade. I'll consider the LS idea. THANK YOU.

    In terms of presenting. It is easy to write out a VALUE on more than one line - just add a "\n" character to the string. And you should be able to simple add a "%" symbol - as that is an allowable symbol for both the string and numeric font sets.

    I think you wanted to include TEMP to compensate and improve the barometric reading. However, in my experience, you can not trust the device temp value, as direct sunlight will often heat up the device to 10+ degrees over ambient.


    Thank you for your answer.

    Finally, I configure the position of the two numbers in my DataFiels via the layout.xml file. I've also tried to use the "\n" character for the units of vertical speed in order to put m/h as the "m" over the "h", just as the default speed data field with km/h. But I've found that the two letters appears too far one from the another and finally I've managed the positions individually for "m" and "h" also in the layout file. Is there any option to control the line separation for "\n"?

    You are right about the use of the internal temperature for height computation via pressure. And also, as the data we need for slope computation are only altitude differences the temperature can be safely omitted as we deal with so close measures. And about the data usage I have a new opinion:

    I've seen in the new SDK 2.4 documentation that there are two new fields related to the atmospheric pressure in Activity::Infi: ambientPressure and rawAmbienPressure. The first one stores

    "
    The ambient pressure in Pascals (Pa).
    This returns ambient (local) barometric pressure as measured by the pressure sensor. The data is smoothed by a two-stage filter to reduce noise and instantaneous variation
    "

    and the raw

    "
    The ambient pressure in Pascals (Pa).
    This returns ambient (local) barometric pressure as measured by the pressure sensor. The data is the raw information read directly from the sensor with no filters applied.
    "

    It sound a little bit strange because if the data is recorded once per second I don't know what kind of filter could be applied to the data in ambientPressure field. Or maybe internally the data is obtained at a rate higher than a second, or the filter is applied considering some previous data.

    But here, using ambientPressure or rawAmbienPressure, couls be probably better to word with pressures instead of altitudes. For example, using my algorithm I'll try (when SDK 2.4 supports the Edge 520) to adjust the line to pressuser vs elapsed distances, then I compute the pressures at the first and last point of my array and I derive fron such data the height increment for compute the slope. I'll try with the two kind of pressures. What do you think about?
  • I provide a user setting so I can adjust the window size on the fly to experiment.


    How can I provide user settings in a DataField project?
  • But here, using ambientPressure or rawAmbienPressure, couls be probably better to word with pressures instead of altitudes. For example, using my algorithm I'll try (when SDK 2.4 supports the Edge 520) to adjust the line to pressuser vs elapsed distances, then I compute the pressures at the first and last point of my array and I derive fron such data the height increment for compute the slope. I'll try with the two kind of pressures. What do you think about?



    Hmmm. Having a filtered barometric reading would help. I'm sure they use prior readings to reduce noise, assuming pressure can't change dramatically second to second. I added a lot of logic to my DF to clean up the noise. Maybe I can simplify my DF once 2.4 comes out.