×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Mar 2008
    Location
    Frankfurt, Germany
    Posts
    35

    Help. My app consumes to much energy

    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 18:55.

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Help. My app consumes to much energy

    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

  3. #3
    Registered User
    Join Date
    Mar 2008
    Location
    Frankfurt, Germany
    Posts
    35

    Re: Help. My app consumes to much energy

    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...

  4. #4
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: Help. My app consumes to much energy

    Hi,

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

    Cheers,

    --jouni

  5. #5
    Registered User
    Join Date
    Mar 2008
    Location
    Frankfurt, Germany
    Posts
    35

    Re: Help. My app consumes to much energy

    @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.

Similar Threads

  1. Changing App Mgr settings from J2ME app
    By ddbhasin in forum Mobile Java General
    Replies: 6
    Last Post: 2007-09-21, 07:18
  2. why my app is not shown in emulator?....due to i have change UID
    By bharats in forum Symbian Tools & SDKs
    Replies: 3
    Last Post: 2007-09-12, 06:49
  3. renaming app, how??
    By Audun Holme in forum Symbian
    Replies: 2
    Last Post: 2007-05-13, 12:10
  4. Dialog's clipping area (again). Nokia experts, please help
    By synov in forum Symbian User Interface
    Replies: 0
    Last Post: 2004-06-26, 14:35
  5. 7650 - go back, close my app not closing the container app
    By geran in forum Digital Rights Management & Content Downloading
    Replies: 1
    Last Post: 2002-12-05, 09:58

Posting Permissions

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