Skip to content

Commit

Permalink
fixed rotation timer
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner committed May 19, 2024
1 parent 1e65b2a commit 6abb815
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions src/DMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,32 +734,14 @@ void DMD::SerumThread()
return m_dmdFrameReady || m_stopFlag ||
(nextRotation > 0 && std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count() < nextRotation);
.count() > nextRotation);
});
sl.unlock();
if (m_stopFlag)
{
return;
}

if (!m_dmdFrameReady && nextRotation > 0 && m_pSerum && m_pSerum->rotationtimer > 0)
{
uint32_t result = Serum_Rotate();

if (result != IDENTIFY_NO_FRAME)
{
QueueSerumFrames(currentBufferPosition);

if (result > 0)
nextRotation = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count() +
m_pSerum->rotationtimer;
else
nextRotation = 0;
}
}

while (!m_stopFlag && bufferPosition != m_updateBufferQueuePosition)
{
bufferPosition = GetNextBufferQueuePosition(bufferPosition);
Expand Down Expand Up @@ -789,13 +771,13 @@ void DMD::SerumThread()

if (m_pSerum && m_pUpdateBufferQueue[currentBufferPosition]->mode == Mode::Data)
{
uint32_t result = Serum_Colorize(m_pUpdateBufferQueue[currentBufferPosition]->data);
uint16_t result = Serum_Colorize(m_pUpdateBufferQueue[currentBufferPosition]->data);

if (result != IDENTIFY_NO_FRAME)
{
QueueSerumFrames(currentBufferPosition);

if (result > 0)
if (result > 0 && result < 1024)
nextRotation = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count() +
Expand All @@ -811,6 +793,26 @@ void DMD::SerumThread()
}
}
}

if (!m_stopFlag && m_pSerum && nextRotation > 0 && m_pSerum->rotationtimer > 0 &&
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch())
.count() > nextRotation)
{
uint16_t result = Serum_Rotate();

if (result != IDENTIFY_NO_FRAME)
{
QueueSerumFrames(currentBufferPosition);

if (result > 0 && result < 1024)
nextRotation = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count() +
m_pSerum->rotationtimer;
else
nextRotation = 0;
}
}
}
}
}
Expand Down

0 comments on commit 6abb815

Please sign in to comment.