From d5941812cc3b06592d2ac589e81970611802ecd4 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sat, 5 Nov 2011 16:52:02 +0100 Subject: [PATCH] Changes from last meeting. --- firmware/main.c | 45 +++++++++++++++++---------------------------- firmware/main.h | 11 +++++------ 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/firmware/main.c b/firmware/main.c index bd7e764..8c8b8d3 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -23,6 +23,9 @@ int main(void) //wdt_reset(); // we are alive, so don't reset the µC usbPoll(); // keep connected + // hier pause einfügen + _delay_ms(50); // beispielsweise 50 ms => muss angepasst werden an usb kommunikation + } } @@ -43,9 +46,11 @@ void init() set_bit(TCCR1B, WGM12); // Animations-Geschwindigkeit + // (vergleichswert bei dem der Interrupt ausgelöst wird) OCR1AH = 0x01; OCR1AL = 0x00; + // anpassen auf reihenweise ausgabe clear_bit(TCCR1B, CS12); // Prescaler 64 set_bit(TCCR1B, CS11); set_bit(TCCR1B, CS10); @@ -54,38 +59,22 @@ void init() } // Interruptvektor von TIMER1 -SIGNAL(SIG_OUTPUT_COMPARE1A) +//SIGNAL(SIG_OUTPUT_COMPARE1A) // alte schreibweise +ISR (TIMER1_COMPA_vect) { - // Pixel multiplexen - for (uint8_t z = 0; z < 3; z++) - { - for (uint8_t y = 0; y < 3; y++) - { - for (uint8_t x = 0; x < 3; x++) - { - uint8_t n = z * 3 + x; + // Alle Pins von PORTD auf LOW setzen + // Höchstes Bit in PORTA auf 0 setzen (Leitung 9 für letzte Reihe) - // LED an - if (cube[x][y][z] == 1) - { - if (n < 8) clear_bit(PORTB, n); else clear_bit(PORTD, 6); - set_bit(PORTD, y + 3); - } - // ON-Time - sleep_nop(PIXEL_TON); + // bei cube_row_offset % 3 eine Ebene weiter schalten (ABC-Leitungen durch rotieren) + // bei Systemstart muss A aktiviert sein. - // LED aus - if (cube[x][y][z] == 1) - { - clear_bit(PORTD, y + 3); - if (n < 8) set_bit(PORTB, n); else set_bit(PORTD, 6); - } - // OFF-Time - sleep_nop(PIXEL_TOFF) - } - } - } + // bits der anzuzeigenden reihe auslesen (cube & (0b00000111 << cube_row_offset)) + // und in PORTD und Pin 8 von PORTA setzen + + // cube_row_offset += 3 // immer um 3 Bits weiter springen in 32Bit Variable + + // cube_row_offset auf 0 setzen wenn maximum überschritten (27-3 = 24) } diff --git a/firmware/main.h b/firmware/main.h index 72cd2ae..243866a 100644 --- a/firmware/main.h +++ b/firmware/main.h @@ -15,15 +15,14 @@ #include #include -//#include +#include //#include //#include -// Cube-Array -uint8_t cube[3][3][3]; -uint8_t buffer[3][3][3]; // Framebuffer - -volatile uint8_t frame_done = 0; +// Cube-Data +volatile uint32_t cube = 0x00000000; +// Bit Offset in Cube-Data +volatile uint8_t cube_row_offset = 0x00; // Prototypen void init(void);