1 (edited by kit 2008-05-15 13:33:11)

Topic: documentation on /dev/ts, /dev/fb and /dev/bend

In an old post Duane was talking about accessing /dev/fb0 and /dev/ts directly

With fbwrite I was able to write and read pixels on the screen but for the touchscreen I don't know how to separate coordinates from dev/ts.

Is there any documentation on /dev/ts ?

Duane post : http://forum.chumby.com/viewtopic.php?id=90

He also talked about /dev/bend, which seems to not exists anymore .. ?

[edit: 15 may]
I finally got it for /dev/ts

simple code for reading /dev/ts:

#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;
}

and you got pressure, then X, then Y, then a unknown value in buf.

you just have to split the bits from buf.
[/edit: 15 may]

--
kit

Re: documentation on /dev/ts, /dev/fb and /dev/bend

That final short is just padding.  Here's what touchscreen event structure looks like; you should be able to read 8 bytes out of /dev/ts and map it directly to the struct.

struct ts_event {
        unsigned short pressure;
        unsigned short x;
        unsigned short y;
        unsigned short pad;
};

Re: documentation on /dev/ts, /dev/fb and /dev/bend

Also, /dev/bend is now known as /dev/switch.  The bent state is represented by a single byte.

0x01 == bent
0x00 == released

Below is a hexdump of /dev/switch, transitioning from bent to released.

0004c950: 01010101 01010101 01010101 01010101 ................
0004c960: 01010101 01010000 00000000 00000000 ................