08
Feb
RotateScreen for Nokia N900
Category: Applications
Tags : Applications, N900, Nokia, Nokia N900, RotateScreen
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.

The steps to create and install rotate.py are:
- 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.
- 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) - Save the document with the name rotate.py (PY is the Python file extension)
- Copy in a folder on the N900 the file rotate.py.
- Start xterm on N900 and type :
python rotate.py
Download | rotate.py
Via | HDBlog.it



if you want to deactivate it how can you do it?
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
I thought that nokia was working on this for the next firmware update?… i’m guessing you couldn’t wait? xD
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”?
it tells me syntax error:invalid syntax on line 20 : rr.XRRSetScreenCon****ndRate(display,config,root,size,angle,rate,timestamp)
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?
not working on my n900. Xterm gives me an error2 msg =(
where i download Python app ?
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
i followd the instructions but it didnt work…
could find the script/path
this isnt clear please could you help
Very nice improvisation! Any idea how much battery it would consume to leave the script running in the background?
You need something else at the end besides python rotate.py?.
Ok, you change line 21, the new line 21 is: rr.XRRSetScreenConfigAndRate(display,config,root,size,angle,rate,timestamp).
It works! Is there any way to start this script when the phone is turn on?
Please can sombody tell me how to fix it on my phone i need some advise?
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.
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
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??
it keeps saying error no such file or directory. where am i supposed to put the file
well I have tried but x-terminal doesnt find the file….why? maybe it is because we are not saving in the right folder?
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.
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
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
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
please show how to run this script! where put the file rotate.py?
useless
thanks
yea put in the root and make sure you type cd MyDocs not cdmydocs
it is case sensitive
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
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.
1. copy rotate.py to root dir /
2. open xterm:
root [enter]
cd / [enter]
python rotate.py [enter]
3. minimize window and rotate phone!
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??
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.
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????