12-27-2011, 01:34 AM | #1 |
Junior Member
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 |
12-27-2011, 08:22 AM | #2 | |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
UPDATE: I replaced /proc/input with /dev/input below. It should work "more better" now. Sorry about that.
Quote:
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. |
|
Advert | |
|
12-27-2011, 08:55 AM | #3 |
Wizard
Posts: 1,379
Karma: 2155307
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). |
12-27-2011, 09:28 AM | #4 | |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Quote:
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. |
|
12-27-2011, 10:27 PM | #5 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
UPDATE: I fixed the paths to the accelerometer and touchscreen devices in my original reply above.
|
Advert | |
|
01-02-2012, 07:12 AM | #6 |
Member
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? |
01-02-2012, 07:34 AM | #7 |
Enthusiast
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 |
01-02-2012, 08:27 AM | #8 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
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. |
01-05-2012, 01:28 AM | #9 | |
Junior Member
Posts: 3
Karma: 10
Join Date: Dec 2011
Device: kindle touch
|
Quote:
|
|
01-05-2012, 03:16 AM | #10 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
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. |
01-05-2012, 03:22 AM | #11 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
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. |
01-05-2012, 07:16 AM | #12 |
Junior Member
Posts: 3
Karma: 10
Join Date: Dec 2011
Device: kindle touch
|
|
01-05-2012, 07:55 AM | #13 | |
Member
Posts: 12
Karma: 28820
Join Date: Dec 2011
Device: Kindle Touch
|
Quote:
https://www.mobileread.com/forums/sho...&postcount=255 |
|
01-06-2012, 10:58 AM | #14 | ||
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Quote:
Quote:
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. |
||
01-09-2012, 05:32 PM | #15 | |
Member
Posts: 11
Karma: 10
Join Date: Dec 2011
Device: kindle touch 5.1
|
Quote:
|
|
|
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 |