diff options
author | Daniel Friesel <derf@finalrewind.org> | 2016-01-16 18:55:40 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2016-01-16 18:55:40 +0100 |
commit | cd52b9a6b0272466f414ce4802ce50a0ec38dd29 (patch) | |
tree | b68e8c8910053165322ed150a88f7047532acf19 /src/display.cc | |
parent | 69b343aac3dce2ac87830ce5181eea8d11144de2 (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.cc | 13 |
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); } /* |