summaryrefslogtreecommitdiff
path: root/src/display.cc
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-01-16 18:55:40 +0100
committerDaniel Friesel <derf@finalrewind.org>2016-01-16 18:55:40 +0100
commitcd52b9a6b0272466f414ce4802ce50a0ec38dd29 (patch)
treeb68e8c8910053165322ed150a88f7047532acf19 /src/display.cc
parent69b343aac3dce2ac87830ce5181eea8d11144de2 (diff)
display: rename turn_on/off to enable/disable, move setup code from main to enable
Diffstat (limited to 'src/display.cc')
-rw-r--r--src/display.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/display.cc b/src/display.cc
index e06f271..b1b0af5 100644
--- a/src/display.cc
+++ b/src/display.cc
@@ -10,16 +10,23 @@ Display display;
extern volatile uint8_t disp[8];
-void Display::turn_off()
+void Display::disable()
{
TIMSK0 &= ~_BV(TOIE0);
PORTB = 0;
PORTD = 0;
}
-void Display::turn_on()
+void Display::enable()
{
- TIMSK0 |= _BV(TOIE0);
+ // Ports B and D drive the dot matrix display -> set all as output
+ DDRB = 0xff;
+ DDRD = 0xff;
+
+ // Enable 8bit counter with prescaler=8 (-> timer frequency = 1MHz)
+ TCCR0A = _BV(CS01);
+ // raise timer interrupt on counter overflow (-> interrupt frequency = ~4kHz)
+ TIMSK0 = _BV(TOIE0);
}
/*