Please Help. onUpdate not updating variables

Hi All

Just finished my 1st watchface. Everything seem to be working fine except the move bar

The screen redraw works fine

It seem that the variable does not update to the new values when getting the movebar status

var info = ActivityMonitor.getInfo();
var movePercent = info.moveBarLevel;


When using the movePercent is stays on "0" untill I go to "Reset app settings"

Can someone please help cause its driving me nuts that everything works and draws and updates except this variable
  • Problem resolved itself with the following

    var movePercent = null;
    var movePercent = ActivityMonitor.getInfo().moveBarLevel
  • This is really a question for the Connect IQ Forum.

    The move bar level is a number between 0 and 5 and not a percent. The first segment is an hr, and the next 4, each additional 15 minutes. A mover bar is typically shown as a bar with 5 segments.

    To get the first segment, start the sim and let it run for an hour without simulating step data.
  • Former Member
    Former Member over 7 years ago
    To get the first segment, start the sim and let it run for an hour without simulating step data.


    Note that you can use the Fast Forward option in the activity tracking menu to make this appear much faster.

  • True Brian! I always forget about that one :)
  • Managed to get it to work correctly. Thanks guys.

    For some reason the variable when declared didn't update in the If statement. When I moved the var to the if from the top it worked fine and updated.
  • Hmmm. If this works...

    var moveBarLevel = ActivityMonitor.getInfo().moveBarLevel;


    .. but this does not...

    var info = ActivityMonitor.getInfo();
    var moveBarLevel = info.moveBarLevel;


    then it sounds like there may be some sort of compiler/runtime bug. I tried to reproduce using a data field, but saw no issues. Here is the code I used...

    using Toybox.Application as App;
    using Toybox.Graphics as Gfx;
    using Toybox.WatchUi as Ui;
    using Toybox.System as Sys;
    using Toybox.Lang as Lang;

    class TestView extends Ui.DataField {

    function initialize() {
    DataField.initialize();
    }

    function onUpdate(dc) {
    dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_BLACK);
    dc.clear();

    //var moveBarLevel = ActivityMonitor.getInfo().moveBarLevel;

    var info = ActivityMonitor.getInfo();
    var moveBarLevel = info.moveBarLevel;
    Sys.println(moveBarLevel);

    var cx = dc.getWidth() / 2;
    var cy = dc.getHeight() / 2;

    dc.drawText(cx, cy, Gfx.FONT_LARGE, moveBarLevel.toString(), Gfx.TEXT_JUSTIFY_CENTER | Gfx.TEXT_JUSTIFY_VCENTER);
    }
    }


    class TestApp extends App.AppBase {

    function initialize() {
    AppBase.initialize();
    }

    function getInitialView() {
    return [ new TestView() ];
    }
    }


    If you are still able to reproduce a problem, could you produce a test case to show the issue?

    Travis