some general questions about developing my first data field

Dear developers,

I want to develop a data field that estimates power (with nothing but speed and elevation data), and shows the average of that for the current lap, for all the poor souls (like me) out there who can't afford power meters. The data field is supposed to run on edge 130 minimum (I would like to use my creation ;). I have quite a bit of experience in coding, but this is my first time developing a garmin data field. To put it in other words: I have no clue what I'm doing. And, like most of the time (sadly), the giant pile of information contained in the documentation is not exactly helpful for new developers trying to get a grip. So, I'd be very pleased if some of you would be so kind to take some time and help me on my journey.  Also, please forgive me, if some of these questions might be incredibly stupid. Here they are anyway:

1. How do I access lap average speed?

As stated, I want to show lap estimated average power. Since power estimation relies heavily on (surprise!) velocity, the easieast way to estimate average power over a lap is to simply take the average speed of that lap. There would be another way, which leads me to point 2:    

2. How do I get the data of the trackpoint at the start of a lap (how do I detect a new lap)?

The easiest way for this would certainly be to simply store the data of the point the "lap" button is pressed. But, if my research is correct: Data Fields don't have access to the information of  buttons pressed, do they? So basically the question is, whether there is any other way to figure that out, like by referencing the current lap duration etc... For anyone interested in              background, I would use this information the following way: Another factor power estimation relies heavily on, is (another surprise!) gradient; which can be determined by distance and            elevation difference from start to end of set distance. The elevation difference I could simply determine by taking the current elevation and the elevation at which the lap started. Same            goes  for, if needed, speed and distance, if these can't be accessed directly (question 1).

3. How do I use trigonometric functions in Monkey C?

Yes, trigonometric functions are used in power estimation (at least in what I found on the internet). In i.e. Java, you can simply import a "Math"-class which contains these functions (and a lot more), something similar is true for python. But is there something like this in Monkey C? I haven't worked with this language ever and all import-like statements I have seen so far in code samples, it just references API-thingies giving information about the device status the program is running on. There has to be something and I just didn't dig deep enough yet.

Now lastly, and probably most importantly ;) :

4. How do I change the text color in eclipse for Monkey C developing?

Seriously. This is an issue. I use eclipse in dark mode, yet, when opening my first sample project, the primary text color was BLACK. Meaning, I can barely see anything. First of all, it's hard for me to understand how this even can happen, given, that the text color should be dictated by eclipse's theme setting, secondly, I am appearantly to stupid to change it. My solution was to temporarily simply use eclipse in light mode until I am finished with my project, but that just can't be a long-term solution.

If anyone, judging based on what is written here, has any other advice apart from what my questions cover: Please leave them here, there's no such thing as "too much support".

Thanks already for reading through all this and, in advance, for helping me out :)

Sincerely, a cyclist

  • 1. How do I access lap average speed?

    This isn't available to CIQ apps, but see next answer.

    2. How do I get the data of the trackpoint at the start of a lap (how do I detect a new lap)?

    The easiest way for this would certainly be to simply store the data of the point the "lap" button is pressed. But, if my research is correct: Data Fields don't have access to the information of  buttons pressed, do they?

    Data fields get a notification on a new lap:

    [https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/DataField.html#onTimerLap-instance_function]

    Override onTimerLap and keep track of the current lap time. You can use that to track the current lap time, which can be used to calculate any lap average data you want.

    Note that CIQ treats laps differently in the context of a programmed workout (regardless of whether they're triggered automatically or manually). To detect the end of a "workout step", you have to call a different function.

    [https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/DataField.html#onWorkoutStepComplete-instance_function]

    Note that not all devices support onWorkoutStepComplete -- only devices which support "API level 3.0.0 or higher" (meaning CIQ 3 or higher). It also looks like the list of supported devices is wrong for this function. (For example, FR230 and Edge 520 don't support API level 3, but they're listed as supported devices here.)

    For practical purposes, if your app runs on an older device that doesn't support API level 3, your app won't be able to detect new "laps" triggered by programmed workouts. (Whether or not you use the lap button to trigger the next step)

    See here for more information on API levels:

    [https://forums.garmin.com/developer/connect-iq/b/news-announcements/posts/welcome-to-connect-iq-system-4]

    3. How do I use trigonometric functions in Monkey C?

    Import the Toyboth.Math module to gain access to functions like pow, sin, sqrt, etc.

    [https://developer.garmin.com/connect-iq/api-docs/Toybox/Math.html]

    4. How do I change the text color in eclipse for Monkey C developing?

    Seriously. This is an issue. I use eclipse in dark mode, yet, when opening my first sample project, the primary text color was BLACK. Meaning, I can barely see anything. First of all, it's hard for me to understand how this even can happen, given, that the text color should be dictated by eclipse's theme setting, secondly, I am appearantly to stupid to change it. My solution was to temporarily simply use eclipse in light mode until I am finished with my project, but that just can't be a long-term solution.

    I agree that this is terrible, and as matter of fact, is one of the many reasons I dislike using Eclipse for CIQ development. IMO, it also highlights the lack of attention to detail that is sometimes seen with CIQ (from Garmin as a whole, not any individual employee).

    To change Monkey C colors, select Windows > Preferences > Connect IQ > Monkey C Editor > Syntax Highlighting.

    Your other alternatives could be:

    - Use VS Code for CIQ development (this has its own issues, as the Monkey C extension for CIQ is in alpha and has a bunch of bugs and usability issues)

    - Build/run apps in Eclipse, but use a different editor like VS Code or Sublime to edit code.