You Are Here:

Community: Developer Discussion Boards

#1 Old Help. My app consumes to much energy - 2008-05-08, 13:46

Join Date: Mar 2008
Posts: 35
Location: Frankfurt, Germany
szallah
Offline
Registered User
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
I know, my code is a mess. proboably very "noobish". But since the code is working, I need a solution for my energy-problem.

Kind regards...
Last edited by szallah : 2008-05-08 at 19:55.
Reply With Quote

#2 Old Re: Help. My app consumes to much energy - 2008-05-08, 14:39

Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
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
Reply With Quote

#3 Old Re: Help. My app consumes to much energy - 2008-05-08, 19:57

Join Date: Mar 2008
Posts: 35
Location: Frankfurt, Germany
szallah
Offline
Registered User
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...
Reply With Quote

#4 Old Re: Help. My app consumes to much energy - 2008-05-09, 00:18

Join Date: Mar 2003
Posts: 937
Location: Espoo, Finland
JOM's Avatar
JOM
Offline
Forum Nokia Champion
Hi,

I would guess miso.vibrate() uses also quite a lot of energy?

Cheers,

--jouni
Reply With Quote

#5 Old Re: Help. My app consumes to much energy - 2008-05-09, 02:10

Join Date: Mar 2008
Posts: 35
Location: Frankfurt, Germany
szallah
Offline
Registered User
@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 With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
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

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d81449X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZpythonQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZuserE5ftagQSxpythonX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ