In this post I will describe how you could enable the gyro-sensor for automatic display rotation under Ubuntu 10.10 (Should also work under all debian based os)
This post and delivered scripts are based on the work of arobase40 from http://ubuntuforums.org/
http://ubuntuforums.org/showthread.php?t=1486671&page=5
and Imarune from the french ubuntu forum.
Thanks for your nice job!
first step
1 2 3 4 5 6 7 | #become root sudo su - #add new startup modules echo -e "i2c-i801\ni2c-dev\nlis3lv02d_i2c" >> /etc/modules |
Info:
arobase40 describes in the mentioned forum post two more ways to access the gyro-sensor. I choose this way because, you do not need to compile the kernel or anything else, also the suspend modes works fine.
[dm]3[/dm]
Download this file and extract it.
The application i2c-gsensor is based on http://pof.eslack.org/blog/2008/06/03/i2c-gsensor-lis3lv02dl-accelerometer-on-htc-shift-g-sensor/
Change with the terminal into the extracted directory and run make!
You got the application i2c-gsensor. Copy the application and the script to /usr/bin/ and
set script and application execution rights with:
1 2 3 4 5 | sudo cp gyro-auto-rotate.run i2c-gsensor /usr/bin/ sudo chmod +x /usr/bin/i2c-gsensor sudo chmod +x /usr/bin/gyro-auto-rotate.run |
Now you could check if everything works:
1 2 3 4 5 6 7 | i2c-gsensor 0 [loop] #loop is optional if you want output in endless loop //0 specifies the i2c-bus, should be correct #if this works fine, you should see some xyz coordinates corresponding to the current notebook position #now check the auto rotation script: gyro-auto-rotate.run |
Turn around your notebook and the display should switch in the correct position (left and right correct for tablet mode).
If everything works fine you could add the script to System->Start programs
Is there a typo in the first line? I get this error
-su: syntax error near unexpected token `;&’
Sorry! I mean line 7 of the first panel.
Hey Andrew,
sorry I have overseen this failure. Now it is correct, the wordpress editor did a wrong conversion of >>
This is awesome though I have a feeling that the next release of Ubuntu will->should have this!
I don’t know if you have seen something like this but it would be very cool to have a desktop that can be scrolled between frames by swiping it sideways, up and down. This would be far better than going through the menus to list applications, control panels etc.
Hey mrsamo,
what you mentioned is the classical smartphone style in my opinion.
I have used something which works in a similar way. On the XFCE Desktop you could configure, that you switch to another desktop if you scroll over the desk edges. If you use this with a touchscreen…
But for me its not a important feature. On GNOME you could select the active desktop with one click in the bottom bar, thats fine.
i think i do something wrong. because i always get this msg:
Error: Could not open file `/dev/i2c-0′ or `/dev/i2c/0′: No such file or directory
can somebody help me?
@xinu:
Please check if /etc/modules is correct.
Check if you got it working with a different value than 0(1,2..) with
i2c-gsensor 0 [loop] #loop is optional if you want output in endless loop //0 specifies the i2c-bus, should be correct
it is working now! thanks a lot! how can i add the gyro-sensor script to the start-menu? (sorry, i am using ubuntu/linux for the first time 😉 )
@xinu:
I am very pleased to hear that. But please tell me what was wrong, maybe I could improve something or another reader maybe has the same problem.
To your question:
Do you really mean the menu? If yes, you could right on the ubuntu logo and select edit menu. In the shown form you are able to add a custom entry. In this custom entry you select the path to the script location.
Feel free to ask, if it’s not clear to you
ok, i know now what the problem was. i have to run the gyro script as root! otherwise it is not working for me. i know how to add the script but how can i add it and run it as root?
hmm, I use it with my normal user account. The only part of the script which needs root privileges is loading the modules, if you put the modules in /etc/modules it should run without root privileges.
But don’t forget to give your user execution priviliges with chmod +x script.run
If you really need root, do it like for synaptic in the system menu:
gksu /usr/sbin/synaptic
Hi, when I put this code on,
echo -e “i2c-i801\ni2c-dev\nlis3lv02d_i2c” >> /etc/modules”
this message appears
-su: syntax error near unexpected token `;&’
By the way, how can I move the application file to /usr/bin with terminal? I can’t move it as usual as it need permission…
Thanks in advance, God bless!
Never mind…I figured it out
Sorry, it was a mistake in my post wrong translation of symbols from the wordpress editor. I have corrected it.
Hi,
I still cannot get it to work.
I have a htc shift.
The modules file looks like this:
gebruiker@ubuntu:~$ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with “#” are ignored.
lp
i2c-i801
i2c-dev
lis3lv02d_i2c
gebruiker@ubuntu:~$ i2c-gsensor 0
Error: Could not open file `/dev/i2c-0′: Permission denied
Run as root?
Accelerometer not found
Then with sudo:
gebruiker@ubuntu:~$ sudo i2c-gsensor 0
Accelerometer not found
Is there somebody who can help?
Best regards,
Hans
Hey Hans,
please try other bus numbers, maybe on your notebook its 1 or 2 …
Hi Toffer, I tried nr 0 till 5 according to the /dev entries that are present.
After that I tried the i2c-gsensor script that pof wrote. Then I got the xyz numbers. But with the use with the gyro script nothing happend.
I tried to change the set i2c-gsensor 0 line to set i2c-gsensor, but with no luck.
for me it was 7
i read over that you have a htc shift. therefore you need to change the 0x3b value to 0x3a in the c code. have you done this?
[…] you want to start or stop my gyro-auto-rotation script (http://www.ceh-photo.de/blog/?p=186) with this button use following script: 12345678#!/bin/bash pid=$( pgrep gyro-auto-rotat ) […]
I am going to try this! Thanks for the replies!!!
Thankz! The i2c-sensor is working now. I now will have to check the gyro script.
I also tried and get the same error that Xinu and Hans: when i type “i2c-gsensor 0 [loop]” or “i2c-gsensor 0” i get the message:
Error: Could not open file `/dev/i2c-0′: Permission denied
Run as root?
Accelerometer not found
I could run the script as root (the “i2c-gesensor 0 [loop]” and the “gyro-auto-rotate.run”) and all is ok, but i really dislike it. So i try this:
sudo chmod 666 /dev/i2c-0
and with this all is correct, i can run the 2 commands without being root.
Hey sadcruel,
Thanks for your advice! I did not have your problems if I put the modules in /etc/modules it works without root permissions. But of course your solution is fine.
Hi Toffer, 😉
It’s been a long time I had last a watch at your blog and from now on, there’s still a little mistake in this line :
“sudo chomd +x /usr/bin/gyro-auto-rotate.run”
Not very important for those who know Linux, but important enough for the newbies… 😀
Nice blog and good job for spreading the informations.
Friendly greeting.
Hey Arobase,
nice to hear from you. Thanks for the correction hint. I edited the post.
Year I post this information also here for my self to have a compact place to look up again.
regards christopher
Hey
Just forgot to wish you a happy New Year 2011 ! 🙂
Oh year! The same to you!
first of all thank you for all your effort.. good work. really.
to my problem now..
the autorotation thing seems to create problems to the screen driver? or is it only me?
after a rotation, touch screen goes insane.. and it does not come back after rotating back..
any clues?
@ Achilleas,
I guess you need to update your graphic driver.
Another thing don’t rotate your screen too fast… ^^
If anyone interessed for an Android Froyo alpha test file for the 1825PT(Z), and probably for the 1425P :
Download it from here :
http://rapidshare.com/files/446220918/Acer-1825ptz_laptop.iso
Use a liveusb-creator to copy the internal files on a USB key or burn it on a CD.
No access to your hard disk if used as Live System, so it should not mess your system.
Don’t install it on your HDD unless you know what you do.
Don’t blame me if something goes wrong and use it at your risk !
Best Regards
Hey Arobase40,
thanks for the information and much more thanks for your work! I think this information and your work deserve credit in an own post! I hope you agree with me.
I’m not in search for glory, but I don’t mind if you create a specific post… 😉
Be aware of the choice of the LiveUsb Creator program you use. If it does not boot at all, then change the program. With Fedora LiveUsb Creator version above 2.9.0, it will not boot. With 2.9.0, it boots but with tons of error messages (cosmetical issue due to syslinux), but it works anyway.
Best is to use Lili Live Usb Creator with which there is no problem at all.
Best Regards and cyl…
Hey arobase,
If you check http://www.ceh-photo.de/blog/?p=293 you will see, I have already created a special post for your awesome work 🙂
I used unetbootin as usb creator under ubuntu and it works out of the box. See my pictures. Could you tell me something of what is work in progress? Is it possible to install it on SD/Usb so I could save some settings etc?
For my self I could detect WLAN`s but I have problems to connect. Is it possible that something is missing for WPA2 encryption?
I am not familar with android, If I am in tablet mode, how could I go back? In laptop mode I use ESC.
If you like you could send me your instant messanger contacts and we could talk a bit about that topic.
Typo, youve left in a quote on the line after “sudo su”
thanks! I fixed it!
[…] http://www.ceh-photo.de/blog/?p=186 […]
Hey all,
I got the same error:
# i2c-gsensor 0 [loop]
Error: Could not open file `/dev/i2c-0′ or `/dev/i2c/0′: No such file or directory
Accelerometer not found
A reboot fixed that. Now i get
x = 4 y = 254 z = 60
or something similar, depending on how i keep my laptop.
# gyro-auto-rotate.run
has no effect, as far as I can see..
Where could I start looking for a solution?
Thanks!
Roel
Hey Roel,
ok your gyro sensor works, this i proofed by the output x = 4 y = 254 z = 60 ..
How do you use the gyro-auto-rotate.run script?
Do you start it from terminal like ./gyro-auto-rotate.run
You could enable debug output in the script:
Change line 3 DEBUG=”” to DEBUG=”1″ and start the script from terminal and check whats going on.
Hey Toffer,
Thanks for your reply.
Yes, I started it from the terminal. I copied it to “/usr/bin/”, and executed it without the “./” After reading your post I tried it again, i2c-gsensor 0 [loop] responds slower than I remeber (thought it was more or les instantanious yesterday, now over a second. gyro-auto-rotate.run magically works now, display turn in right direction and no problems with calibration. Curious…
Thanks for your concern anyway 🙂
Cheers!
Roel
Sorry for not closing the parentheses, hope nobody caught a cold in the draught… )
english to vietnamese translation…
[…]CEH-PHOTO » Blog Archive » Enable the gyro-sensor for auto display rotation on Acer 1825 – Computer Science, Linux, Embedded Systems, Photography and more projects by Christopher Hrabia[…]…
android tablet forums…
[…]CEH-PHOTO » Blog Archive » Enable the gyro-sensor for auto display rotation on Acer 1825 – Computer Science, Linux, Embedded Systems, Photography and more projects by Christopher Hrabia[…]…
Hello,
thanks for your script.
I am able to launch the script as root and everything is working well.
However I can’t find how to run gyro-auto-rotate.run from startup.
Thanks for your help
Ps: I am new with linux.
Hi,
which linux desktops do you use?
I am using Ubuntu 11.10
Here is a documentation on how to set up autostart for applications in unity:
http://askubuntu.com/questions/48321/how-to-start-applications-at-startup-automatically-in-unity
Ok Thanks,
I’ve done this, However the script is not running at startup.
I think, the programm need to be launch as root.
If I make a sudo su + gyro-auto-rotate.run
It’s is working.
Any ideas ?
Regards
It should be possible to use the script with normal user rights (I am doing this).
Please check if you have necessary rights for execution on following files:
/usr/bin/i2c-gsensor
/usr/bin/gyro-auto-rotate.run
For information you have to change right on /dev/i2c-0 too ! That was my mistake ! Tanks for your help !
http://corgi.tw/thread-42147-1-1.html