| Reply | « Previous Thread | Next Thread » |
|
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. 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...
Last edited by szallah : 2008-05-08 at 19:55.
|
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Offline
Forum Nokia Champion
|
|
Hello szallah and welcome to the Python Discussion Board.
The high energy consumption is most likely due to the "while running" loop. Since you used "telephone.incoming_call()" and "telephone.call_state(handleCall)" to wait for a call, the way I see it there is no need for the loop. See also this discussion. Hope that helps ![]() |
|
thanks bogdan... the difference between with "while running" and without is around 0,5W (that's what the energy profiler said)...
seems to work perfect now... ![]() |
|
Hi,
I would guess miso.vibrate() uses also quite a lot of energy? Cheers, --jouni |
|
@JOM
of course it does. but vibrating is the purpose of my application, so there's really no other way. and, as far as i know, miso iss the only way to generate vibration. and by removing the while-running-loop everything is working fine now. |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Changing App Mgr settings from J2ME app | ddbhasin | Mobile Java General | 6 | 2007-09-21 08:18 |
| why my app is not shown in emulator?....due to i have change UID | bharats | Symbian Tools & SDKs | 3 | 2007-09-12 07:49 |
| renaming app, how?? | Audun Holme | General Symbian C++ | 2 | 2007-05-13 13:10 |
| Dialog's clipping area (again). Nokia experts, please help | synov | Symbian User Interface | 0 | 2004-06-26 15:35 |
| 7650 - go back, close my app not closing the container app | geran | Digital Rights Management & Content Downloading | 1 | 2002-12-05 10:58 |