Some small performance improvements from Thomas Kopp.

This commit is contained in:
Aaron Mueller 2014-06-22 21:06:06 +02:00
parent 119e9889c9
commit 5fe28a0205

View file

@ -38,7 +38,7 @@ void init()
PORTD = 0b01000000;
// Setup Timer-Interrupt "TIMER1" compare match interrupt
TIMSK |= (1 << OCIE1A);
TIMSK = (1 << OCIE1A);
// Refreshrate is 100Hz of the whole LEDCube.
// The ISR comes up at 300Hz.
@ -48,7 +48,7 @@ void init()
OCR1AL = 0b01110001;
// Set prescale to 64 and clear the counter on compare match.
TCCR1B |= (1 << CS11) | (1 << CS10) | (1 << WGM12);
TCCR1B = (1 << CS11) | (1 << CS10) | (1 << WGM12);
sei(); // Enable interrupts global
}
@ -57,8 +57,7 @@ void init()
*/
ISR (TIMER1_COMPA_vect)
{
if ( !(--delay) ) // decrease the counter and check if we are done with waiting
if (!(--delay)) // decrease the counter and check if we are done with waiting
{
if (frmnum == MAX_EEPROM_FRAMES)
{
@ -82,6 +81,7 @@ ISR (TIMER1_COMPA_vect)
}
// !!!Don't touch the 6th bit (9th LED wire)!!!
// PORTD = __, 9, C, B, A, D+, D-, __
PORTD &= 0b11000111; // delete bit 3 to 6 (bit 3 to 5 = layer 0 to 2
uint8_t tmp = level * 9; // calculate the position in the frame
@ -90,7 +90,7 @@ ISR (TIMER1_COMPA_vect)
// 0 = led is on, 1 = led is off
PORTB = ~((frame >> tmp) & 0xff);
if ( (((frame >> tmp) >> 8) & 0x01) )
if ((((frame >> tmp) >> 8) & 0x01))
PORTD &= ~(1 << 6); // turn the 9th LED on
else
PORTD |= (1 << 6); // turn the 9th LED off