Simulator needs more requestUpdates

I wrote a watchface which is able to display multiple information pages by activating the high-power mode several times.

The code looks like that:
Nope, can't paste it here :(

To get the same results for the Forerunner 935 and in the simulator, I need to remove / add Ui.requestUpdate() in the sleep function.
  • Former Member
    Former Member
    Hey PUFFOLINO ,

    Can you try posting again? We believe that you should be able to post code now.

    Thanks,
    -Coleman
  • using Toybox.Application as App;
    using Toybox.WatchUi as Ui;
    using Toybox.Graphics as Gfx;
    using Toybox.System as Sys;
    using Toybox.Lang as Lang;
    using Toybox.ActivityMonitor as Act;
    using Toybox.Time.Gregorian as Calendar;


    var active=0; // initialisieren (onUpdate)
    var display=0; // initialisieren (onUpdate)
    var hipower=0; // initialisieren (onUpdate)

    class ClockMain extends Ui.WatchFace
    {

    function initialize() { WatchFace.initialize(); }
    function onLayout(dc) { }


    function onUpdate(dc)
    {
    Sys.println("[tock]");

    // View.onUpdate(dc); // WHY THIS IS NEEDED?

    dc.setColor(Gfx.COLOR_BLACK, Gfx.COLOR_BLACK);
    dc.clear();

    if (active>0)
    {
    dc.setColor(0xffaaaa,-1);
    dc.drawText(120,80,Gfx.FONT_LARGE,"HIGH POWER",Gfx.TEXT_JUSTIFY_CENTER);
    dc.setColor(0xaaaaFF,-1);
    dc.drawText(120,130,Gfx.FONT_LARGE,"SCREEN "+hipower,Gfx.TEXT_JUSTIFY_CENTER);
    }
    else
    {
    dc.setColor(0xaaaaaa,-1);
    dc.drawText(120,80,Gfx.FONT_LARGE,"NORMAL MODE",Gfx.TEXT_JUSTIFY_CENTER);
    dc.setColor(0xaaaaFF,-1);
    dc.drawText(120,130,Gfx.FONT_LARGE,"DISPLAY TIME",Gfx.TEXT_JUSTIFY_CENTER);
    }

    dc.setColor(0xaaffaa,-1);
    dc.drawText(80,180,Gfx.FONT_TINY,active,Gfx.TEXT_JUSTIFY_CENTER);
    dc.drawText(160,180,Gfx.FONT_TINY,hipower,Gfx.TEXT_JUSTIFY_CENTER);

    if (active==0) // one minute in low power, page 0
    { hipower=0; Sys.println("PAGE 0"); }
    else if (active<0) // exit High-Power, prepare next page
    { active=0; hipower=(hipower+1)%3; Sys.println("NEXT PAGE "+hipower);}
    else
    { active++; }


    }

    function onExitSleep() { active= 1; // active=1,2,...
    Ui.requestUpdate(); Sys.println("SIMMODE"); // Simulator vs. Uhr
    }
    function onEnterSleep() { active=-1; // active=0
    Ui.requestUpdate(); Sys.println("SIMMODE"); // Simulator vs. Uhr
    }

    }

    class Init extends App.AppBase
    {
    function initialize() { AppBase.initialize(); }
    function getInitialView() { return [new ClockMain()]; } // return initial view of the application
    }


  • Thanks, could post a test code now, the idea is to view a "normal" information page when lifting the watch the first time, but other pages when repeating this again and again.

    I am using the variable hipower to set the page which will be displayed the next time in high-power mode. Additionally, active will be incremented, so different information could be displayed for the first few seconds etc.

    In the simulator, I need to call Ui.requestUpdate() within the functions onExitSleep and onEnterSleep, while I need to remove these calls to get similar results on my Forerunner 935.