Menu2, onPartialUpdate Boolean.

Hello,

I need help with one problem.

In my WF, I use the settings via Menu2, so not in the form of GCM.

I have made seconds that should be displayed even in Low Power Mode, so the function function onPartialUpdate(dc).
Dc.setClip(); I have it set correctly and the values ​​do not exceed:

- executionTimeAverage

- executionTimeLimit

The problem is that in Menu2 I have a classic radio button, so Boolean.

Code SecondsAlwaysOn:

 function onPartialUpdate( dc ) 
    {
    if(Storage.getValue(3) == true)
    {            
        var clockTime = System.getClockTime();
        var value = clockTime.sec.format("%02d");
        dc.setClip(x,y,w,h);
        dc.setColor(Graphics.COLOR_RED, Graphics.COLOR_BLACK);
        dc.clear();
        dc.drawText(x, y, Graphics.FONT_XTINY, value, Graphics.TEXT_JUSTIFY_LEFT);              
        }
    }   

When I turn on this switch, WF only shows me the seconds in the SIM for two minutes and then it disappears.

When I turn that switch off, the seconds work correctly for me.

I also used the System.println debug console and it also shows me the true and false values ​​correctly.

Thank you

  • hi, may be something else, I haven't tested it again but accessing the storage inside onPartialUpdate make it exceed the timeLimite after some time, you should try to store your Storage.getValue(3) inside a var you initialize somewhere else. That might be your issue

  • Yes, this is exactly what is happening to me...
    Can you write me and give an example of how to fix it?

  • Yes, anything that hits the file system in onPartialUpdate (except doing println calls) will cause the budget to be exceeded at the top of the next minute if not before.

    So things like doing the getValue should be done outside/before of onPartialUpdate.

  • as I wrote: you should try to store your Storage.getValue(3) inside a var you initialize somewhere else. 

  • and according all the things I've read here, should avoid also in onUpdate ?

  • source code.

     function onUpdate(dc) 
        {
     
            var clockTime = System.getClockTime();
            View.onUpdate(dc);
            if(partialUpdatesAllowed) 
            {
            dc.clearClip();
            }
            
            dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_BLACK);
            dc.clear();
            if( partialUpdatesAllowed && mAlwaysOnSec) 
            {
    
                onPartialUpdate(dc);
            } else if (isAwake) {
                dc.drawText(x,y, Graphics.FONT_XTINY, clockTime.sec.format("%02d"), Graphics.TEXT_JUSTIFY_LEFT);
            }
        }
    
        function onPartialUpdate( dc ) 
        {
        if( Storage.getValue(3)==true)) 
        {            
            var clockTime = System.getClockTime();
            var value = clockTime.sec.format("%02d");
            dc.setClip(x,y,w,h);
            dc.setColor(Graphics.COLOR_RED, Graphics.COLOR_BLACK);
            dc.clear();
            dc.drawText(x, y, Graphics.FONT_XTINY, value, Graphics.TEXT_JUSTIFY_LEFT);              
            }
        }   

  • ok, so inside your:

    class NAMEOFYOURAppView, put a var, let's say AoS:

    class NAMEOFYOURAppView extends Ui.WatchFace {
    var Aos = false;
    }
    then inside for exemple  function initialize()
    put AoS = Storage.getValue(3);
    function initialize(){
    AoS = Storage.getValue(3);
    }
    then replace inside your 
    function onPartialUpdate( dc ) {} replace Storage.getValue(3) with AoS;
    of course don't forget to deal with the AoS variable if an user changes the settings.
  • Keep in mind that some of the answers may be useful to others who are looking for answers and solutions in the area of ​​application development here on this forum...

    according your words, why did you delete your "source code"? other could learn from your mistake?