From 8b1bad7e3e8d9311cb881e4df2101203f5a1eb9e Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 29 Jan 2016 16:57:52 +0100 Subject: check ->length for texts, too --- src/display.cc | 10 +++------- src/main.cc | 4 ++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/display.cc b/src/display.cc index 5a652c8..970d823 100644 --- a/src/display.cc +++ b/src/display.cc @@ -74,10 +74,6 @@ void Display::update() { str_pos++; } - if (active_anim->data[str_pos] == 0) { - str_pos = 0; - } - if (char_pos == 0) { disp_buf[7] = 0xff; // whitespace } else { @@ -88,9 +84,9 @@ void Display::update() { disp_buf[i] = ~active_anim->data[str_pos+i]; } str_pos += 8; - if (str_pos == active_anim->length) { - str_pos = 0; - } + } + if (str_pos >= active_anim->length) { + str_pos = 0; } } } diff --git a/src/main.cc b/src/main.cc index a8fb5d3..91ff92a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -15,8 +15,8 @@ int main (void) animation_t ohai; ohai.mode = AnimationType::TEXT; ohai.speed = (4 << 4) + 15; - ohai.data = (uint8_t *)"Ohai! "; - ohai.length = 6; + ohai.data = (uint8_t *)"\001 Ohai "; + ohai.length = 8; uint8_t anim_data[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0 }; -- cgit v1.2.3