diff options
author | Daniel Friesel <derf@finalrewind.org> | 2016-02-27 14:50:14 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2016-02-27 14:50:14 +0100 |
commit | 15e021913a1fbd8ead848dc15bb2aab5f2e5534b (patch) | |
tree | 9d705ccb134e9159c38804c8f53adb3b35522b33 | |
parent | 1259de61e7b05ffef9f64bd478e96e3432c0d5a8 (diff) |
display: support scrolling in both directions
-rw-r--r-- | src/display.cc | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/display.cc b/src/display.cc index faa3d2e..87d863f 100644 --- a/src/display.cc +++ b/src/display.cc @@ -61,11 +61,20 @@ void Display::update() { if (status == RUNNING) { if (current_anim->type == AnimationType::TEXT) { - for (i = 0; i < 7; i++) { - disp_buf[i] = disp_buf[i+1]; + if (current_anim->direction == 0) { + for (i = 0; i < 7; i++) { + disp_buf[i] = disp_buf[i+1]; + } + } else if (current_anim->direction == 1) { + for (i = 7; i > 0; i--) { + disp_buf[i] = disp_buf[i-1]; + } } - glyph_addr = (uint8_t *)pgm_read_ptr(&font[current_anim->data[str_pos]]); + if (current_anim->direction == 0) + glyph_addr = (uint8_t *)pgm_read_ptr(&font[current_anim->data[str_pos]]); + else + glyph_addr = (uint8_t *)pgm_read_ptr(&font[current_anim->data[current_anim->length - 1 - str_pos]]); glyph_len = pgm_read_byte(&glyph_addr[0]); char_pos++; @@ -74,11 +83,20 @@ void Display::update() { str_pos++; } - if (char_pos == 0) { - disp_buf[7] = 0xff; // whitespace + if (current_anim->direction == 0) { + if (char_pos == 0) { + disp_buf[7] = 0xff; // whitespace + } else { + disp_buf[7] = ~pgm_read_byte(&glyph_addr[char_pos]); + } } else { - disp_buf[7] = ~pgm_read_byte(&glyph_addr[char_pos]); + if (char_pos == 0) { + disp_buf[0] = 0xff; // whitespace + } else { + disp_buf[0] = ~pgm_read_byte(&glyph_addr[glyph_len - char_pos + 1]); + } } + } else if (current_anim->type == AnimationType::FRAMES) { for (i = 0; i < 8; i++) { disp_buf[i] = ~current_anim->data[str_pos+i]; |