Chumby device settings information on /dev

From Chumby Wiki
Revision as of 15:15, 15 May 2008 by Kit (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

/dev/fb

/dev/fb stand for a pointer to the video memory. You writes in it, it draws pixels on the chumby screen.

see the fbwrite project (really easy to read if you know C)

http://files.chumby.com/source/ironforge/build396/fbwrite-1.0.tar.gz

http://files.chumby.com/source/

/dev/accel

http://forum.chumby.com/viewtopic.php?id=759

/dev/ts

Why use /dev/ts ?

  • faster
  • direct connection with the driver
  • I had a problem using /proc/chumby/touchscreen/coordinates without using /bin/cat

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

Launch it, click on the screen then, exit with 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