aod coding and on which devices to add this feature?

Hey, I am looking to add a AOD feature to my watch with only the time, date and battery showing up. I have tried to reach a guide or a post in the forum but found nothing on the internet or in the garmin connect iq. How do I even set this up and can I make this feature for all of the devices?

  • See the section for AMOLED.  The Venu sq is the same, but isn't AMOLED.

    https://forums.garmin.com/developer/connect-iq/b/news-announcements/posts/connect-iq-3-1-now-available

    You can use file>view heat map in the sim to see what's going on the low power.

  • Thank you jim, so just to make sure that I got it right, in AMOLED I need to use WatchUi.onEnterSleep and then make the text for the watch face. I need to use thin fonts and get the pixels to move (every minute for instance). In MIP (not AMOLED) I can use View.onPartialUpdate and use it for the middle of my watch without time limitation or any need to move the location of the pixels used.

    I can determine the screen type easily with if (DeviceSettings.requiresBurnInProtection == true) {settings for AMOLED;}

    else {settings for MIP;}

    And the very last question is how can I cause the pixels to move?

  • It depends a bit on your code.  In onEnterSleep, I set a boolen and in onExitSleep, I clear it and then in onUpdate, I can see if I'm in low power mode or not.  And then it's low power andrequiresBurninProtection=true is then code that fits the requirements is used - no more than 10% of the pixels and no pixel on for more than 3 minutes.

  • Hey jim, I've started working on it. I tried to use the same lines as I used in onUpdate in the onEnterSleep(). I've seen that the var don't work in onEnterSleep(). The code looks like this:

    if(DeviceSettings.requiresBurnInProtection == true) {
    		dc.setColor(SelectedColor, Graphics.COLOR_TRANSPARENT);
            if (Application.getApp().getProperty("ShowLeadingZero") == true) {dc.drawText(dc.getWidth() / 2.1, dc.getHeight()*0.32452, customFont, myHr.format("%02d"), Graphics.TEXT_JUSTIFY_RIGHT);}
            if (Application.getApp().getProperty("ShowLeadingZero") == false) {dc.drawText(dc.getWidth() / 2.1, dc.getHeight()*0.32452, customFont, myHr.format("%d"), Graphics.TEXT_JUSTIFY_RIGHT);}
            dc.drawText(dc.getWidth() / 2, dc.getHeight()*0.2284, dateFont, dateString, Graphics.TEXT_JUSTIFY_CENTER);
            if (Application.getApp().getProperty("ShowSeconds") == true) {
            dc.drawText(dc.getWidth() *0.8534, dc.getHeight()*0.46875, secFont, Lang.format("$1$", [clockTime.sec.format("%02d")]), Graphics.TEXT_JUSTIFY_LEFT);}
            if (!System.getDeviceSettings().is24Hour) {dc.drawText(dc.getWidth() *0.8534, dc.getHeight()*0.37981, secFont, myAmPm , Graphics.TEXT_JUSTIFY_LEFT);}
            dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
            dc.drawText(dc.getWidth() / 2.1, dc.getHeight()*0.32452, customFont, ":" + Lang.format("$1$", [clockTime.min.format("%02d")]), Graphics.TEXT_JUSTIFY_LEFT);
            }
    And the errors I get are those:

    BUILD: ERROR: C:\temp\eclipse-workspace\Digital Elegant4\source\DigitalElegantView.mc:190:  Undefined symbol "SelectedColor" detected.
    BUILD: ERROR: C:\temp\eclipse-workspace\Digital Elegant4\source\DigitalElegantView.mc:191:  Undefined symbol "myHr" detected.
    BUILD: ERROR: C:\temp\eclipse-workspace\Digital Elegant4\source\DigitalElegantView.mc:192:  Undefined symbol "myHr" detected.
    BUILD: ERROR: C:\temp\eclipse-workspace\Digital Elegant4\source\DigitalElegantView.mc:195:  Undefined symbol "clockTime" detected.
    BUILD: ERROR: C:\temp\eclipse-workspace\Digital Elegant4\source\DigitalElegantView.mc:196:  Undefined symbol "myAmPm" detected.
    BUILD: ERROR: C:\temp\eclipse-workspace\Digital Elegant4\source\DigitalElegantView.mc:198:  Undefined symbol "clockTime" detected.
    How can I pass this problem, I want to make sure my code works in the onEnterSleep() before I try to cause the pixels to move. BTW, my idea to cause the pixels to move is this:
    var extra = null;
    var minNum;
    minNum = clockTime.min.toNum();
    if (minNum%2 == 1){extra = dc.getHeight/2;}
    if (minNum%2 == 0){extra = 0;}

    and then add extra to the the y of all the texts I want to add.

  • Hi,

    Pretty sure because your Var is declared on onUpdate, so they does not exist on onEnterSleep.

    Like Jim said, I think it is because to create à function for amoled which is called on OnUpdate and use onEnterSleep etc to set a flag 

  • Hi Shent-Aurkhan, I didn't understand how to do the part the part of In "onEnterSleep, I set a boolen and in onExitSleep, I clear it and then in onUpdate, I can see if I'm in low power mode or not" that Jim said. I thought that for now it will be better to start with something and then optimize it but I guessing that it is worse then optimize from the beginning. Can you or explain to me how to create it?

  • hi, 

    with all the elements given to you, you could find it on your own, I mean your learning would be better if you find the solution on your own, don't you think?

    Basicaly, here is how I do:

    var AODflag=false;
    
    onUpdate(){
        //CODE YOU WANT ON ALL VIEW
        //for exemple only time and date
    
        if (!AODflag){
            //CODE ONLY WHEN BURN PROTECTION IS FALSE
            //for exemple the data field etc
        }
    }
    
    
    
    onEnterSleep(){
        if(System.getDeviceSettings() has :requiresBurnInProtection && System.getDeviceSettings().requiresBurnInProtection){AODflag=true;}
    }
    
    
    
    onExitSleep(){AODflag=false;}

    you can use the same process to detect if your device is in LowPower or HighPower, for exemple to display seconds only on gesture.

    EDIT: I forgot to add, on onUpdate()

    you will want to add:

    if(AODflag){

    //Draw black line which move every 3minutes

    }

  • hi, 

    with all the elements given to you, you could find it on your own, I mean your learning would be better if you find the solution on your own, don't you think?

    Basicaly, here is how I do:

    var AODflag=false;
    
    onUpdate(){
        //CODE YOU WANT ON ALL VIEW
        //for exemple only time and date
    
        if (!AODflag){
            //CODE ONLY WHEN BURN PROTECTION IS FALSE
            //for exemple the data field etc
        }
    }
    
    
    
    onEnterSleep(){
        if(System.getDeviceSettings() has :requiresBurnInProtection && System.getDeviceSettings().requiresBurnInProtection){AODflag=true;}
    }
    
    
    
    onExitSleep(){AODflag=false;}

    you can use the same process to detect if your device is in LowPower or HighPower, for exemple to display seconds only on gesture.

    EDIT: I forgot to add, on onUpdate()

    you will want to add:

    if(AODflag){

    //Draw black line which move every 3minutes

    }

    in my case:

    if(AODflag){
    dc.setColor(0, 0);var y=clockTime.min%3;
    for(var i=0;i<gH/2.5;i=i+2){dc.fillRectangle(0,gH/3.0+i+y, gW, 1);}
    }

    where gH is dc.getHeigh and gW is dc.getWidth

  • Wooooooooooow I've just noticed that SQ are not amoled...Thanks...

  • Here's the very basics of what I do

    class MyView extends WatchUi.WatchFace {
    
    	var inLowPower=false;
    	var canBurnIn=false;
    	
        function initialize() {
            WatchFace.initialize();
    
            if(Sys.getDeviceSettings() has :requiresBurnInProtection) {       
            	canBurnIn=Sys.getDeviceSettings().requiresBurnInProtection;        	
            }
        }
        
        function onUpdate(dc) {
            if(inLowPower && canBurnIn) {
                //do AOD display (<10%. 3 minutes max)
            } else {
                // regular display
            }
        }
        
        function onExitSleep() {
        	inLowPower=false;
        	WatchUi.requestUpdate();
        }
    
        function onEnterSleep() {
        	inLowPower=true;
        	WatchUi.requestUpdate();    
        }
    }