From 7ce050f2387c2276218a7c002d7631dd3edd0c72 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 12 Jan 2016 13:02:17 +0100 Subject: add display render loop and example image --- main.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/main.c b/main.c index 1911237..0529721 100644 --- a/main.c +++ b/main.c @@ -1,11 +1,14 @@ #include +#include +#include #include #include #include +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; +} -- cgit v1.2.3