Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 12-27-2011, 01:34 AM   #1
sptrks
Junior Member
sptrks began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Dec 2011
Device: kindle touch
Accessing accelerometer data from kindle touch

I am trying to find out how to access the raw data from the touch's accelerometer and or sensors in general.

I have done some searches of this forum and have had no luck finding such information. If I missed something feel free to link me to the relevant post.


Thanks
sptrks is offline   Reply With Quote
Old 12-27-2011, 08:22 AM   #2
geekmaster
Всё гениальное просто.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 5,066
Karma: 6789001
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
UPDATE: I replaced /proc/input with /dev/input below. It should work "more better" now. Sorry about that.
Quote:
Originally Posted by sptrks View Post
I am trying to find out how to access the raw data from the touch's accelerometer and or sensors in general.

I have done some searches of this forum and have had no luck finding such information. If I missed something feel free to link me to the relevant post.


Thanks
I was playing with the accelerometer data yesterday with
cat /dev/input/event3
It emits a packet of binary data that appears to start with a timestamp.
If you shake the touch top-to-bottom or side-to-side, it emits one or more data packets with each direction change. It also emits data packets for side-to-side changes. When held vertically with the display towards you, rotating it also emits data packets when it crosses 45-degree angle boundaries, due to gravity sensing. You do not need to "enable" the accelerometer to receive this data.

The "shake mode" could be used with the media player to skip forward or back. The "gravity sensing mode" could be used to rotate the display. (Code changes would be required, of course.)

What I find interesting about this is that the accelerometer works great even though the bootup messages indicate that no accelerometer was found.

The touchscreen data is emitted from
cat /dev/input/event4
and it also emits binary packets that are 16-bytes long and start with a timestamp. The timestamp is useful for measuing velocity and acceleration of your finger or stylus on the display. It reports the touch position for up to two contact points. When no touch, no data emitted. (Experimentation shows that a stylus must be fairly thick, like a chopstick from a Chinese restaurant, and must be held perpendicular to the screen).

The touch must be awake (not is screensaver mode) to receive data from these devices.

There are also some /proc/ ports (buried inside /sys/) that report such things as how many fingers are touching the touchscreen (0, 1, or 2), battery voltage, temperature of battery (degrees F), temperature of display (degrees C), and much more.

EDIT: It is easier to analyzer the data packets with
hd /dev/input/event3
and
hd /dev/input/event3
because hd does a hexdump already formatted into 16-byte columns that match the packet size emitted by these devices.

Last edited by geekmaster; 12-27-2011 at 10:21 PM.
geekmaster is offline   Reply With Quote
 
Enthusiast
Old 12-27-2011, 08:55 AM   #3
hawhill
Wizard
hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.
 
hawhill's Avatar
 
Posts: 1,081
Karma: 2114647
Join Date: Nov 2010
Location: Goettingen, Germany
Device: Kindle Paperwhite, Kobo Mini
In the embedded market, such sensors are typically connected to the SoC via an I2C bus (sometimes SPI, but since this isn't really a timing critical device, I think it is probably I2C). Linux might offer access via its generic I2C interface.

Also note that the input event interface is quite standardized on Linux. I'd suggest to compile evtest (a quick search retrieves this: http://cgit.freedesktop.org/~whot/evtest/) and have it dump the data. It might make sense at it is already. If so, and if you're working with C/C++ codebases, there's linux/input.h in the kernel headers (though it will probably only provide you a struct and some constants).
hawhill is offline   Reply With Quote
Old 12-27-2011, 09:28 AM   #4
geekmaster
Всё гениальное просто.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 5,066
Karma: 6789001
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
Quote:
Originally Posted by hawhill View Post
If so, and if you're working with C/C++ codebases, there's linux/input.h in the kernel headers (though it will probably only provide you a struct and some constants).
I am working in C and I am nearly ready to write some code to read these devices. Thanks for recommending the input.h file so I do not have to reverse-engineer the datastream myself (an activity that has consumed a lot of my time over the years, using logic analyzers and such).

EDIT: I like the evtest capture/replay ability (kb/touch/event macro recorder). Not only for software regression tests, but for general use, such as for making "one-touch" buttons (e.g. a button to start wifi, launch the browser, and take you to a specific web page). Although, it might be a more direct approach to launch apps directly with command-line parameters, or to launch them with "lipc" commands where appropriate.

A macro recorder could be very easy for an end-user to record and use their own macros by simply starting the recorder and then just doing the thing that they want to automate (no command-line or programming skills required).

Last edited by geekmaster; 12-27-2011 at 04:29 PM.
geekmaster is offline   Reply With Quote
Old 12-27-2011, 10:27 PM   #5
geekmaster
Всё гениальное просто.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 5,066
Karma: 6789001
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
UPDATE: I fixed the paths to the accelerometer and touchscreen devices in my original reply above.
geekmaster is offline   Reply With Quote
Old 01-02-2012, 07:12 AM   #6
nerduban
Member
nerduban began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Dec 2011
Device: kindle touch 5.1
Hello,

I have a Kindle Touch without 3G and with SO, and cannot see any output with the command "hd /dev/input/event3". However, I could see touchsreen output with event4.

Should I call some other commands in order to enable accelerometer? Or maybe it is not present in my Kindle Touch?
nerduban is offline   Reply With Quote
Old 01-02-2012, 07:34 AM   #7
miguelos
Enthusiast
miguelos shares his or her toysmiguelos shares his or her toysmiguelos shares his or her toysmiguelos shares his or her toysmiguelos shares his or her toysmiguelos shares his or her toysmiguelos shares his or her toysmiguelos shares his or her toysmiguelos shares his or her toysmiguelos shares his or her toysmiguelos shares his or her toys
 
Posts: 44
Karma: 5666
Join Date: Dec 2011
Device: K3-3G, KT SO
I have KT SO and can see event3 values..
did you try to lean kindle towards you ? I just see it when i rotate kindle with upward position
miguelos is offline   Reply With Quote
Old 01-02-2012, 08:27 AM   #8
geekmaster
Всё гениальное просто.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 5,066
Karma: 6789001
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
You can also shake the kindle firmly from side to side, or from top to bottom, to generate accelerometer events.

To generate rotation accelerometer events, hold it out in front of you and rotate it around an axis perpendicular to the screen. Rotation events occur at 45-degree angles (useful for controlling screen orientation).

Screen orientation controls are hidden in current touch firmware because it has problems with displaying some pages in landscape mode. Perhaps it will be added back when they fix all the landcape mode page rendering bugs.

What is your touch firmware version? Perhaps different versions have different accelerometer settings?

Somewhere in this forum, yifanlu posted a command that showed how to enable the accelerometer on a touch. I did not need that. Perhaps you need to enable your accelerometer.

Last edited by geekmaster; 01-02-2012 at 08:36 AM.
geekmaster is offline   Reply With Quote
Old 01-05-2012, 01:28 AM   #9
sptrks
Junior Member
sptrks began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Dec 2011
Device: kindle touch
Quote:
Originally Posted by nerduban View Post
Hello,

I have a Kindle Touch without 3G and with SO, and cannot see any output with the command "hd /dev/input/event3". However, I could see touchsreen output with event4.

Should I call some other commands in order to enable accelerometer? Or maybe it is not present in my Kindle Touch?
Are you connected over wireless? If so toggle the ssh by putting the ";un" command into the search bar on the main page. This has worked for me.
sptrks is offline   Reply With Quote
Old 01-05-2012, 03:16 AM   #10
geekmaster
Всё гениальное просто.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 5,066
Karma: 6789001
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
Quote:
Originally Posted by sptrks View Post
Are you connected over wireless? If so toggle the ssh by putting the ";un" command into the search bar on the main page. This has worked for me.
Huh? Are you saying he can enable his accelerometer by toggling ssh with a ;un command? Or did you post this to the wrong thread?

Last edited by geekmaster; 01-05-2012 at 03:25 AM.
geekmaster is offline   Reply With Quote
Old 01-05-2012, 03:22 AM   #11
geekmaster
Всё гениальное просто.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 5,066
Karma: 6789001
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
Quote:
Originally Posted by sptrks View Post
Are you connected over wireless? If so toggle the ssh by putting the ";un" command into the search bar on the main page. This has worked for me.
As I stated in an earlier post, yifanlu posted somewhere in this forum a command to enable the accelerometer. If I can find that post, I will add it here. Perhaps somebody can PM him and ask him what command enables the accelerometer.

Last edited by geekmaster; 01-05-2012 at 04:49 AM.
geekmaster is offline   Reply With Quote
Old 01-05-2012, 07:16 AM   #12
sptrks
Junior Member
sptrks began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Dec 2011
Device: kindle touch
Quote:
Originally Posted by geekmaster View Post
Huh? Are you saying he can enable his accelerometer by toggling ssh with a ;un command? Or did you post this to the wrong thread?
Not sure if it toggles the accelerometer. It has fixed the problem of no events on /dev/input/event3.
sptrks is offline   Reply With Quote
Old 01-05-2012, 07:55 AM   #13
mc2739
Member
mc2739 solves Fermatís last theorem while doing the crossword.mc2739 solves Fermatís last theorem while doing the crossword.mc2739 solves Fermatís last theorem while doing the crossword.mc2739 solves Fermatís last theorem while doing the crossword.mc2739 solves Fermatís last theorem while doing the crossword.mc2739 solves Fermatís last theorem while doing the crossword.mc2739 solves Fermatís last theorem while doing the crossword.mc2739 solves Fermatís last theorem while doing the crossword.mc2739 solves Fermatís last theorem while doing the crossword.mc2739 solves Fermatís last theorem while doing the crossword.mc2739 solves Fermatís last theorem while doing the crossword.
 
Posts: 12
Karma: 28820
Join Date: Dec 2011
Device: Kindle Touch
Quote:
Originally Posted by geekmaster View Post
As I stated in an earlier post, yifanlu posted somewhere in this forum a command to enable the accelerometer. If I can find that post, I will add it here. Perhaps somebody can PM him and ask him what command enables the accelerometer.
The post from yifanlu about enabling the accelerometer is here:

http://www.mobileread.com/forums/sho...&postcount=255
mc2739 is offline   Reply With Quote
Old 01-06-2012, 10:58 AM   #14
geekmaster
Всё гениальное просто.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 5,066
Karma: 6789001
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
Quote:
Originally Posted by sptrks View Post
Not sure if it toggles the accelerometer. It has fixed the problem of no events on /dev/input/event3.
/dev/input/event3 *IS* the accelerometer. Without checking into the details, perhaps yifanlu enables the accelerometer in his ";un" command.

Quote:
Originally Posted by mc2739 View Post
The post from yifanlu about enabling the accelerometer is here:

http://www.mobileread.com/forums/sho...&postcount=255
Thanks! I could not find it when I looked for it.

For some reason, the accelerometer is already enabled on my touch. But then I did use the ;un command in the past, so that could explain it.

Code that uses the accelerometer should enable it first. It is tempting to disable it again when done using it, but that might break other programs that also use the accelerometer.

Last edited by geekmaster; 01-06-2012 at 11:05 AM.
geekmaster is offline   Reply With Quote
Old 01-09-2012, 05:32 PM   #15
nerduban
Member
nerduban began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Dec 2011
Device: kindle touch 5.1
Quote:
Originally Posted by mc2739 View Post
The post from yifanlu about enabling the accelerometer is here:

http://www.mobileread.com/forums/sho...&postcount=255
Thanks a lot geekmaster and mc2739. After replacing the parameter value of IS_ACCEL to 1 in /etc/upstart/makexconfig, and rebooting the device, I can now see the accelerometer data. Great!
nerduban is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Accelerometer bart34 Which one should I buy? 5 07-13-2011 02:38 PM
Kindle 3, Nook Simple Touch, Kobo Touch and Libra Pro Touch jbcohen Which one should I buy? 4 06-18-2011 07:58 PM
Accessing U of T wifi on Kindle Padraic Amazon Kindle 3 01-19-2011 09:56 PM
Accessing available networks kindle 3 Pushka Amazon Kindle 1 10-03-2010 06:44 PM
Accessing Kindle 2 bookmarks jeffocal Amazon Kindle 1 06-05-2010 09:42 AM


All times are GMT -4. The time now is 05:06 AM.


MobileRead.com is a privately owned, operated and funded community.