Error logo on Edge 520 datafield

Former Member
Former Member
I'm trying to write a simple datafield for my 520, and it works fine in the simulator. When I build and put on my Edge 520 (following the side loading directions here), it shows up fine in the selector to add to a screen. However, when I go to use it on a ride, it only shows the Connect IQ error symbol when I put the new datafield onto a screen. I've verified that other apps in the Connect IQ store work.

Any ideas? Any more information I can give to help troubleshoot?

(BTW, the datafield is a simple virtual power display -- it just takes current speed and calculates power according to my trainer's power curve.)
  • There is a file in apps/logs called ciq_log.txt that could help in figuring this out.

    But one common problem people have with data fields (or apps that do .fit recording) is when they first start, fields in the act.info structure may be null, and not have a number. You won't see this with the simulator, but you need to check for nulls. For example, he's a bit of code I use in compute() for one of mine:

    if(info.elapsedDistance!=null) {
    if(Sys.getDeviceSettings().distanceUnits==Sys.UNIT_STATUTE) {
    distance=(info.elapsedDistance* 0.000621371).format("%0.2f")+" mi";
    } else {
    distance=(info.elapsedDistance/1000).format("%0.2f")+" km";
    }
    }
  • Former Member
    Former Member over 9 years ago
    Thanks for your help. I'm not sure if this null issue is the problem, but here's the CIQ.txt file when I try to do a ride with the datafield:

    ERROR: Unhandled Exception
    DETAILS: Failed invoking <symbol>
    STORE_ID: 00000000000000000000000000000000
    CALLSTACK:

    WARNING: Failed in data field compute
    STORE_ID: 00000000000000000000000000000000

    WARNING: Failed in data field compute
    STORE_ID: 00000000000000000000000000000000


    ... with this "WARNING" block repeated.

    Here's the code I'm using:

    using Toybox.WatchUi as Ui;

    class VirtualPowerView extends Ui.SimpleDataField {

    var power;


    //! Set the label of the data field here.
    function initialize() {
    //SimpleDataField.initialize();
    label = "Virtual Power";
    }

    //! The given info object contains all the current workout
    //! information. Calculate a value and return it in this method.
    function compute(info) {
    // See Activity.Info in the documentation for available information.
    power=((0.0112*(info.currentSpeed*2.23694)*(info.currentSpeed*2.23694)*(info.currentSpeed*2.23694))+
    (0.1308*(info.currentSpeed*2.23694)*(info.currentSpeed*2.23694))+
    (6.8756*(info.currentSpeed*2.23694))+
    5.323);
    return power.format("%0.0f") + " W";
    }

    }


    Any help would be greatly appreciated!
  • Try this

    using Toybox.WatchUi as Ui;

    class VirtualPowerView extends Ui.SimpleDataField {

    var power = 0;


    //! Set the label of the data field here.
    function initialize() {
    //SimpleDataField.initialize();
    label = "Virtual Power";
    }

    //! The given info object contains all the current workout
    //! information. Calculate a value and return it in this method.
    function compute(info) {
    // See Activity.Info in the documentation for available information.
    if(info.currentSpeed!=null) {
    power=((0.0112*(info.currentSpeed*2.23694)*(info.currentSpeed*2.23694)*(info.currentSpeed*2.23694))+
    (0.1308*(info.currentSpeed*2.23694)*(info.currentSpeed*2.23694))+
    (6.8756*(info.currentSpeed*2.23694))+
    5.323);
    return power.format("%0.0f") + " W";
    }
    }

    }
  • Former Member
    Former Member over 9 years ago
    Thanks!

    Thanks for the help! Somehow my last reply got lost, but that was indeed the problem, and I fixed it similarly to what was above:

    if(info.currentSpeed==null) {
    power=0;} else {
    power=((0.0112*(info.currentSpeed*2.23694)*(info.currentSpeed*2.23694)*(info.currentSpeed*2.23694))+
    (0.1308*(info.currentSpeed*2.23694)*(info.currentSpeed*2.23694))+
    (6.8756*(info.currentSpeed*2.23694))+
    5.323);
    }


    Thanks again!
  • Former Member
    Former Member over 9 years ago
    readability and performance improvement

    A suggestion for your calculation: determine the base value and then use that in the complex expression
    var spd = info.currentSpeed * 2.23694;
    power=((0.0112*(spd)*(spd)*(spd))+
    (0.1308*(spd)*(spd))+
    (6.8756*(spd))+
    5.323);


    This makes it much more readable, but also faster - I'm guessing that monkeyC code is not optimised.

    Second you can use pow from the Math module:

    power=((0.0112 * pow(spd, 3) +
    (0.1308 * pow(spd, 2) +
    (6.8756 * spd) +
    5.323);