summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-03-16 20:20:40 +0100
committerDaniel Friesel <derf@finalrewind.org>2016-03-16 20:20:40 +0100
commitbdb7cce4d563250f567dac299c4cab25d01bf329 (patch)
tree8e7a336198cabbe083b273209d5f621c9b44a37f
parenta7552770f8d98f8993c56d592a59b9963eb6e51f (diff)
Fix occasional lag when switching animations
-rw-r--r--src/display.cc7
-rw-r--r--src/display.h7
2 files changed, 10 insertions, 4 deletions
diff --git a/src/display.cc b/src/display.cc
index f06b5e3..98b394a 100644
--- a/src/display.cc
+++ b/src/display.cc
@@ -45,8 +45,6 @@ void Display::enable()
void Display::multiplex()
{
- static uint8_t scroll;
-
/*
* To avoid flickering, do not put any code (or expensive index
* calculations) between the following three lines.
@@ -57,8 +55,8 @@ void Display::multiplex()
if (++active_col == 8) {
active_col = 0;
- if (++scroll == current_anim->speed) {
- scroll = 0;
+ if (++update_cnt == current_anim->speed) {
+ update_cnt = 0;
need_update = 1;
}
}
@@ -170,6 +168,7 @@ void Display::reset()
{
for (uint8_t i = 0; i < 8; i++)
disp_buf[i] = 0xff;
+ update_cnt = 0;
str_pos = 0;
str_chunk = 0;
char_pos = -1;
diff --git a/src/display.h b/src/display.h
index fd91994..1bf5758 100644
--- a/src/display.h
+++ b/src/display.h
@@ -88,6 +88,13 @@ class Display {
animation_t *current_anim;
/**
+ * Internal display update counter. Incremented by multiplex().
+ * update() is called (and the counter reset) whenever
+ * update_cnt == need_update.
+ */
+ uint8_t update_cnt;
+
+ /**
* Set to a true value by multiplex() if an update (that is,
* a scroll step or a new frame) is needed. Checked and reset to
* false by update().