Changes from last meeting.

This commit is contained in:
Kai Lauterbach 2011-11-05 16:52:02 +01:00
parent 7cd1ac3d2e
commit d5941812cc
2 changed files with 22 additions and 34 deletions

View file

@ -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)
}

View file

@ -15,15 +15,14 @@
#include <avr/interrupt.h>
#include <avr/io.h>
//#include <util/delay.h>
#include <util/delay.h>
//#include <avr/pgmspace.h>
//#include <avr/wdt.h>
// 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);