A couple of bugs found: Profiles HR and drawArc

I am just experiencing 2 issues when doing my datafield for my edge 1000:
1. drawArc is curiously begin cut on the middle of it at certain angles. I am experiencing it on: dc.drawArc(240,474,322,Gfx.ARC_CLOCKWISE,113,67); until start and end angles are around 100,70. When difference of angles is bigger the gap widen.

2. Getting the profile HR zones: mHRZones = profile.getHeartRateZones(profile.getCurrentSport()); this give an array with the different zones. It works well on the simulator, however when datafield is already running on my edge device, the correct value for the zone is on a different index. For example, Zone 5 value is on mHRZones[5] when on the simulator but it is on mHRZones[4] when running on my edge.

3. I am also having another strange issue with the draw Arc that a portion of it is appearing on another section. I am still trying to figure out how to solve this one.



  • Former Member
    Former Member
    Hey Vallecino,

    Sorry we didn't see this somehow! In regards to your bugs, We have seen 1 and 3 I believe. Are your drawArc() issues happening on device, simulator, or both?
    For number 2 I'll need to look into this one a bit more, but I wanted to make sure you knew that we are looking at them!

    Thanks,
    - Coleman
  • Former Member
    Former Member
    Vallecino,

    I've tested this out with this view class built from a complex datafield template project:

    using Toybox.WatchUi as Ui;
    using Toybox.Graphics as Gfx;
    using Toybox.UserProfile;

    class WT5758View extends Ui.DataField {

    hidden var mValue = 0;

    function initialize() {
    DataField.initialize();

    }

    // Set your layout here. Anytime the size of obscurity of
    // the draw context is changed this will be called.
    function onLayout(dc) {
    var obscurityFlags = DataField.getObscurityFlags();

    // Top left quadrant so we'll use the top left layout
    if (obscurityFlags == (OBSCURE_TOP | OBSCURE_LEFT)) {
    View.setLayout(Rez.Layouts.TopLeftLayout(dc));

    // Top right quadrant so we'll use the top right layout
    } else if (obscurityFlags == (OBSCURE_TOP | OBSCURE_RIGHT)) {
    View.setLayout(Rez.Layouts.TopRightLayout(dc));

    // Bottom left quadrant so we'll use the bottom left layout
    } else if (obscurityFlags == (OBSCURE_BOTTOM | OBSCURE_LEFT)) {
    View.setLayout(Rez.Layouts.BottomLeftLayout(dc));

    // Bottom right quadrant so we'll use the bottom right layout
    } else if (obscurityFlags == (OBSCURE_BOTTOM | OBSCURE_RIGHT)) {
    View.setLayout(Rez.Layouts.BottomRightLayout(dc));

    // Use the generic, centered layout
    } else {
    View.setLayout(Rez.Layouts.MainLayout(dc));
    var labelView = View.findDrawableById("label");
    labelView.locY = labelView.locY - 16;
    var valueView = View.findDrawableById("value");
    valueView.locY = valueView.locY + 7;
    }

    View.findDrawableById("label").setText(Rez.Strings.label);
    return true;
    }

    // The given info object contains all the current workout information.
    // Calculate a value and save it locally in this method.
    // Note that compute() and onUpdate() are asynchronous, and there is no
    // guarantee that compute() will be called before onUpdate().
    function compute(info) {
    var profile = UserProfile.getProfile();
    var rate = info.currentHeartRate;
    var zoneCheck;

    // See Activity.Info in the documentation for available information.
    if(info has :currentHeartRate){
    if(info.currentHeartRate != null){
    zoneCheck = UserProfile.getHeartRateZones(UserProfile.getCurrentSport());

    // This if block determines the HR Zone by comparing the
    // Current HR value against the bounds of each HR Zone as
    // defined by the HR Zone array.
    if (rate >= zoneCheck[0] && rate < zoneCheck[1]){
    mValue = 1;
    } else if (rate >= zoneCheck[1] && rate < zoneCheck[2]){
    mValue = 2;
    } else if (rate >= zoneCheck[2] && rate < zoneCheck[3]){
    mValue = 3;
    } else if (rate >= zoneCheck[3] && rate < zoneCheck[4]){
    mValue = 4;
    } else if (rate >= zoneCheck[4]) {
    mValue = 5;
    } else {
    mValue = 0;
    }
    }
    } else {
    mValue = "error";
    }

    }

    // Display the value you computed here. This will be called
    // once a second when the data field is visible.
    function onUpdate(dc) {
    // Set the background color
    View.findDrawableById("Background").setColor(getBackgroundColor());

    // Set the foreground color and value
    var value = View.findDrawableById("value");
    if (getBackgroundColor() == Gfx.COLOR_BLACK) {
    value.setColor(Gfx.COLOR_WHITE);
    } else {
    value.setColor(Gfx.COLOR_BLACK);
    }
    value.setText(mValue.toString());

    // Call parent's onUpdate(dc) to redraw the layout
    View.onUpdate(dc);
    }
    }


    With this code I am seeing consistent behaviour between the device and the simulator using an Edge 1000. Do you know if your Edge software is totally up to date? I don't remember a bug about this on a previous version, but it's worth checking out. Do you see anything that I'm doing here that would not accurately reproduce what you are seeing?

    Thanks,
    - Coleman
  • Hi Vallencino,

    i can confirm your item 3 with portions of the arc appearing in another section (portions of the green arc on the left and right side in my screenshot). I solved it for me by using dc.setClip.

    Regards Werner


    community.garmin.com/.../1351405.png
  • Long time not connecting here. I will publish my code later so that you guys can verify #2. I have latest sw on my edge. You can even try my datafield which is already published as "valles mtb hybrid datafield"