Programming Data Fields in Garmin IQ

Former Member
Former Member
Hi Everyone!

My name is Jose, and I am a very enthusiastic triathlete. Although I am good at Matlab and Python programming, I am very new to the Monkey Platform, very. However, I am very interested in programming my own data fields and I had some questions:

1. Is it possible to get activity values from past times? For example for the last ten seconds? This will help me to calculate the grade according to the elevation, or heart-rate-curve slope. How can I do this?

2. Is it possible to dynamicaly compute a new variable, when its inputs are increasing size constantly? I would like to compute the NP, which is obtained by:

NP = [avg(P[SUB]1[/SUB][SUP]4[/SUP]+P[SUB]2[/SUB][SUP]4[/SUP]+...+P[SUB]i[/SUB][SUP]4[/SUP])][SUP]1/4[/SUP]

3. Is it possible to have access to the activity information of the current lap? Such as Pace averaged in Lap?

Thank you for your answers!!
Jose
  • Former Member
    Former Member over 10 years ago
    Hi!

    I have just finished compiling my new data fields. How do I pass the IQ data to the watch? I have the latest Garmin Express & the latest Firmware of the 920?

    Thank you!!
  • From within Eclipse there are two options on the ConnectIQ menu to build distributables. I can't remember the names, but it is pretty clear. One of them will build a .prg file and the other will build an .iq file. If you want to test your data field on your 920, connect it to your PC/Mac via USB and copy the .prg file to the Garmin/APPS folder. When you eject the USB storage device (the 920), it will start up. You should be able to select your data field from the data field settings on the activity configuration menu.
  • Former Member
    Former Member over 10 years ago
    I think it could be done more simply as...

    var sum = 0;

    var i;
    for (i = 0; i < values.size(); ++i) {
    if (values== null) {
    break;
    }
    sum += values;
    }

    sum /= i;
    [/code]

    If you do that, you'd have to evaluate every value to check if it might be null. Your code might look a little cleaner, but I think mine is still very readable and executes a lot faster (especially if N is a large number).
  • Former Member
    Former Member over 10 years ago
    Hi!

    I have just finished compiling my new data fields. How do I pass the IQ data to the watch? I have the latest Garmin Express & the latest Firmware of the 920?

    Thank you!!


    Just to be sure. By latest you mean beta version 2.64? It won't work on the current release version 2.50.
  • Former Member
    Former Member over 10 years ago
    Hi!

    I was able to download my data fields, and to use them on the indoor bike mode. However, the 920xt keeps crashing every second. I turned it on, moved to the run or indoor run menu, and then it would restart. If i change to bike or swim mode, it stops crashing. I had to remove all the new data fields to use it without crashing.

    How could I solve this problem? Thank you!

    Jose
  • It sounds like there is a bug in your code somewhere. You need to check that you aren't trying to access a null object. As an example, you need to be sure that info.currentHeartRate is not null before you try to use the value.

    You need to be sure that your program behaves correctly under the simulator when running data no data file, when simulating data, when using a fit file that both does and doesn't include a various bits of data (with and without heart rate data, with and without gps data, ...).

    Travis
  • Former Member
    Former Member over 10 years ago
    You were right!

    I programmed some data fields using the currentSpeed command, but didn't considered the null-case. Now they run perfectly!

    I was wondering if it would be possible to allow more IQ Data Fields per activity. 2 is very limiting, and I have created around 5 for each sport. I would like to use them simultaneously. Would it be possible in the future to use them all?

    Thanks!
  • This has been asked multiple times, and the answer has been no because of resource constraints on the devices. You might be able side-step the limitation by creating different activity profiles and using two data fields with each one. Provided that you don't _need_ them simultaneously, you'll be okay. If you really must have more than two in a single activity mode, then your options are limited. You could modify your data field to automatically rotate through a few metrics, or you could display multiple metrics on the screen at a given time.

    Travis
  • Former Member
    Former Member over 10 years ago
    Thank you for your response!

    I understand the limitations. I would like then to display multiple data fields on one screen. How can I begin? Are there any particular examples?

    Jose
  • Former Member
    Former Member over 10 years ago
    Create a project of type datafield and have it extend DataField in stead of SimpleDataField.
    Calculate the values you want to display inside the compute(info) method and store the values in class level fields.
    Implement an onUpdate(dc) method to display whatever you want on your screen. (See watchface examples in the toolkit.)