added: make peakhold direction configurable

This commit is contained in:
Bob van Loosen 2013-04-02 23:34:00 +02:00
parent a19e535343
commit b051549f6d
2 changed files with 28 additions and 9 deletions

View file

@ -64,6 +64,7 @@ CBitVis::CBitVis(int argc, char *argv[])
m_hasaudio = false;
m_scopesample = 0.0;
m_scopesamples = 0;
m_peakup = false;
m_fontheight = 0;
InitChars();
@ -75,7 +76,7 @@ CBitVis::CBitVis(int argc, char *argv[])
m_volumetime = GetTimeUs();
m_displayvolume = 0;
const char* flags = "f:d:p:a:m:o:";
const char* flags = "f:d:p:a:m:o:u";
int c;
while ((c = getopt(argc, argv, flags)) != -1)
{
@ -132,6 +133,10 @@ CBitVis::CBitVis(int argc, char *argv[])
m_mpdport = port;
}
else if (c == 'u') //peak hold goes up
{
m_peakup = true;
}
}
if (!m_address)
@ -627,18 +632,31 @@ void CBitVis::SendData(int64_t time)
{
pixel |= 3;
}
if (time - currpeak.time > 500000 && Round32(currpeak.value) > 0)
{
currpeak.value += 0.01f;
if (currpeak.value >= nrlines)
currpeak.value = 0.0f;
}
}
line[x] = pixel;
}
data.SetData(line, sizeof(line), true);
}
for (int i = 0; i < m_nrcolumns; i++)
{
peak& currpeak = m_peakholds[i];
if (time - currpeak.time > 500000 && Round32(currpeak.value) > 0)
{
if (m_peakup)
{
currpeak.value += 0.5f;
if (currpeak.value >= nrlines)
currpeak.value = 0.0f;
}
else
{
currpeak.value -= 0.5f;
if (currpeak.value <= 0.0f)
currpeak.value = 0.0f;
}
}
}
}
uint8_t text[m_nrcolumns / 4 * m_fontheight];

View file

@ -95,6 +95,7 @@ class CBitVis : public CThread
};
peak* m_peakholds;
bool m_peakup;
CMutex m_socketlock;
CTcpClientSocket m_socket;