First step for datafield

Hello!

I try to create my own datafield. It should sum the time, where cadence and/or power is zero.

Should running on a Edge1040

I setup Visual Studio, install Monkey C and create first project. When I click on "Run without debugging" I choose the Edge1040 and the simulator start.

But there I have only a blank screen. I thought it will display the edge 1040?

Is there a tutorial for a simple datafield on a edge 1040?

Thank you!

  • I test this now:

        function compute(info as Activity.Info) as Numeric or Duration or String or Null {
            // See Activity.Info in the documentation for available information.
            var cad = info.currentCadence;
            var pwr = info.currentPower;
            var spd = info.currentSpeed;
    
            if (spd > 0){
                if (cad == null){
                    zeroPower += 1;
                } else if (pwr == null){
                    zeroPower += 1;
                }
            }
            return zeroPower;
        }

    I try to play a GPX file from a existing workout:

    Simulation => FIT/GPX Playable file => Load the file an click the Play icon.

    But it seems the data never changed.

  •        if (info has :currentCadence) {
                cad = info.currentCadence;
                if (cad == null) {
                    cad = 0;
                }
                    
            } else {
                cad = -1;
            }
    
            if (info has :currentPower) {
                pwr = info.currentPower;
                if (pwr == null) {
                    pwr = 0;
                }
                    
            } else {
                pwr = -1;
            }
    
            if (info has :currentSpeed) {
                spd = info.currentSpeed * 3.6;
                if (cad == 0 or pwr == 0){
                    zeroPower = zeroPower.add(new Time.Duration(1));
                }
            }
    
            return secondsToTimeString(zeroPower.value());

    ok, so far I think this is correct.

    I did not find any info, how I can save this info. In some IQ fields I see at the end of a workout:

    How can I store this info also?

    And is it possible to save the counter while workout? Sometimes it happen, that the Edge reboot while a workout is running. Could I reload then the zeroPower variable?

    Thanks

    Hannes

  • you can create session level fit field(s) and store it there