Root.czBlogyjoejoe.blog.root.cz

Akcelerometry v openmoku

joe, 23. 09. 2008, 20:34 v kategorii geekphone,

freeruner logo Zkoušel jsem si zase hrát s akcelerometrama na openmoku a tohle je výsledek.

#include <linux/input.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
//#define EVENT_PATH "/dev/input/event2"
#define EVENT_PATH "/dev/input/event3"
#define EVENT_SLEEP 50000
#define LOG_NAME "accel-dump.log"
#define BUFSIZE 8
#define MAX(a, b)           (((a) > (b)) ? (a) : (b))
#define DEBUG 0int counter = 0;

void process_packet (FILE *eventfp) {
struct input_event buffer[BUFSIZE];
int x, y, z, maxVal;
maxVal = x = y = z = 0;
if (fread(buffer, sizeof (struct input_event), BUFSIZE, eventfp) != BUFSIZE) {
  fprintf(stderr, "fread() failed\n");
  exit(1);
}

for (int i = 0; i < BUFSIZE; i++) {
  if (buffer[i].type == EV_REL) {
  switch(buffer[i].code) {
  case REL_X: x = buffer[i].value;break;
  case REL_Y: y = buffer[i].value;break;
  case REL_Z: z = buffer[i].value;break;
}

maxVal = MAX(buffer[i].value, maxVal);
maxVal = MAX(-buffer[i].value, maxVal);

}

}

FILE* fp = fopen(LOG_NAME, "a");
fprintf(fp, "%d %d %d %d %d\n", counter++, x, y, z, maxVal);
fclose(fp);

}

int main (int argc, char *argv[]) {
FILE *eventfp;
eventfp = fopen(EVENT_PATH, "rb");
if (eventfp == NULL) {
fprintf(stderr, "Couldn't open file.\n");
exit(1);
}

for (;;) {
process_packet(eventfp);
usleep(EVENT_SLEEP);
}
}

gnuplot

x = x + 1
plot "/mnt/moko/home/root/accel-dump.log" using 1:2 with lines title "x", "/mnt/moko/home/root/accel-dump.log" using 1:3 with lines title "y", "/mnt/moko/home/root/accel-dump.log" using 1:4 with lines title "z"
if(x<1000) reread

připojení openmoka přes sshfs

sudo sshfs root@moko:/ /mnt/moko/ -o allow_other

a nakonec se to spustilo na telefonu

./accel-dump

na desktopu

x=0; load "accel-dump.gnuplot"


http://www.stud.fit.vutbr.cz/~xmlich02/openmoko/accel-dump.avi (5mb)
http://www.stud.fit.vutbr.cz/~xmlich02/openmoko/accel-dump2.avi (22mb)

Komentáře (6)

  1. 23. 09. 2008, 21:16 Rezza napsal:

    Ty jo, to video se normalne ztratilo z YouTube!

  2. 23. 09. 2008, 22:48 Nano napsal:

    Hlasi to "This video has been remove by the user."

  3. 24. 09. 2008, 08:12 joe napsal:

    (2) daval jsem to na youtube vcera vecer a doufal jsem, ze do rana to bude zpracovane. dal jsem tam link primo na to to video. youtube suxx (-;

  4. 26. 09. 2008, 23:02 LoopTrop napsal:

    Mohol si s mobilom trocha zashakeovat.

  5. 9. 10. 2008, 14:36 Rezza napsal:

    (2) Podle vseho to bylo jen tim, ze jeste nebylo zpracovane...

  6. 14. 12. 2008, 13:11 K- napsal:

    Hi, very interesting. Would be nice if you could share a binary!

Přidej komentář