Difference between revisions of "Chumby device settings information on /dev"
From Chumby Wiki
(New page: ==/dev/fb== ==/dev/accel== ==/dev/ts== How to read /dev/ts in C <pre> #include <stdio.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> #include <signal.h> short *buf; in...) |
(→/dev/ts) |
||
Line 5: | Line 5: | ||
==/dev/ts== | ==/dev/ts== | ||
How to read /dev/ts in C | How to read /dev/ts in C | ||
+ | |||
+ | see [[Chumby_device_settings_information_on_/proc#/proc/chumby/touchscreen/coordinates | coordinates in /proc page]] for value explanation (pressure). | ||
<pre> | <pre> | ||
#include <stdio.h> | #include <stdio.h> | ||
Line 52: | Line 54: | ||
return 0; | return 0; | ||
} | } | ||
+ | </pre> | ||
+ | |||
+ | example of output, exit by ctrl-c | ||
+ | <pre> | ||
+ | read n[8] p[4973] x[1702] y[2489] unknown[671] | ||
+ | read n[8] p[4974] x[1697] y[2501] unknown[765] | ||
+ | read n[8] p[4973] x[1721] y[2621] unknown[865] | ||
+ | read n[8] p[4974] x[1734] y[2825] unknown[966] | ||
+ | read n[8] p[0] x[0] y[0] unknown[1212] | ||
+ | clean exit | ||
</pre> | </pre> |
Revision as of 14:43, 15 May 2008
/dev/fb
/dev/accel
/dev/ts
How to read /dev/ts in C
see coordinates in /proc page for value explanation (pressure).
#include <stdio.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> #include <signal.h> short *buf; int read_coor() { int fd; int n = 0; if (0 > (fd = open("/dev/ts", O_RDONLY))) { perror("file "); return 0; } buf = (short *)malloc(4 * sizeof(short)); do { if((n = read(fd, buf, 4 * sizeof(short))) < 0) perror("read"); printf("read n[%d] p[%d] x[%d] y[%d] unknown[%d]\n", n, buf[0], buf[1], buf[2], buf[3]); }while(n > 0); free(buf); buf = 0; return close(fd); } void killall(int t) { printf("clean exit\n"); if (buf) free(buf); buf = 0; exit(0); } int main() { signal(SIGINT, killall); read_coor(); return 0; }
example of output, exit by ctrl-c
read n[8] p[4973] x[1702] y[2489] unknown[671] read n[8] p[4974] x[1697] y[2501] unknown[765] read n[8] p[4973] x[1721] y[2621] unknown[865] read n[8] p[4974] x[1734] y[2825] unknown[966] read n[8] p[0] x[0] y[0] unknown[1212] clean exit