Battery consumption optimization for WatchFace

hye evereyone,

i've made lot of rechearch to try to gathering information about battery optimization for watchface but more or less in vain.

I was told by Jim:

- not do the 

App.getApp().getProperty("XXX");
Iin on Update for watchface settings 

it is the only trick I've found so far.

I'm quite lazy and for exemple i did this for 3 data filed I have on a watchface:

		var P = ["C","L","R"];
		var Ps = ["LDC","LDL","LDR"];
		var y=185;
		if (gH<240){y=170;}
		if (gH<200){y=140;}  
	
		    	for (var i=0;i<3;i++){
		    		data = App.getApp().getProperty(Ps[i]);
					if (data==2){DrawNot(dc,P[i],y,CLR1,CLR2);}
					if (data==3){DrawBat(dc,P[i],y,CLR1,CLR2);}
					if (data==4){DrawHR(dc,P[i],y,CLR1,CLR2);}
					if (data==5){DrawElv(dc,P[i],y,CLR1,CLR2);}
					if (data==6){DrawPress(dc,P[i],y,CLR1,CLR2);}
					if (Sys.getDeviceSettings().activityTrackingOn){	
						if (data==7){DrawSteps(dc,P[i],y,CLR1,CLR2);}
						if (data==8){DrawFloor(dc,P[i],y,CLR1,CLR2);}
						if (data==9){DrawKcal(dc,P[i],y,CLR1,CLR2);}
						if (data==10){DrawActive(dc,P[i],y,CLR1,CLR2);}
						if (data==15){DrawDist(dc,P[i],y,CLR1,CLR2);}
					}
					if (data==11 && PRO){DrawNSE(dc,P[i],y,CLR1,CLR2);}
					if (data==12 && PRO){DrawUNSE(dc,P[i],y,CLR1,CLR2);}
					if (data==13 && PRO){DrawWeather(dc,P[i],y,CLR1,CLR2,"");}
					if (data==14 && PRO){DrawStatus(dc,P[i],y,CLR1,CLR2);alarm =false;}
				}
			}

is it a good way to do? for memory or battery?

does anyone has tricks for saving battery?

  • One place to look is if you use onPartialUpdate(), as that runs every second 24/7, vs onUpdate() that only runs once a minute most times.

    And to see what's going on, in the sim, there's File>View Watchface Diagnostics

    The very first number will be showing you how you're doing in relation to the 30ms power budget.  If you're sitting at a total time of 29000 you're pretty close to that 30ms.  A WF I'm currently running in the sim is under 7400 for comparison.  The other 3 numbers show you how that time is spent and can help to optimize things.

    That watchface over 8hrs last night on a fr945, dropped the battery by ~1%, so that's something else to look at - how it works on a watch to see if you even have a battery issue, and how big the issue it might be.

  • OK thanks 

    The diagnostics is

    18,18,0,0

    So it May be a coïncidence, the leak of battery doesn't seem come from this watchface... 

    Since I use it, my device get from 0.4% /hr to 1.4...

  • There are things with the overall design of a watch face that can have impact on battery, and these may be things you don't want to change and can't do much about.

    Once again with onPartialUpdate(), is how "tall" the clip region is for seconds/etc.  The shorter the better.

    Also, using custom fonts is a harder hit on the battery than using native fonts.

  • That the odd thing, I dont use any onpartialupdate on this WF. 

  • It is pretty hard to know what will execute faster, and if a difference will actually amount to a noticeable improvement to battery life without direct testing. 

    I'm not sure if it would be significantly better for power or memory, but this code would be cleaner if you used an array of symbols or method objects.

    Something of this nature:

    //Initialize this when the app starts.
    var drawSymbols = [ null, null, :DrawNot, :DrawBat, :DrawHR, ... ];
    
    for (var i=0;i<3;i++){
        var data = App.getApp().getProperty(Ps[i]);
        if(data < NUM_METHODS){
            //method is relative to the current object. 
            //This only works if the :Draw* functions are in this object
            var func = method(drawSymbols[data]);
            if(func != null) {
                func.invoke(dc,P[i],y,CLR1,CLR2);
            }
        }
    }

    I'd also recommend using enumerations instead of strings for things like your P[i] arguments. Constructing, and comparing strings is going to be much more expensive than using integers.

  • Do you really think, custom fonts are more expensive than native once? The graphic processor has to render the fonts anyway!?

  • Wow, one percent per night is really a cool value. I have optimized my watchfaces as well regarding power, but get around 0.3 percent per hour, causes the watchface to consume 2.4 percent in 8 hours. 

  • It will vary based on the watch and the size of it's battery.  Did you mean .3% per hour?

  • Thank you very much for this !!!

    It makes me save lots of memory !!!

    Very nice 

  • Exactly, per hour. And I own an fr945 as well