From 4c368d27358a10341cd50c200b55fca1239285bf Mon Sep 17 00:00:00 2001 From: Bob van Loosen Date: Thu, 20 Dec 2012 16:58:23 +0100 Subject: [PATCH] added: start the text at position 0, and start scrolling after two seconds, but only if the text doesn't fit on the display --- src/bitvis.cpp | 23 +++++++++++++++++------ src/bitvis.h | 1 + 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/bitvis.cpp b/src/bitvis.cpp index 512a7c6..a0c694a 100644 --- a/src/bitvis.cpp +++ b/src/bitvis.cpp @@ -54,6 +54,7 @@ CBitVis::CBitVis(int argc, char *argv[]) m_nrlines = 48 - m_fontheight - 1; m_scrolloffset = 0; + m_songupdatetime = GetTimeUs(); m_mpdclient = new CMpdClient("music.bitlair", 6600); m_mpdclient->StartThread(); @@ -336,7 +337,10 @@ void CBitVis::SendData(int64_t time) string currentsong; if (m_mpdclient->CurrentSong(currentsong)) - m_scrolloffset = m_nrcolumns; + { + m_scrolloffset = 0; + m_songupdatetime = GetTimeUs(); + } SetText(text, currentsong.c_str()); data.SetData(text, sizeof(text), true); @@ -376,13 +380,20 @@ void CBitVis::SetText(uint8_t* buff, const char* str, int offset /*= 0*/) charpos++; pixlength++; } - charpos++; - pixlength++; + + if (i < length - 1) + { + charpos++; + pixlength++; + } } - m_scrolloffset--; - if (m_scrolloffset < -pixlength) - m_scrolloffset = m_nrcolumns; + if (pixlength > m_nrcolumns && GetTimeUs() - m_songupdatetime > 2000000) + { + m_scrolloffset--; + if (m_scrolloffset < -pixlength) + m_scrolloffset = m_nrcolumns; + } } void CBitVis::InitChars() diff --git a/src/bitvis.h b/src/bitvis.h index 4b134c2..ff84216 100644 --- a/src/bitvis.h +++ b/src/bitvis.h @@ -54,6 +54,7 @@ class CBitVis float m_decay; int m_fontheight; int m_scrolloffset; + int64_t m_songupdatetime; CMpdClient* m_mpdclient; struct peak