#define LPT1IRQ 7
#define TICKS 5
-#define MAXX 10
-#define MAXY 7
+#define MAXX 16
RT_TASK intrtask, drawtask;
RTIME ticks[TICKS+1];
RTIME tocks[TICKS+1];
+unsigned char data[MAXX] = {
+ 1, 2, 4, 8, 16, 32, 64, 128, 256,
+ 1, 2, 4, 8, 16, 32, 64, 128, 256
+};
+
void add_tick(RTIME *t, RTIME tnew)
{
unsigned int i = 0;
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);
+ RTIME step = time/(2*MAXX+2);
+ unsigned int i;
+
+ //To the right
+ outb(0x00, 0x378);
+ rt_task_sleep(step*2);
+ for(i=0; i<MAXX; i++){
+ outb(data[i], 0x378);
+ rt_task_sleep(step/2);
+ outb(0x00, 0x378);
+ rt_task_sleep(step/2);
+ }
+ rt_task_sleep(step);
+ outb(0x00, 0x378);
+
+ //rt_printf("Every x has %.2fms\n", step/1000/1000.0);
}
void taski(void *arg)
RTIME tock;
RTIME period;
while(1){
- //Wait for tick (long stretch)
- rt_intr_wait(&intr, TM_INFINITE);
tock = rt_timer_read();
- add_tick(ticks, rt_timer_read()-tick);
+ add_tick(ticks, tock-tick);
- // Tocks are the short stretches
+ // Tocks waiting period
if(tocks[TICKS] < ticks[TICKS]){
// sleep until the arm is most left
rt_task_sleep(tocks[TICKS]/2);
rt_task_create(&drawtask, NULL, 0, 50, 0);
- period = ticks[TICKS]/2+tocks[TICKS]/2;
+ period = ticks[TICKS]+tocks[TICKS];
rt_task_start(&drawtask, &taskd, &period);
rt_printf("tocks is the short stretch\n");
}
-
- //Wait for tock (shorter stretch)
rt_intr_wait(&intr, TM_INFINITE);
+
+ //Tick waiting period
tick = rt_timer_read();
- add_tick(tocks, rt_timer_read()-tock);
+ add_tick(tocks, tick-tock);
- //Long stretch
if(ticks[TICKS] < tocks[TICKS]){
// sleep until the arm is most left
rt_task_sleep(ticks[TICKS]/2);
rt_task_create(&drawtask, NULL, 0, 50, 0);
- period = tocks[TICKS]/2+ticks[TICKS]/2;
+ period = ticks[TICKS]+tocks[TICKS];
rt_task_start(&drawtask, &taskd, &period);
rt_printf("ticks is the short stretch\n");
}
-
+ rt_intr_wait(&intr, TM_INFINITE);
//Print average
//rt_printf("avgtick: %lluns, avgtock: %lluns, avgticktock: %lluns\n",
// ticks[TICKS], tocks[TICKS], (ticks[TICKS]+tocks[TICKS])/2);