====== Zeichen ausgeben ====== [[artikel:atmega_u-howto:blinkenlights_fontheader|Hier gibt es die font.h]] /* * Ein Zeichen ausgeben * Blinkenlights-Bausatz * www.eHaJo.de * * (C) Hannes Jochriem, 2013 * */ #include #include #include #include #include #include "font.h" int main() { printf("Starte LEDMatrix-Programm\n"); int fd; int i, j; struct termios options; char buffer; char temp; 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 Zeichen eingeben: "); while(1) { // haupt-endlosschleife scanf("%c", &temp); if (!(temp < 0x20) || (temp > 0x7F)) { // Zeichen darstellbar for(i = 0; i<8; i++) { for(j = 0; j<7; j++) { if(font[(temp-0x20)*7+j] & (1<