/* Matrixanzeige (c) Oliver Mezger 13.04.2011 Firmware fuer Prototyp 16x8 LED-Matrix Distributed under Creative Commons 3.0 -- Attib & Share Alike Synopsis: http://www.tvbgone.com/mfaire/ledcubekit/ledcube.c http://www.cse.ohio-state.edu/~stocka/LEDCube/ */
#include <avr/io.h> #include <util/delay.h> #include <avr/pgmspace.h>
struct imElt { unsigned int z[8]; unsigned long int imageDuration; } const imageTab[] PROGMEM = { { 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 0b0000000110000000, 0b0000000110000000, 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 1000 }, { 0b0000000000000000, 0b0000000000000000, 0b0000001111000000, 0b0000001001000000, 0b0000001001000000, 0b0000001111000000, 0b0000000000000000, 0b0000000000000000, 1000 }, { 0b0000000000000000, 0b0000000000000000, 0b0000011111100000, 0b0000010000100000, 0b0000010000100000, 0b0000011111100000, 0b0000000000000000, 0b0000000000000000, 1000 }, { 0b0000000000000000, 0b0000111111110000, 0b0000100000010000, 0b0000100000010000, 0b0000100000010000, 0b0000100000010000, 0b0000111111110000, 0b0000000000000000, 1000 }, { 0b0000000000000000, 0b0001111111111000, 0b0001000000001000, 0b0001000000001000, 0b0001000000001000, 0b0001000000001000, 0b0001111111111000, 0b0000000000000000, 1000 }, { 0b0011111111111100, 0b0010000000000100, 0b0010000000000100, 0b0010000000000100, 0b0010000000000100, 0b0010000000000100, 0b0010000000000100, 0b0011111111111100, 1000 }, { 0b0100000000000010, 0b0100000000000010, 0b0100000000000010, 0b0100000000000010, 0b0100000000000010, 0b0100000000000010, 0b0100000000000010, 0b0100000000000010, 1000 }, { 0b1010101010101010, 0b0101010101010101, 0b1010101010101010, 0b0101010101010101, 0b1010101010101010, 0b0101010101010101, 0b1010101010101010, 0b0101010101010101, 30000 }, { 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 0b0000000110000000, 0b0000000110000000, 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 1000 }, { 0b0000000000000000, 0b0000000000000000, 0b0000001111000000, 0b0000001001000000, 0b0000001001000000, 0b0000001111000000, 0b0000000000000000, 0b0000000000000000, 1000 }, { 0b0000000000000000, 0b0000000000000000, 0b0000011111100000, 0b0000010000100000, 0b0000010000100000, 0b0000011111100000, 0b0000000000000000, 0b0000000000000000, 1000 }, { 0b0000000000000000, 0b0000111111110000, 0b0000100000010000, 0b0000100000010000, 0b0000100000010000, 0b0000100000010000, 0b0000111111110000, 0b0000000000000000, 1000 }, { 0b0000000000000000, 0b0001111111111000, 0b0001000000001000, 0b0001000000001000, 0b0001000000001000, 0b0001000000001000, 0b0001111111111000, 0b0000000000000000, 1000 }, { 0b0011111111111100, 0b0010000000000100, 0b0010000000000100, 0b0010000000000100, 0b0010000000000100, 0b0010000000000100, 0b0010000000000100, 0b0011111111111100, 1000 }, { 0b0100000000000010, 0b0100000000000010, 0b0100000000000010, 0b0100000000000010, 0b0100000000000010, 0b0100000000000010, 0b0100000000000010, 0b0100000000000010, 1000 }, { 0b0101010101010101, 0b1010101010101010, 0b0101010101010101, 0b1010101010101010, 0b0101010101010101, 0b1010101010101010, 0b0101010101010101, 0b1010101010101010, 30000 }, { 0b0000000000000000, 0b1111101111010111, 0b0010001000010010, 0b0010001000010010, 0b0010001011010010, 0b0010001001010010, 0b0010001111010010, 0b0000000000000000, 35000 }, { 0b0000000000000000, 0b1111010101000111, 0b1001010101000001, 0b1111010101000010, 0b1100010101000010, 0b1010010101000100, 0b1001011101110111, 0b0000000000000000, 40000 }, { 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 5120 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, };
void displayImage(int index){ unsigned long int duration = pgm_read_dword( &imageTab[index].imageDuration ); unsigned char zeile=1,p=0; unsigned int a; for (int i=0; i<(duration/(20)); i++) { a = pgm_read_word( &imageTab[index].z[p] ); // lies Wort PORTC = a; // oberer Teil hinten PORTD = a>>8; // unter Teil vorne PORTB = zeile; _delay_ms(1); zeile = zeile <<1; p++; if (zeile == 0){ zeile =1; p=0; } } }
int main(){ DDRB = 0xff; // PB als Ausgang Zeilen DDRC = 0xff; // PC als Ausgang Spalten DDRD = 0xff; // PD als Ausgang Spalten while (1){ // Endlosschleife int i = 0; do { displayImage(i); i++; } while (pgm_read_dword(&imageTab[i].imageDuration) != 0); } }
|