Hi.
I'm very new to programming in python.
Therefore, the code i have written consumes too much energy, and i don't really know where the problem could be.
I'd be very thankful for help.
I know, my code is a mess. proboably very "noobish". But since the code is working, I need a solution for my energy-problem.Code:import appuifw import e32 import telephone try: import miso misoon = True except: misoon = False try: import envy envyon = True except: envyon = False # unprotected UID SYMBIAN_UID = 0xFFFFFFFF SIS_VERSION = "0.5.1" TITLE=u'abcd' VERSION=TITLE + ' ' + SIS_VERSION STATES = {telephone.EStatusUnknown: "unknown", telephone.EStatusIdle: "idle", telephone.EStatusDialling: "dialing", telephone.EStatusRinging: "ringing", telephone.EStatusAnswering: "answering", telephone.EStatusConnecting: "connecting", telephone.EStatusConnected: "connected", telephone.EStatusReconnectPending: "reconnect pending", telephone.EStatusDisconnecting: "disconnecting", telephone.EStatusHold: "hold", telephone.EStatusTransferring: "transferring", telephone.EStatusTransferAlerting: "transfer alerting"}; def handleCall((callState, number)): print "callState = "+STATES[callState] if callState == telephone.EStatusRinging: if number == "": print "incoming call" else: print "call from "+number elif callState == telephone.EStatusDialling: miso.vibrate(40000,1) elif callState == telephone.EStatusConnected: miso.vibrate(40000,0) elif callState == telephone.EStatusDisconnecting: miso.vibrate(40000,0) print "hung up" def quit(): global running running=0 appuifw.app.set_exit() def show_help(): appuifw.note(u"I said the RED KEY!","info", 1) def test_vibrate(): miso.vibrate(1000,1) def shout(): index = lb.current() if index == 0: show_help() elif index == 1: test_vibrate() elif index == 2: quit() if envyon == True: envy.set_app_system(1) else: appuifw.note(u"Envy is missing!",'error') if misoon == False: appuifw.note(u"Miso is missing!",'error') print "waiting for a call" entries = [u"Hide with RED KEY",u"Test vibration",u"Quit"] lb = appuifw.Listbox(entries,shout) app_lock=e32.Ao_lock() appuifw.app.body = lb running = 1 old_title = appuifw.app.title appuifw.app.title = TITLE appuifw.app.menu = [(u"Hide with RED KEY", show_help),(u"Test vibration", test_vibrate),(u"Quit", quit)] appuifw.app.exit_key_handler = quit while running: global STATES telephone.incoming_call() telephone.call_state(handleCall) e32.ao_yield() appuifw.app.title = old_title
Kind regards...

Reply With Quote


