Hier gibt es die font.h
/*
* Lauftext
* Blinkenlights-Bausatz
* www.eHaJo.de
*
* (C) Hannes Jochriem, 2013
*
*/
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>
#include "font.h"
int main()
{
printf("Starte LEDMatrix-Programm\n");
int fd;
int i, j, laufvariable, laufvariable2, anzahl;
struct termios options;
char buffer;
char temp;
char schieberegister[7]; //Anzeigepuffer
char laufbuffer[700]; // Puffer fuer die Zeichen
fd = open("/dev/ttyACM0", O_RDWR | O_NOCTTY | O_NDELAY); // seriellen port oeffnen
if(fd == -1)
{
printf("konnte Port nicht oeffnen\n");
}
else
{
fcntl(fd, F_SETFL, 0);
printf("port geoeffnet...\n");
}
// seriellen port konfigurieren:
tcgetattr(fd, &options);
cfsetispeed(&options, B115200);
cfsetospeed(&options, B115200);
options.c_cflag |= (CLOCAL | CREAD);
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;
options.c_cflag &= ~( ICANON | ECHO | ECHOE |ISIG );
options.c_iflag &= ~(IXON | IXOFF | IXANY );
options.c_oflag &= ~OPOST;
tcsetattr(fd, TCSANOW, &options); // die config an den port uebertragen
// Alle LEDs ausschalten:
for(i = 0; i<8; i++)
{
for(j = 0; j<8; j++)
{
buffer = (j<<1) | (i<<4);
write(fd, &buffer, 1);
}
}
printf("Bitte Zeichenfolge eingeben: ");
laufvariable = 0;
temp = getchar();
do
{
if(laufvariable>700)
break;
for(i = 0; i<8; i++)
{
laufbuffer[laufvariable*7+i] = font[(temp-0x20)*7+i];
}
laufvariable++;
} while((temp = getchar()) != 0x0a);
anzahl = laufvariable*7;
laufvariable = 0;
laufvariable2 = 0;
for(i=0; i<8; i++)
{ // Anzeigepuffer leeren
schieberegister[i] = 0;
}
while(1)
{ // haupt-endlosschleife
for(i = 0; i<8; i++)
{
for(j = 0; j<7; j++)
{
if(schieberegister[j] & (1<<(i))) // Bit fuer Bit ueberprufen ob 1 und somit LED an
buffer = (((7-j) << 1) | ((7-i)<<4)) + 1;
else // Falls Bit = 0: LED ausschalten
buffer = (((7-j) << 1) | ((7-i)<<4));
write(fd, &buffer, 1); // sende byte an ledmatrix
}
}
for(i=0; i<7; i++)
{
schieberegister[i] = schieberegister[i] << 1; // Anzeigepuffer um 1 Bit nach links schieben
// Letzte Spalte mit dem naechsten Buchstaben fuellen:
schieberegister[i] |= ((laufbuffer[i+(7*laufvariable2)] & (1<<(7-(laufvariable%7)))) >> (7-(laufvariable%7)));
}
usleep(100000);
laufvariable++;
if(laufvariable % 7 == 0)
laufvariable2++;
if(laufvariable == anzahl)
{
laufvariable = 0;
laufvariable2 = 0;
for(i=0; i<8; i++)
{
schieberegister[i] = 0;
}
}
}
close(fd); // port schliessen
return 0;
}