From a570bd9546f64abce89f8450182ff06deb7ed676 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 30 Aug 2013 02:31:32 +0000 Subject: [PATCH] The video buffer is already pre-cleared by virtue of being in the BSS, so don't bother to do it in Init(). It's harmless to allow a Flip() in single-buffer mode. Saves another 62 bytes of code. --- lib/Charliplexing.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/Charliplexing.cpp b/lib/Charliplexing.cpp index 21b3432..d4550e8 100644 --- a/lib/Charliplexing.cpp +++ b/lib/Charliplexing.cpp @@ -267,10 +267,7 @@ void LedSign::Init(uint8_t mode) backTimer = &timer[1]; frontTimer = &timer[0]; - SetBrightness(127); - - // Clear the buffer and display it - LedSign::Clear(0); + LedSign::SetBrightness(127); // Then start the display #if defined (__AVR_ATmega168__) || defined (__AVR_ATmega48__) || defined (__AVR_ATmega88__) || defined (__AVR_ATmega328P__) || defined (__AVR_ATmega1280__) || defined (__AVR_ATmega2560__) @@ -303,16 +300,13 @@ void LedSign::Init(uint8_t mode) */ void LedSign::Flip(bool blocking) { - if (displayMode & DOUBLE_BUFFER) - { - // Just set the flip flag, the buffer will flip between redraws - videoFlipPage = true; + // Just set the flip flag, the buffer will flip between redraws + videoFlipPage = true; - // If we are blocking, sit here until the page flips. - if (blocking) - while (videoFlipPage) - ; - } + // If we are blocking, sit here until the page flips. + if (blocking) + while (videoFlipPage) + ; } #endif @@ -546,9 +540,8 @@ ISR(TIMER1_COMPA_vect) { #ifdef DOUBLE_BUFFER // If the page should be flipped, do it here. - if (videoFlipPage && (displayMode & DOUBLE_BUFFER)) + if (videoFlipPage) { - // TODO: is this an atomic operation? videoFlipPage = false; videoPage* temp = displayBuffer;