From 387018c94f7cd138cba5fe85eb0c5c58a0a7f00c Mon Sep 17 00:00:00 2001 From: root Date: Sun, 11 Jul 2010 16:16:46 +0200 Subject: * Add option to control volume bargraph --- vfd.c | 85 +++++++++++++++++++++++++++++++++---------------------------------- 1 file changed, 42 insertions(+), 43 deletions(-) (limited to 'vfd.c') diff --git a/vfd.c b/vfd.c index 0b73ae9..7dd7f01 100644 --- a/vfd.c +++ b/vfd.c @@ -373,57 +373,56 @@ void cVFD::clear() bool cVFD::flush(bool refreshAll) { - unsigned int n, x, yb; + unsigned int n, x, yb; - if (!backingstore || !framebuf) - return false; + if (!backingstore || !framebuf) + return false; + + const uchar* fb = framebuf->getBitmap(); + const unsigned int width = framebuf->Width(); + + bool doRefresh = false; + unsigned int minX = width; + unsigned int maxX = 0; + + for (yb = 0; yb < m_iSizeYb; ++yb) + for (x = 0; x < width; ++x) + { + n = x + (yb * width); + if (*(fb + n) != *(backingstore + n)) + { + *(backingstore + n) = *(fb + n); + minX = min(minX, x); + maxX = max(maxX, x + 1); + doRefresh = true; + } + } + + if (refreshAll || doRefresh) { + if (refreshAll) { + minX = 0; + maxX = width; + } - const uchar* fb = framebuf->getBitmap(); - const unsigned int width = framebuf->Width(); + maxX = min(maxX, width); - bool doRefresh = false; - unsigned int minX = width; - unsigned int maxX = 0; + unsigned int nData = (maxX-minX) * m_iSizeYb; + if(nData) { + // send data to display, controller + QueueCmd(CMD_SETRAM); + QueueData(minX*m_iSizeYb); + QueueCmd(CMD_SETPIXEL); + QueueData(nData); - for (yb = 0; yb < m_iSizeYb; ++yb) - for (x = 0; x < width; ++x) + for (x = minX; x < maxX; ++x) + for (yb = 0; yb < m_iSizeYb; ++yb) { n = x + (yb * width); - if (*(fb + n) != *(backingstore + n)) - { - *(backingstore + n) = *(fb + n); - minX = min(minX, x); - maxX = max(maxX, x + 1); - doRefresh = true; - } + QueueData((*(backingstore + n))); } - - if (refreshAll || doRefresh) - { - if (refreshAll) { - minX = 0; - maxX = width; - } - - maxX = min(maxX, width); - - unsigned int nData = (maxX-minX) * m_iSizeYb; - if(nData) { - // send data to display, controller - QueueCmd(CMD_SETRAM); - QueueData(minX*m_iSizeYb); - QueueCmd(CMD_SETPIXEL); - QueueData(nData); - - for (x = minX; x < maxX; ++x) - for (yb = 0; yb < m_iSizeYb; ++yb) - { - n = x + (yb * width); - QueueData((*(backingstore + n))); - } } - } - return QueueFlush(); + } + return QueueFlush(); } /** -- cgit v1.2.3