RotateScreen for Nokia N900

Rotate is a  Python script to activate the automatic rotation of the screen of our Nokia N900 and change to landscape or portrait mode automatically.

 

rotatescreen N900 RotateScreen for Nokia N900

 


The steps to create and install rotate.py are:

 

  1. Create the file in python (or download at the end of post, then go directly to step 4). we can use, for example, the program ConTEXT.
  2. Copy and paste the following lines :

     

    from ctypes import *
    import os
    import sys
    import time
    from math import atan2
    from pprint import pprint
    xlib = cdll.LoadLibrary("libX11.so.6")
    rr = cdll.LoadLibrary("libXrandr.so.2")
    def get_rotation():
        f = open("/sys/class/i2c-adapter/i2c-3/3-001d/coord", 'r' )
        coords = [int(w) for w in f.readline().split()]
        f.close()
        return coords
    print get_rotation()
    def rotate(angle):
        rr.XRRSetScreenConfigAndRate(display,config,root,size,angle,rate,timestamp)
    display = xlib.XOpenDisplay(os.getenv("DISPLAY"))
    screen = xlib.XDefaultScreen(display)
    root = xlib.XDefaultRootWindow(display, screen)
    class XRRScreenConfiguration(Structure):
       pass
    gsi = rr.XRRGetScreenInfo
    gsi.restype = POINTER(XRRScreenConfiguration)
    config = gsi(display, root)
    current_time = c_ulong()
    rr.XRRTimes.restpye = c_ulong
    timestamp = rr.XRRTimes(display, screen, byref(current_time))
    xccr = rr.XRRConfigCurrentRate
    xccr.restype = c_int
    rate = xccr(config)
    rotation = c_ushort()
    size = rr.XRRConfigCurrentConfiguration(config, byref(rotation))
    while True:
        [x,y,z] = get_rotation()
        print x,y,z
        if y < -500:
            rotate(1)
        elif y > 500:
            rotate(4)
        elif x < -500:
            rotate(2)
        elif x > 500:
            rotate(8)
        time.sleep(1)
    
  3. Save the document with the name rotate.py (PY is the Python file extension)
  4. Copy in a folder on the N900 the file rotate.py.
  5. Start xterm on N900 and type :
    python rotate.py

 

Download | rotate.py

Via | HDBlog.it



This entry was posted in Maemo Applications and tagged , , , , . Bookmark the permalink.
Related Posts:

74 Responses to RotateScreen for Nokia N900

  1. Renos says:

    if you want to deactivate it how can you do it?

  2. Norga says:

    Please can you help me because its not working in my phone can you give me more details or a video how can i do that with my phone .
    Thanks

  3. RikiSky says:

    I thought that nokia was working on this for the next firmware update?… i’m guessing you couldn’t wait? xD

  4. Antonio Andrade says:

    Hi,

    I’m receiving a syntaxerror on line 21:
    rr.XRRSetScreenCon****ndRate(display,config,root,size,angle,rate,timestamp)

    Are you sure about the function “XRRSetScreenCon****ndRate”?

  5. kakalos says:

    it tells me syntax error:invalid syntax on line 20 : rr.XRRSetScreenCon****ndRate(display,config,root,size,angle,rate,timestamp)

  6. Deathlar says:

    This script only controls landscape mode of the phone application, or is it something to rotate some other parts of the phone we´re all waiting for so long?

  7. n900 user says:

    not working on my n900. Xterm gives me an error2 msg =(

  8. Describe says:

    where i download Python app ?

  9. Deathlar says:

    OK, i tryed to run the script, but in the lust step i got stuck, my xTerm doesnt seem to be able to find the rotate.py, where is it supposed to be stored?? i got it MyDocuments

  10. Shindo says:

    i followd the instructions but it didnt work…
    could find the script/path

  11. paul says:

    this isnt clear please could you help

  12. kai says:

    Very nice improvisation! Any idea how much battery it would consume to leave the script running in the background?

  13. zod says:

    You need something else at the end besides python rotate.py?.

  14. admin says:

    Ok, you change line 21, the new line 21 is: rr.XRRSetScreenConfigAndRate(display,config,root,size,angle,rate,timestamp).

  15. Antonio Andrade says:

    It works! Is there any way to start this script when the phone is turn on?

  16. Norga says:

    Please can sombody tell me how to fix it on my phone i need some advise?

  17. hjz says:

    it doesn’t work with mine. The xterm replies “can’t open file ‘rotate.py’ :( errorno 2) no such file or directory. Needs help. Thanks.

  18. FX says:

    hi everybody,

    I have the error : error 2 “no such file or directory” .
    How can we resolve this problem ???

    I have put rotate.py in my documents

    Please help us !!
    thx u

  19. Deathlar says:

    I start the script, and there is just a bunch of numbers going on screen in format like : 18 -432 -936… how long does it takes to rotate the screen?? ia this what is supposed to happend??

  20. adan says:

    it keeps saying error no such file or directory. where am i supposed to put the file

  21. jhonathan says:

    well I have tried but x-terminal doesnt find the file….why? maybe it is because we are not saving in the right folder?

  22. qUaLiTy says:

    The script worked just “fine”. Is not good enough; you have to leave Xterm running on the background, the rotation does not rearrange the icons..it just flip! Its not very useful.

  23. BigBalls says:

    put it in documents then type

    cd MyDocs

    then python rotate.py.

    then just leave the script running in the background, to turn it off close xterminal however portrait mode does not fit the screen properly more of a novelty thing really

  24. Mikula says:

    Use basic unix bash commands in X-Terminal to go tho the folder you saved the file.

    ls = directory listing
    cd .. = directory up
    cd foldername = enter dir

  25. G says:

    i will answer the question. You have save the file on the root of the Nokia N900 drive and then enter in the xterm : cd MyDocs
    and the : python rotate.py

  26. estanis says:

    please show how to run this script! where put the file rotate.py?

  27. Tc says:

    useless

    thanks

  28. erkk says:

    yea put in the root and make sure you type cd MyDocs not cdmydocs

    it is case sensitive

  29. erkk says:

    not worth the try though nothing works but in a quarter margin of the actual landscape size and my phone has rebooted from using it barely

  30. The Eagle says:

    i do think that all what has been said doesn’t have any importance. the fact is that there is no way to make autorotaion in nokia n900, till Nokia will luch another firmware with the auto rotation.that’s it.

  31. f2thak says:

    1. copy rotate.py to root dir /

    2. open xterm:

    root [enter]
    cd / [enter]
    python rotate.py [enter]

    3. minimize window and rotate phone!

  32. batii says:

    hi F2THAKel can you tell as where is a root dir??? i have file rotate.py but i can’t find root dir pleas can you help??

  33. teo says:

    Root its not a directory. Just put rotate.py in your .documents folder connecting n900 to your computer.
    1.Start xterm and run “cd MyDocs/.documents” without ” and [enter]
    2.Run “python rotate.py” without “, [enter] and voila!

    If u want to “disable” the rotation just close xterm.

  34. batii says:

    sorry but I think that unless I am doing something bad or something is wrong with my phone This is how I am doing i have rotate.py in the documents now i open xterm and writes”
    “cd MyDocs/.documents” without ”
    “python rotate.py” without “, “and nothing????

  35. tarinder says:

    guys..the only thing you need to do to activate auto rotation is:
    . open xterminal
    now you must have saved that rotate.py in your documents. make sure it is saved in a right place. else xterminal will not recognize.
    . type “cd MyDocs”and press enter
    . type “python rotate.pc” and press anter
    and then it should start displaying some sort numbers.
    just minimixe the xterminal and try rotating your phone and it should work..
    WARNING: Using this programme can effect your batterly life badly. as the programme doesnot have any importance to use.
    Suggession: only use if you really need to.

  36. superg05 says:

    nokia is lazy can’t wait tell intel gets into the fray

  37. pyethonee says:

    it worked. but screen is not flexible. icons hide and lower part of screen does not work.

  38. Oakbeach says:

    Hey,

    Thanks for the script!
    Thank you for showing the functionality of python scripting on n900.

    Question to the people complaining, why on earth did you guys by a n900? I don’t get it.

    This is a phone for people that is interested in linux, scripting, development, people who don’t whine whenever they run into a problem.

    If you want a standard phone, go buy iPhone!

  39. ahmad says:

    i download it and put in .documents and i followed the steps but nothing appeared

  40. Darko35 says:

    Actually you dont have to download anything at all. The potrait mode for the web browser is already inputed. All you have to do is Press three buttons. (control), (shift), and (O) all at the same time. I hope this helps out alot and saves time from inputing commands into the Xterminal.

  41. amirlol says:

    thanks !
    very very nice and Qu

  42. Roland says:

    A bit useless app, however it worked well for me, but still…useless :) But good work. If it would flip the icons – would be just perfect app ;)

  43. Shinigami says:

    To deactivate it only stop the HS and put on again : Cause at any boots of N900 U’ve to do the command to use it.

    For me it’s ok but it isn’t comfortable : The N900 booted by himself so use only one time. Must we let Xterm work in background ?

  44. kannuchi says:

    Ctrl + Shift + R makes this work with the leaked PR1.2.

  45. Pingback: RotateScreen – Портретная клавиатура для Nokia N900 | Nokia N900 Maemo Nokia N9 MeeGo Форум Программы Игры Ovi Store

  46. Inder says:

    for runing of rotete.py start X Term and
    go MyDocs from $ Prompt
    $ cd MyDocs (Type same because this is case sansative)and then python retate.py
    its work
    inder

  47. Sonny says:

    Follow these steps.
    1) Use your N900 device to download rotate.py given from the links above.
    2) save it in your documents in your N900 device
    3) open terminal or xterm
    4) type cd MyDocs
    5) Type python.rotate.py

  48. Naitik Shah says:

    I am not getting how to install that rotate.py nd where to save it???
    can any1 plzz help me out

  49. Naitik Shah says:

    Can any one please help me???? i am not getting where to save de file exactly…???
    Plzz it is a request

  50. gopal says:

    very nice nokia all mobiles parches for only one nokia mobiles
    thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>