From b71f23b93acdd3aa28066bd6edc7bcb63d518bfe Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 22 Jan 2016 16:37:10 +0100 Subject: display: Don't run (rather slow) scroll code in ISR --- src/display.cc | 16 ++++++++++++++-- src/display.h | 3 +++ 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; -- cgit v1.2.3