Skip to content

Commit

Permalink
better zone clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner committed Jan 21, 2024
1 parent be65043 commit e34de88
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/ZeDMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ void ZeDMD::RenderRgb24(uint8_t* pFrame) {
if (m_wifi) {
m_pZeDMDWiFi->QueueCommand(ZEDMD_COMM_COMMAND::RGB24ZonesStream, m_pPlanes,
bufferSize, width, height);
} else if (m_hd || m_rgb24Streaming) {
} else if (m_hd || m_rgb24Streaming || m_streaming) {
m_pZeDMDComm->QueueCommand(ZEDMD_COMM_COMMAND::RGB24ZonesStream, m_pPlanes,
bufferSize, width, height);
} else if (m_usb) {
Expand Down
11 changes: 6 additions & 5 deletions src/ZeDMDComm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,6 @@ void ZeDMDComm::QueueCommand(char command, uint8_t* data, int size,
return;
}

if (command == ZEDMD_COMM_COMMAND::ClearScreen) {
// Next frame needs to be complete.
memset(m_zoneHashes, 0, 128);
}

ZeDMDFrame frame = {0};
frame.command = command;
frame.size = size;
Expand All @@ -157,6 +152,8 @@ void ZeDMDComm::QueueCommand(char command, uint8_t* data, int size,
m_delayedFrameReady = true;
m_delayedFrameMutex.unlock();
m_lastStreamId = -1;
// Next streaming needs to be complete.
memset(m_zoneHashes, 0, 128);
}
// delayed streamed zones
else if (streamId != -1 && delayed) {
Expand All @@ -172,6 +169,10 @@ void ZeDMDComm::QueueCommand(char command, uint8_t* data, int size,
}
m_frames.push(frame);
m_frameQueueMutex.unlock();
if (streamId == -1) {
// Next streaming needs to be complete.
memset(m_zoneHashes, 0, 128);
}
}
}

Expand Down
61 changes: 53 additions & 8 deletions src/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,44 @@ int main(int argc, const char* argv[]) {

if (pZeDMD->Open(128, 32)) {
pZeDMD->EnableDebug();

uint8_t* pImage2 = CreateImage(2);
uint8_t* pImage4 = CreateImage(4);
uint8_t* pImage24 = CreateImageRGB24();

for (int i = 0; i < 5; i++) {
for (int i = 0; i < 3; i++) {
printf("Render loop: %d\n", i);

printf("Grey2\n");
pZeDMD->SetDefaultPalette(2);
pZeDMD->RenderGray2(pImage2);
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
pZeDMD->ClearScreen();

printf("Grey4\n");
pZeDMD->SetDefaultPalette(4);
pZeDMD->RenderGray4(pImage4);
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
pZeDMD->ClearScreen();

printf("RGB24 Streming\n");
pZeDMD->RenderRgb24(pImage24);
std::this_thread::sleep_for(std::chrono::milliseconds(2000));

printf("RGB24 Streming\n");
pZeDMD->RenderRgb24(pImage24);
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
pZeDMD->ClearScreen();

printf("RGB24 Streming\n");
pZeDMD->RenderRgb24(pImage24);
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
pZeDMD->ClearScreen();
}

pZeDMD->DisableRGB24Streaming();

for (int i = 0; i < 3; i++) {
printf("Render loop: %d\n", i);

printf("Grey2\n");
Expand All @@ -67,27 +100,39 @@ int main(int argc, const char* argv[]) {
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
pZeDMD->ClearScreen();

printf("RGB24 as RGB565\n");
pZeDMD->RenderRgb24EncodedAs565(pImage24);
printf("RGB24 Streming\n");
pZeDMD->RenderRgb24(pImage24);
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
pZeDMD->ClearScreen();

}

pZeDMD->EnforceStreaming();

for (int i = 0; i < 20; i++) {
printf("Render loop: %d\n", i);
for (int i = 0; i < 3; i++) {
printf("Streaming render loop: %d\n", i);

printf("Grey2\n");
pZeDMD->SetDefaultPalette(2);
pZeDMD->RenderGray2(pImage2);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
pZeDMD->ClearScreen();

printf("Grey4\n");
pZeDMD->SetDefaultPalette(4);
pZeDMD->RenderGray4(pImage4);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
pZeDMD->ClearScreen();

printf("RGB24\n");
pZeDMD->RenderRgb24(pImage24);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
pZeDMD->ClearScreen();

printf("RGB24 as RGB565\n");
pZeDMD->RenderRgb24EncodedAs565(pImage24);
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
pZeDMD->ClearScreen();
}

free(pImage2);
Expand Down

0 comments on commit e34de88

Please sign in to comment.