diff options
author | Daniel Friesel <derf@finalrewind.org> | 2016-01-22 16:37:10 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2016-01-22 16:37:32 +0100 |
commit | b71f23b93acdd3aa28066bd6edc7bcb63d518bfe (patch) | |
tree | 76003f9fbb17e4b9c7d7806380052c0e6b2cf41e /src | |
parent | 83d6a0ee679e73c89d0ba84602d3052527726230 (diff) |
display: Don't run (rather slow) scroll code in ISR
Diffstat (limited to 'src')
-rw-r--r-- | src/display.cc | 16 | ||||
-rw-r--r-- | src/display.h | 3 | ||||
-rw-r--r-- | src/main.cc | 9 |
3 files changed, 24 insertions, 4 deletions
diff --git a/src/display.cc b/src/display.cc index 42710c9..82c5020 100644 --- a/src/display.cc +++ b/src/display.cc @@ -37,8 +37,6 @@ void Display::enable() void Display::multiplex() { static uint16_t scroll; - uint8_t i, glyph_len; - uint8_t *glyph_addr; /* * To avoid flickering, do not put any code (or expensive index @@ -53,6 +51,15 @@ void Display::multiplex() if (++scroll == scroll_delay) { scroll = 0; + need_scroll = 1; + } +} + +void Display::scroll() { + uint8_t i, glyph_len; + uint8_t *glyph_addr; + if (need_scroll) { + need_scroll = 0; for (i = 0; i < 7; i++) { disp_buf[i] = disp_buf[i+1]; @@ -87,6 +94,11 @@ void Display::reset() char_pos = -1; } +void Display::setString(const char *new_str) +{ + setString((char *)new_str); +} + void Display::setString(char *new_str) { reset(); diff --git a/src/display.h b/src/display.h index f0ea0a4..0887f72 100644 --- a/src/display.h +++ b/src/display.h @@ -7,6 +7,7 @@ class Display { private: uint16_t scroll_delay; + uint8_t need_scroll; uint8_t active_col; uint8_t disp_buf[8]; uint8_t str_pos; @@ -18,6 +19,8 @@ class Display { void disable(void); void multiplex(void); void reset(void); + void scroll(void); + void setString(const char *str); void setString(char *str); }; diff --git a/src/main.cc b/src/main.cc index aefad1c..78cbd88 100644 --- a/src/main.cc +++ b/src/main.cc @@ -31,9 +31,14 @@ int main (void) // nothing to do here, go to idle to save power SMCR = _BV(SE); asm("sleep"); - // The display timer causes a wakeup after 256µs. Run the system - // loop after the timer's ISR is done. + /* + * The display timer causes a wakeup after 256µs. Run the system + * loop after the timer's ISR is done. + * The Modem also causes wakeups, which is pretty convenient since + * it means we can immediately process the received data. + */ rocket.loop(); + display.scroll(); } return 0; |