My Python program shall run in background and it hast to do something every 5 minutes. Does anyone know the best method to save battery? I tried using e32.Ao_timer(), this rapidly empties my N95 battery.
My Python program shall run in background and it hast to do something every 5 minutes. Does anyone know the best method to save battery? I tried using e32.Ao_timer(), this rapidly empties my N95 battery.
can you tell me what was the code you used with appswitch for running in background?!
My first step was not to use appswitch but start the program an put it into background manually.
The code ist like this:
class Scheduler(object):
iIntervalMin=20
def __init__(self):
self._timer = e32.Ao_timer()
def set_timer(self,ixIntervallMin):
self._timer.cancel()
self.iIntervallMin = ixIntervallMin
self.start_timer()
def start_timer(self):
self._timer.after(self.iIntervallMin*60, self.handler)
def __del__(self):
self._timer.cancel()
def handler(self):
self.start_timer()
DoSomethingEvery20Minutes()
app_lock = e32.Ao_lock()
app.exit_key_handler=EndProgram
scheduler = Scheduler()
while running:
e32.ao_yield()
thanks!!! but my application rotates the screen automactily with the N95 rotation sensor, this code should make it rotate in menus and apps too?
Pankaj Nathani
www.croozeus.com
I was worried about the power consumption of e32.Ao_timer() too. So I tried to estimate the power consumption with Nokia's Energy Profiler http://www.forum.nokia.com/main/reso...ergy_profiler/. Although I used an interval of just 5 seconds I couldn't detect any significant differences in power consumption over a period of 15 min compared to 'idle'. A test program which ran in background with 1 min update interval didn't cause any noticeable battery drain when running for about 10 days. Done with 1.4.1 on a 6120 classic.
Martin