Skip to content

Commit

Permalink
drop frames that use a refresh rate over 125Hz
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner committed Feb 17, 2025
1 parent cd3ad2e commit 5001a07
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
11 changes: 11 additions & 0 deletions src/ZeDMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,17 @@ void ZeDMD::RenderRgb565(uint16_t* pFrame)
}
bool ZeDMD::UpdateFrameBuffer888(uint8_t* pFrame)
{
static auto lastExecutionTime = std::chrono::steady_clock::now();

auto currentTime = std::chrono::steady_clock::now();

// 8ms means 125Hz. Drop frames of that and higher frame rates because ZeDMD HD can't handle them.
if (std::chrono::duration_cast<std::chrono::milliseconds>(currentTime - lastExecutionTime).count() < 8) {
return false;
}

lastExecutionTime = currentTime;

if (0 == memcmp(m_pFrameBuffer, pFrame, m_romWidth * m_romHeight * 3))
{
return false;
Expand Down
9 changes: 4 additions & 5 deletions src/ZeDMDComm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,10 +914,10 @@ bool ZeDMDComm::SendChunks(uint8_t* pData, uint16_t size)
defined(__ANDROID__))

static uint8_t guru[4] = {'G', 'u', 'r', 'u'};
uint8_t ack[CTRL_CHARS_HEADER_SIZE + 1] = {0};
uint8_t ack[CTRL_CHARS_HEADER_SIZE + 2] = {0};
int status = 0;
uint16_t sent = 0;
uint8_t message[64];
uint8_t message[65] = {0};

while (sp_input_waiting(m_pSerialPort) > 0)
{
Expand Down Expand Up @@ -979,7 +979,7 @@ bool ZeDMDComm::SendChunks(uint8_t* pData, uint16_t size)
}
sent += status;

memset(ack, 0, CTRL_CHARS_HEADER_SIZE + 1);
memset(ack, 0, CTRL_CHARS_HEADER_SIZE + 2);
status = sp_blocking_read(m_pSerialPort, ack, CTRL_CHARS_HEADER_SIZE + 1, ZEDMD_COMM_SERIAL_READ_TIMEOUT);

if (status < (CTRL_CHARS_HEADER_SIZE + 1) || memcmp(ack, CTRL_CHARS_HEADER, CTRL_CHARS_HEADER_SIZE) != 0 ||
Expand All @@ -988,10 +988,9 @@ bool ZeDMDComm::SendChunks(uint8_t* pData, uint16_t size)
if (memcmp(ack, guru, 4) == 0 || memcmp(&ack[1], guru, 4) == 0 || memcmp(&ack[2], guru, 4) == 0)
{
Log("ZeDMD %s", ack);
uint8_t message[64];
while (sp_input_waiting(m_pSerialPort) > 0)
{
memset(message, ' ', 64);
memset(message, 0, 65);
if (sp_nonblocking_read(m_pSerialPort, message, 64) > 0)
{
Log("%s", message);
Expand Down
1 change: 1 addition & 0 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ int main(int argc, char* argv[])
if (save)
{
pZeDMD->SaveSettings();
pZeDMD->Reset();
}

if (opt_led_test)
Expand Down

0 comments on commit 5001a07

Please sign in to comment.