From 0e42a6028b7b9330ca69e4fbeeecfa3affa53346 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 13 Jan 2016 20:39:04 +0100 Subject: main: prepare for non-static display buffer --- main.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 6bfabe1..e1f0fb8 100644 --- a/main.c +++ b/main.c @@ -4,6 +4,8 @@ #include #include +#include "font.h" + #define SHUTDOWN_THRESHOLD 2048 volatile uint8_t disp[32]; @@ -32,6 +34,8 @@ int main (void) // raise timer interrupt on counter overflow (-> interrupt frequency = ~4kHz) TIMSK0 = _BV(TOIE0); + //disp = font[2]; +#if 1 // smile! disp[0] = 0x08; disp[1] = 0x04; @@ -65,6 +69,7 @@ int main (void) disp[29] = 0x00; disp[30] = 0x00; disp[31] = 0x00; +#endif sei(); @@ -130,23 +135,27 @@ ISR(TIMER0_OVF_vect) static uint16_t scroll = 0; static uint8_t disp_offset = 0; - uint8_t buffer_col; + static uint8_t display[8]; + + uint8_t i; if (++scroll == 256) { scroll = 0; if (++disp_offset == sizeof(disp)) { disp_offset = 0; } - } - buffer_col = (disp_offset + active_col) % sizeof(disp); + for (i = 0; i < 8; i++) { + display[i] = ~disp[(disp_offset + i) % sizeof(disp)]; + } + } /* * To avoid flickering, do not put any code (or expensive index * calculations) between the following three lines. */ PORTB = 0; - PORTD = ~disp[buffer_col]; + PORTD = display[active_col]; PORTB = _BV(active_col); if (++active_col == 8) -- cgit v1.2.3