summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-01-12 13:02:17 +0100
committerDaniel Friesel <derf@finalrewind.org>2016-01-12 13:02:17 +0100
commit7ce050f2387c2276218a7c002d7631dd3edd0c72 (patch)
tree9c3f72be43cc6519ede53602763a074c0074fd1b
parentf078fe9b54424b6ba12a64d981607c0ead887078 (diff)
add display render loop and example image
-rw-r--r--main.c43
1 files 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 <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;
+}