From 83d6a0ee679e73c89d0ba84602d3052527726230 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 22 Jan 2016 16:27:33 +0100 Subject: make display buffer private, add separate modem receive buffer --- src/display.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/display.cc') diff --git a/src/display.cc b/src/display.cc index b0bc636..42710c9 100644 --- a/src/display.cc +++ b/src/display.cc @@ -11,14 +11,6 @@ Display display; Display::Display() { - disp_buf[0] = 0xff; - disp_buf[1] = 0xfb; - disp_buf[2] = 0xdd; - disp_buf[3] = 0xfd; - disp_buf[4] = 0xdd; - disp_buf[5] = 0xfb; - disp_buf[6] = 0xff; - disp_buf[7] = 0xff; char_pos = -1; scroll_delay = 400; } @@ -89,12 +81,20 @@ void Display::multiplex() void Display::reset() { - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) disp_buf[i] = 0xff; str_pos = 0; char_pos = -1; } +void Display::setString(char *new_str) +{ + reset(); + for (uint8_t i = 0; new_str[i] != 0; i++) { + string[i] = new_str[i]; + } +} + /* * Draws a single display column. This function should be called at least once * per millisecond. -- cgit v1.2.3 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(-) (limited to 'src/display.cc') 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 From 84758ec540877a79d2c9a4403b2023aa5d31eb17 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 22 Jan 2016 16:44:53 +0100 Subject: display: rename *scroll* to *update* (would be confusing for animations otherwise) --- src/display.cc | 12 ++++++------ src/display.h | 6 +++--- src/main.cc | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/display.cc') diff --git a/src/display.cc b/src/display.cc index 82c5020..2059c9b 100644 --- a/src/display.cc +++ b/src/display.cc @@ -12,7 +12,7 @@ Display display; Display::Display() { char_pos = -1; - scroll_delay = 400; + update_delay = 400; } void Display::disable() @@ -49,17 +49,17 @@ void Display::multiplex() if (++active_col == 8) active_col = 0; - if (++scroll == scroll_delay) { + if (++scroll == update_delay) { scroll = 0; - need_scroll = 1; + need_update = 1; } } -void Display::scroll() { +void Display::update() { uint8_t i, glyph_len; uint8_t *glyph_addr; - if (need_scroll) { - need_scroll = 0; + if (need_update) { + need_update = 0; for (i = 0; i < 7; i++) { disp_buf[i] = disp_buf[i+1]; diff --git a/src/display.h b/src/display.h index 0887f72..f48d1c3 100644 --- a/src/display.h +++ b/src/display.h @@ -6,8 +6,8 @@ class Display { private: - uint16_t scroll_delay; - uint8_t need_scroll; + uint16_t update_delay; + uint8_t need_update; uint8_t active_col; uint8_t disp_buf[8]; uint8_t str_pos; @@ -19,7 +19,7 @@ class Display { void disable(void); void multiplex(void); void reset(void); - void scroll(void); + void update(void); void setString(const char *str); void setString(char *str); }; diff --git a/src/main.cc b/src/main.cc index 78cbd88..4398d02 100644 --- a/src/main.cc +++ b/src/main.cc @@ -38,7 +38,7 @@ int main (void) * it means we can immediately process the received data. */ rocket.loop(); - display.scroll(); + display.update(); } return 0; -- cgit v1.2.3