diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/display.cc | 6 | ||||
-rw-r--r-- | src/display.h | 6 | ||||
-rw-r--r-- | src/system.cc | 12 |
3 files changed, 17 insertions, 7 deletions
diff --git a/src/display.cc b/src/display.cc index 98b394a..b0f5369 100644 --- a/src/display.cc +++ b/src/display.cc @@ -55,7 +55,7 @@ void Display::multiplex() if (++active_col == 8) { active_col = 0; - if (++update_cnt == current_anim->speed) { + if (++update_cnt == update_threshold) { update_cnt = 0; need_update = 1; } @@ -124,6 +124,7 @@ void Display::update() { str_pos = 0; if (current_anim->delay > 0) { status = PAUSED; + update_threshold = 244; } if (current_anim->length > 128) { storage.loadChunk(str_chunk, current_anim->data); @@ -139,6 +140,7 @@ void Display::update() { if (current_anim->delay > 0) { str_pos = 0; status = PAUSED; + update_threshold = 244; } else { str_pos = (current_anim->length - 1) % 128; } @@ -159,6 +161,7 @@ void Display::update() { else str_pos = 127; status = RUNNING; + update_threshold = current_anim->speed; } } } @@ -180,6 +183,7 @@ void Display::show(animation_t *anim) { current_anim = anim; reset(); + update_threshold = current_anim->speed; if (current_anim->direction == 1) { if (current_anim->length > 128) { str_chunk = (current_anim->length - 1) / 128; diff --git a/src/display.h b/src/display.h index 1bf5758..aac64dd 100644 --- a/src/display.h +++ b/src/display.h @@ -102,6 +102,12 @@ class Display { uint8_t need_update; /** + * Number of frames after which update() is called. This value + * holds either the current animation's speed or its delay. + */ + uint8_t update_threshold; + + /** * The currently active column in multiplex() */ uint8_t active_col; diff --git a/src/system.cc b/src/system.cc index 9e36c0a..7e43966 100644 --- a/src/system.cc +++ b/src/system.cc @@ -83,11 +83,11 @@ void System::loadPattern_buf(uint8_t *pattern) if (active_anim.type == AnimationType::TEXT) { active_anim.speed = 250 - (pattern[2] & 0xf0); - active_anim.delay = (pattern[2] & 0x0f ) << 4; + active_anim.delay = (pattern[2] & 0x0f ); active_anim.direction = pattern[3] >> 4; } else if (active_anim.type == AnimationType::FRAMES) { active_anim.speed = 250 - ((pattern[2] & 0x0f) << 4); - active_anim.delay = (pattern[3] & 0x0f) << 2; + active_anim.delay = (pattern[3] & 0x0f); active_anim.direction = 0; } @@ -288,9 +288,9 @@ void System::shutdown() display.update(); // and some more to debounce the buttons (and finish powerdown animation) - for (i = 0; i < 100; i++) { + for (i = 0; i < 200; i++) { display.update(); - _delay_ms(2); + _delay_ms(1); } // turn off display to indicate we're about to shut down @@ -319,9 +319,9 @@ void System::shutdown() display.update(); // debounce - for (i = 0; i < 50; i++) { + for (i = 0; i < 100; i++) { display.update(); - _delay_ms(2); + _delay_ms(1); } // finally, turn on the modem... |