diff options
author | Sebastian Muszytowski <sebastian@muszytowski.net> | 2016-01-22 18:52:10 +0100 |
---|---|---|
committer | Sebastian Muszytowski <sebastian@muszytowski.net> | 2016-01-22 18:52:10 +0100 |
commit | 724f650b968e4029dfdd0f355cc8669e098b6880 (patch) | |
tree | 939baef3b38c1844d0dc35882b640b3b6def7a94 /src/display.cc | |
parent | 6e41844bfa547a69a2fbd8effb09aae15b203bff (diff) | |
parent | 84758ec540877a79d2c9a4403b2023aa5d31eb17 (diff) |
Merge branch 'master' of github.com:blinkenrocket/firmware
Diffstat (limited to 'src/display.cc')
-rw-r--r-- | src/display.cc | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/display.cc b/src/display.cc index b0bc636..2059c9b 100644 --- a/src/display.cc +++ b/src/display.cc @@ -11,16 +11,8 @@ 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; + update_delay = 400; } void Display::disable() @@ -45,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 @@ -59,8 +49,17 @@ void Display::multiplex() if (++active_col == 8) active_col = 0; - if (++scroll == scroll_delay) { + if (++scroll == update_delay) { scroll = 0; + need_update = 1; + } +} + +void Display::update() { + uint8_t i, glyph_len; + uint8_t *glyph_addr; + if (need_update) { + need_update = 0; for (i = 0; i < 7; i++) { disp_buf[i] = disp_buf[i+1]; @@ -89,12 +88,25 @@ 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(const char *new_str) +{ + setString((char *)new_str); +} + +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. |