diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 43 |
1 files changed, 32 insertions, 11 deletions
@@ -1,11 +1,14 @@ #include <avr/io.h> +#include <avr/interrupt.h> +#include <avr/sleep.h> #include <avr/wdt.h> #include <util/delay.h> #include <stdlib.h> +volatile uint8_t disp[8]; + int main (void) { - unsigned int i, j, h; wdt_disable(); DDRB = 0xff; @@ -14,18 +17,36 @@ int main (void) PORTB = 0; PORTD = 0; + TCCR0A = _BV(CS00); // no prescaler (/8 without software prescaler is okay too) + TIMSK0 = _BV(TOIE0); // interrupt on overflow + + // smile! + disp[0] = 0x08; + disp[1] = 0x04; + disp[2] = 0x62; + disp[3] = 0x02; + disp[4] = 0x02; + disp[5] = 0x62; + disp[6] = 0x04; + disp[7] = 0x08; + + sei(); + while (1) { - for (i = 1; i < 256; i *= 2) { - PORTB = i; - for (j = 1; j < 256; j *= 2) { - PORTD = ~j; - for (h = 1; h < 1; h++) { // use "h < 4096" for visible pixels (e.g. finding soldering errors) - asm("nop"); - } - } - PORTB = 0; - } + sleep_enable(); } return 0; } + +ISR(TIMER0_OVF_vect) +{ + static uint8_t active_col = 0; + + PORTB = 0; + PORTD = ~disp[active_col]; + PORTB = _BV(active_col); + + if (++active_col == 8) + active_col = 0; +} |