Pages

Sunday 26 September 2010

RotateScreen for Nokia N900





















The steps to create and install rotate.py are:

1.Create the python file (or download at the end of post, then
go directly to step 4). For this we use, for
example, the ConTEXT.

2.Copiamos and paste the following lines:

from ctypes import *
import os
import sys
import time
from math import atan2
from pprint import pprint

cdll.LoadLibrary xlib = ( "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

get_rotation print ()

def rotate (angle):
rr.XRRSetScreenCon **** ndRate (display, config, root, s ize, angle, rate, timestamp)

display = xlib.XOpenDisplay (os.getenv ( "DISPLAY"))
screen = xlib.XDefaultScreen (display)
root = xlib.XDefaultRootWindow (display, screen)

XRRScreenConfiguration class (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)

c_ushort rotation = ()
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.Guarde the document with the name rotate.py (PY is the Python file extension)

4.Copiar in a file folder rotate.py N900.

5.Iniciamos xterm on N900 and type:
python rotate.py


Download

No comments:

VISITORS