×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    3

    Rotation control on S60 9.3

    Hello all!
    I'm not entirely new to py60 (or to python in general) but since trying to use carbide.c++ lead me to huge frustrations, I went back to try writing a simple app using python.
    Back when I had my N73, things were - IMHO - a bit more simple, but today coding simple apps to my N85 can be very confusing at times.

    I'm trying, for the time being, to write a code that would enable me to stop or start the auto-rotation of the screen.
    I tried using the .accelerometer, the .orientation and the .rotation functions, but neither of them worked (so I temporary put ALL of them in - please ignore that for the time being):

    Code:
    from sensor import *
    import e32
    import appuifw
    
    class SENSE():
        
        def __init__(self):
            self.rotation = RotationData()
            self.orientation = OrientationData()
            self.accelerometer = AccelerometerXYZAxisData()
    
        def _menu(self):
            flag = 1
            while (flag!=0):
                Selection = appuifw.popup_menu([u'Turn OFF', u'Turn ON', u'Quit...'])
                if (Selection == 0):
                    self.rotation.stop_listening()
                    self.orientation.stop_listening()
                    self.accelerometer.stop_listening()
                    Selection = appuifw.note(u"OFF!", 'info')
                elif (Selection == 1):
                    self.rotation.start_listening()
                    self.orientation.start_listening()
                    self.accelerometer.start_listening()
                    Selection = appuifw.note(u"ON!", 'info')
                elif (Selection == 2):
                    flag = 0
                    
    if __name__ == '__main__':
        app = SENSE()
        app._menu()
        e32.ao_sleep(1)
        app.rotation.stop_listening()
        app.orientation.stop_listening()
        app.accelerometer.stop_listening()
        print "Exiting SENSE"
        print ""
    Running the menu and choosing to stop_listening does not prevent the screen to auto-rotate when I tilt the phone...
    BTW, I installed the 1.9.2 runtime and scriptshell on the phone, and yes, I know the code is not elegant and I'm sorry - but first I want this piece of code to work properly, and only then I'll refine the code to be more elegant

  2. #2
    Regular Contributor
    Join Date
    Oct 2007
    Posts
    114

    Re: Rotation control on S60 9.3

    Quote Originally Posted by efekt View Post
    <snip>

    I'm trying, for the time being, to write a code that would enable me to stop or start the auto-rotation of the screen.
    <snip>
    Running the menu and choosing to stop_listening does not prevent the screen to auto-rotate when I tilt the phone...
    This rotation sensor object does not or rather cannot control the auto-rotation of the screen. Using this rotation sensor object you can listen to the rotation sensor channel and only get the current values of x, y and z axis angles. The auto-rotation of the screen is controlled by the setting on the phone and this module does not give an interface to enable or disable that setting.

    In your code if you do self.rotation.set_callback(my_func) before start_listening, this function will be called when new data is available from the rotation sensor channel. In this function you can check the x,y and z angles as self.rotation.x, self.rotation.y and self.rotation.z for their respective values. The callback function will stop receiving updates when stop_listening is called.
    import antigravity

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    3

    Re: Rotation control on S60 9.3

    Thank you for your reply.
    So, is there isn't any way I could easily turn off/on the rotation of the screen with a simple command? I'm well aware of the option to turn the rotation on or off in the phone's settings - as I obviously turned it on myself, but I'm looking into turn it off or on by code.
    The N-GAGE application does that (disable rotation once activated) so I figured there's a way I could do that too...

  4. #4
    Registered User
    Join Date
    Jul 2008
    Posts
    3

    Re: Rotation control on S60 9.3

    Sorry for jumping this thread, but I'm really interested in an answer: Is there a simple solution to turn off the automatic rotation of the screen?

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

    Re: Rotation control on S60 9.3

    Quote Originally Posted by efekt View Post
    Sorry for jumping this thread, but I'm really interested in an answer: Is there a simple solution to turn off the automatic rotation of the screen?
    I'm really missing something here, but could this be what you're asking:

    Code:
    appuifw.app.orientation = 'portrait'
    That fixes screen to portrait == vertical mode.

    Puzzled,

    --jouni

  6. #6
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Re: Rotation control on S60 9.3

    Quote Originally Posted by efekt View Post
    Sorry for jumping this thread, but I'm really interested in an answer: Is there a simple solution to turn off the automatic rotation of the screen?
    Well, as JOM said, you can use appuifw.app.orientation = 'portrait'. But, something to regard is that this will only avoid the auto rotation inside your application. There is no way to switch the rotation settings of the phone by code, only manually, on Settings application



    BR,

    Rafael.

Similar Threads

  1. Python for S60 1.9.0 released
    By tvijayan in forum Symbian
    Replies: 48
    Last Post: 2009-01-27, 15:39
  2. S60 9.3 beta SDK resource size limit?
    By Sectoid in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2008-01-14, 11:59
  3. Disabling auto gain control for the mics - S60 platforms
    By mandargandhe in forum Symbian Media (Closed)
    Replies: 0
    Last Post: 2007-01-16, 18:05
  4. AppUi - Control communication.
    By Subotai4Winds in forum Symbian
    Replies: 1
    Last Post: 2005-01-20, 08:53

Posting Permissions

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