From: dopefishh Date: Fri, 9 Oct 2015 08:03:26 +0000 (+0200) Subject: start with clock X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=5de2a4c126e5bd85d15f21719605125cf5bb0459;p=des2015.git start with clock --- diff --git a/mart/ex11/ex11.c b/mart/ex11/ex11.c index a9fd350..6e107db 100644 --- a/mart/ex11/ex11.c +++ b/mart/ex11/ex11.c @@ -11,29 +11,79 @@ #include #define LPT1IRQ 7 -#define TESTSAMPLES 20 +#define TICKS 5 +#define MAXX 10 +#define MAXY 7 -RT_TASK task; -RTIME times[SAMPLES]; +RT_TASK intrtask, drawtask; +RTIME ticks[TICKS+1]; +RTIME tocks[TICKS+1]; -void taskf(void *arg) +void add_tick(RTIME *t, RTIME tnew) +{ + unsigned int i = 0; + t[TICKS] = 0; + for(i=TICKS-1; i>0; i--){ + t[i] = t[i-1]; + t[TICKS] += t[i]; + } + t[0] = tnew; + t[TICKS] = t[TICKS]/TICKS; +} + +void taskd(void *arg) +{ + RTIME time = *(RTIME *)arg; + rt_printf("Time to draw=%.2fms\n", time/1000/1000.0); + RTIME step = time/MAXX; + rt_printf("Every x has %.2fms\n", step/1000/1000.0); +} + +void taski(void *arg) { //Register as interrupt handler RT_INTR intr; rt_intr_create(&intr, NULL, LPT1IRQ, 0); + rt_printf("Interrupt created\n"); - //Measure average time of the clock - RTIME dur = rt_timer_read(); - unsigned int i; - for(i = 0; i