#define LPT1IRQ 7
#define TICKS 5
-#define MAXX 16
+#define BANNERWIDTH 10000
+#define MSGMAX 1000
+#define MAXX 20
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
-};
+unsigned char data[BANNERWIDTH];
+char message[MSGMAX];
+char inputmsg[MSGMAX];
+unsigned int pointer = 0;
+unsigned int msglen;
void add_tick(RTIME *t, RTIME tnew)
{
t[TICKS] += t[i];
}
t[0] = tnew;
- t[TICKS] = t[TICKS]/TICKS;
+ t[TICKS] = (t[TICKS]+t[0])/TICKS;
}
void taskd(void *arg)
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(data[i+pointer], 0x378);
+ rt_task_sleep(step);
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);
+ pointer = pointer > msglen ? 0 : pointer+1;
}
void taski(void *arg)
//Register as interrupt handler
RT_INTR intr;
rt_intr_create(&intr, NULL, LPT1IRQ, 0);
- rt_printf("Interrupt created\n");
//Initialize and declare the timer variables
RTIME tick = rt_timer_read();
rt_task_create(&drawtask, NULL, 0, 50, 0);
period = ticks[TICKS]+tocks[TICKS];
rt_task_start(&drawtask, &taskd, &period);
- rt_printf("tocks is the short stretch\n");
}
rt_intr_wait(&intr, TM_INFINITE);
rt_task_create(&drawtask, NULL, 0, 50, 0);
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);
}
}
+void make_message(char *msg)
+{
+ unsigned int i;
+ for(i=0; i<BANNERWIDTH; i++){
+ data[i] = 0;
+ }
+ i = 20;
+ unsigned char s = 0;
+ while(i<BANNERWIDTH && s < strlen(msg)){
+ char c = msg[s];
+ // Yes, we hardcoded all letters, digits and some symbols...
+ switch(c){
+ case 'A':
+ case 'a':
+ data[i++] = 0x1e; data[i++] = 0x5; data[i++] = 0x1e; break;
+ case 'B':
+ case 'b':
+ data[i++] = 0x1f; data[i++] = 0x15; data[i++] = 0xe; break;
+ case 'C':
+ case 'c':
+ data[i++] = 0xe; data[i++] = 0x11; break;
+ case 'D':
+ case 'd':
+ data[i++] = 0x1f; data[i++] = 0x11; data[i++] = 0xe; break;
+ case 'E':
+ case 'e':
+ data[i++] = 0x1f; data[i++] = 0x15; break;
+ case 'F':
+ case 'f':
+ data[i++] = 0x1f; data[i++] = 0x05; break;
+ case 'G':
+ case 'g':
+ data[i++] = 0xe; data[i++] = 0x11, data[i++] = 0x1d; break;
+ case 'H':
+ case 'h':
+ data[i++] = 0x1f; data[i++] = 0x4, data[i++] = 0x1f; break;
+ case 'I':
+ case 'i':
+ data[i++] = 0x1f; break;
+ case 'J':
+ case 'j':
+ data[i++] = 0x10; data[i++] = 0x1f; break;
+ case 'K':
+ case 'k':
+ data[i++] = 0x1f; data[i++] = 0x04; data[i++] = 0x1b; break;
+ case 'L':
+ case 'l':
+ data[i++] = 0x1f; data[i++] = 0x10; break;
+ case 'M':
+ case 'm':
+ data[i++] = 0x1f; data[i++] = 0x2; data[i++] = 0x7; data[i++] = 0x2; data[i++] = 0x1f; break;
+ case 'N':
+ case 'n':
+ data[i++] = 0x1f; data[i++] = 0x2; data[i++] = 0x4; data[i++] = 0x1f; break;
+ case 'O':
+ case 'o':
+ data[i++] = 0xe; data[i++] = 0x11; data[i++] = 0xe; break;
+ case 'P':
+ case 'p':
+ data[i++] = 0x1f; data[i++] = 0x5; data[i++] = 0x2; break;
+ case 'Q':
+ case 'q':
+ data[i++] = 0xe; data[i++] = 0x11; data[i++] = 0x19; data[i++] = 0x1e; break;
+ case 'R':
+ case 'r':
+ data[i++] = 0x1f; data[i++] = 0x5; data[i++] = 0x1a; break;
+ case 'S':
+ case 's':
+ data[i++] = 0x12; data[i++] = 0x15; data[i++] = 0xd; break;
+ case 'T':
+ case 't':
+ data[i++] = 0x1; data[i++] = 0x1f; data[i++] = 0x1; break;
+ case 'U':
+ case 'u':
+ data[i++] = 0x1f; data[i++] = 0x10; data[i++] = 0x1f; break;
+ case 'V':
+ case 'v':
+ data[i++] = 0xf; data[i++] = 0x10; data[i++] = 0xf; break;
+ case 'W':
+ case 'w':
+ data[i++] = 0xf; data[i++] = 0x10; data[i++] = 0xc; data[i++] = 0x10; data[i++] = 0xf; break;
+ case 'X':
+ case 'x':
+ data[i++] = 0x11; data[i++] = 0xe; data[i++] = 0x11; break;
+ case 'Y':
+ case 'y':
+ data[i++] = 0x17; data[i++] = 0x14; data[i++] = 0xf; break;
+ case 'Z':
+ case 'z':
+ data[i++] = 0x19; data[i++] = 0x15; data[i++] = 0x13; break;
+ case '0':
+ data[i++] = 0xe; data[i++] = 0x11; data[i++] = 0xe; break;
+ case '1':
+ data[i++] = 0x12; data[i++] = 0x1f; data[i++] = 0x10; break;
+ case '2':
+ data[i++] = 0x12; data[i++] = 0x19; data[i++] = 0x16; break;
+ case '3':
+ data[i++] = 0x15; data[i++] = 0xa; break;
+ case '4':
+ data[i++] = 0x7; data[i++] = 0x4; data[i++] = 0x1f; break;
+ case '5':
+ data[i++] = 0x17; data[i++] = 0x15; data[i++] = 0x9; break;
+ case '6':
+ data[i++] = 0xe; data[i++] = 0x15; data[i++] = 0x9; break;
+ case '7':
+ data[i++] = 0x1; data[i++] = 0x1f; break;
+ case '8':
+ data[i++] = 0x1f; data[i++] = 0x15; data[i++] = 0x1f; break;
+ case '9':
+ data[i++] = 0x12; data[i++] = 0x15; data[i++] = 0x1e; break;
+ case '.':
+ data[i++] = 0x10; break;
+ case ',':
+ data[i++] = 0x10; data[i++] = 0x8; break;
+ case '\'':
+ case '"':
+ data[i++] = 0x1; break;
+ case ':':
+ data[i++] = 0xa; break;
+ case '(':
+ data[i++] = 0xe; data[i++] = 0x11; break;
+ case ')':
+ data[i++] = 0x11; data[i++] = 0xe; break;
+ case '-':
+ data[i++] = 0x4; data[i++] = 0x4; break;
+ case ' ':
+ i++;
+ break;
+ case '!':
+ data[i++] = 0x17; break;
+ default:
+ break;
+ }
+ i++;
+ s++;
+ }
+ msglen = i;
+ pointer = 0;
+}
+
int main(int argc, char* argv[])
{
rt_print_auto_init(1);
mlockall(MCL_CURRENT | MCL_FUTURE);
- // Get permission to write to parallel port
+ unsigned int i;
+ for(i=0; i<BANNERWIDTH; i++){
+ data[i] = 0;
+ }
+
ioperm(0x37A, 1, 1);
ioperm(0x378, 1, 1);
outb(inb(0x37A) | 0x10, 0x37A);
+ make_message("abcdefghijklmnopqrstuvwxyz1234567890,.\"()");
+
rt_task_create(&intrtask, NULL, 0, 50, 0);
rt_task_start(&intrtask, &taski, 0);
- pause();
+ printf("CRTL+C to exit\n");
+ printf("legal chars: abcdefghijklmnopqrstuvwxyz1234567890,.\"()\n");
+ while(1){
+ printf("Type your message(max %d chars): ", MSGMAX);
+ scanf("%[^\n]", inputmsg);
+ getchar();
+ make_message(inputmsg);
+ sleep(0.1);
+ }
}