From 119e9889c954441cdb7ac562d068958b731fe3f7 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sun, 22 Jun 2014 13:30:58 +0200 Subject: [PATCH] Missing bugfix added. --- firmware/main.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/firmware/main.c b/firmware/main.c index 245bbca..d96f667 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -81,8 +81,8 @@ ISR (TIMER1_COMPA_vect) delay = (frame >> 24) & 0xf8; } - // PORTD = __, 9, C, B, A,D+,D-,__ - PORTD &= 0b10000111; // delete bit 3 to 6 (bit 3 to 5 = layer 0 to 2; bit 6 = wire 9 to the LEDs) + // !!!Don't touch the 6th bit (9th LED wire)!!! + 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 @@ -91,13 +91,20 @@ ISR (TIMER1_COMPA_vect) PORTB = ~((frame >> tmp) & 0xff); if ( (((frame >> tmp) >> 8) & 0x01) ) - PORTD &= ~(1 << 6); // turn the 9th LED on if required + PORTD &= ~(1 << 6); // turn the 9th LED on + else + PORTD |= (1 << 6); // turn the 9th LED off - PORTD |= (1 << 6) | ((1 << level) << 3); // set the current level and pin 6 to high (9th LEDs off) + // set the current level to high + // at this point the LED pins are up to date so it's + // safe to reenable the level wire (A/B/C) + // this prevents wierd LED flashing which is not defined + // in the animation frame + PORTD |= ((1 << level) << 3); // rotate through the 3 level level++; - if (level > 2) level = 0; + if (level > 2) + level = 0; } -