Skip to content

Commit a570bd9

Browse files
author
root
committed
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.
1 parent 1d80dc2 commit a570bd9

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

lib/Charliplexing.cpp

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,7 @@ void LedSign::Init(uint8_t mode)
267267
backTimer = &timer[1];
268268
frontTimer = &timer[0];
269269

270-
SetBrightness(127);
271-
272-
// Clear the buffer and display it
273-
LedSign::Clear(0);
270+
LedSign::SetBrightness(127);
274271

275272
// Then start the display
276273
#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)
303300
*/
304301
void LedSign::Flip(bool blocking)
305302
{
306-
if (displayMode & DOUBLE_BUFFER)
307-
{
308-
// Just set the flip flag, the buffer will flip between redraws
309-
videoFlipPage = true;
310-
311-
// If we are blocking, sit here until the page flips.
312-
if (blocking)
313-
while (videoFlipPage)
314-
;
315-
}
303+
// Just set the flip flag, the buffer will flip between redraws
304+
videoFlipPage = true;
305+
306+
// If we are blocking, sit here until the page flips.
307+
if (blocking)
308+
while (videoFlipPage)
309+
;
316310
}
317311
#endif
318312

@@ -546,9 +540,8 @@ ISR(TIMER1_COMPA_vect) {
546540

547541
#ifdef DOUBLE_BUFFER
548542
// If the page should be flipped, do it here.
549-
if (videoFlipPage && (displayMode & DOUBLE_BUFFER))
543+
if (videoFlipPage)
550544
{
551-
// TODO: is this an atomic operation?
552545
videoFlipPage = false;
553546

554547
videoPage* temp = displayBuffer;

0 commit comments

Comments
 (0)