Skip to content

Commit

Permalink
Fixed ZeDMD HD support and added a test (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner authored Mar 15, 2024
1 parent 38d1c2f commit 188e3e7
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 17 deletions.
3 changes: 2 additions & 1 deletion include/DMDUtil/DMD.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class DMDUTILAPI DMD
Mode mode = Mode::Data; // int
uint16_t width = 0;
uint16_t height = 0;
uint8_t buffered = 0; // 0 => unbuffered, 1 => buffered
uint8_t buffered = 0; // 0 => unbuffered, 1 => buffered
uint8_t disconnectOthers = 0; // 0 => no, 1 => yes
uint32_t length = 0;
};
Expand All @@ -118,6 +118,7 @@ class DMDUTILAPI DMD
void FindDisplays();
static bool IsFinding();
bool HasDisplay() const;
bool HasHDDisplay() const;
void SetRomName(const char* name);
void SetAltColorPath(const char* path);
void DumpDMDTxt();
Expand Down
2 changes: 1 addition & 1 deletion platforms/android/arm64-v8a/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845
LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f

Expand Down
2 changes: 1 addition & 1 deletion platforms/ios/arm64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845
LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f

Expand Down
2 changes: 1 addition & 1 deletion platforms/linux/aarch64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845
LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f

Expand Down
2 changes: 1 addition & 1 deletion platforms/linux/x64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845
LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f

Expand Down
2 changes: 1 addition & 1 deletion platforms/macos/arm64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845
LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f

Expand Down
2 changes: 1 addition & 1 deletion platforms/macos/x64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845
LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f

Expand Down
2 changes: 1 addition & 1 deletion platforms/tvos/arm64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845
LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f

Expand Down
2 changes: 1 addition & 1 deletion platforms/win/x64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845
LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f

Expand Down
2 changes: 1 addition & 1 deletion platforms/win/x86/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845
LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f

Expand Down
14 changes: 10 additions & 4 deletions src/DMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ bool DMD::HasDisplay() const
#endif
}

bool DMD::HasHDDisplay() const { return (m_pZeDMD != nullptr && m_pZeDMD->GetWidth() == 256); }

void DMD::SetRomName(const char* name) { strcpy(m_romName, name ? name : ""); }

void DMD::SetAltColorPath(const char* path) { strcpy(m_altColorPath, path ? path : ""); }
Expand Down Expand Up @@ -436,12 +438,11 @@ void DMD::FindDisplays()
if (pZeDMD->Open())
{
if (pConfig->IsZeDMDDebug()) pZeDMD->EnableDebug();

if (pConfig->GetZeDMDRGBOrder() != -1) pZeDMD->SetRGBOrder(pConfig->GetZeDMDRGBOrder());

if (pConfig->GetZeDMDBrightness() != -1) pZeDMD->SetBrightness(pConfig->GetZeDMDBrightness());

if (pConfig->IsZeDMDSaveSettings()) pZeDMD->SaveSettings();
pZeDMD->EnablePreDownscaling();
pZeDMD->EnablePreUpscaling();

m_pZeDMDThread = new std::thread(&DMD::ZeDMDThread, this);
}
Expand All @@ -461,7 +462,8 @@ void DMD::FindDisplays()

if (pConfig->IsPixelcade())
{
pPixelcadeDMD = PixelcadeDMD::Connect(pConfig->GetPixelcadeDevice(), pConfig->GetPixelcadeMatrix(), 128, 32);
pPixelcadeDMD =
PixelcadeDMD::Connect(pConfig->GetPixelcadeDevice(), pConfig->GetPixelcadeMatrix(), 128, 32);
if (pPixelcadeDMD) m_pPixelcadeDMDThread = new std::thread(&DMD::PixelcadeDMDThread, this);
}

Expand Down Expand Up @@ -569,11 +571,15 @@ void DMD::ZeDMDThread()

AdjustRGB24Depth(m_pUpdateBufferQueue[bufferPosition]->data, rgb24Data, width * height, palette,
m_pUpdateBufferQueue[bufferPosition]->depth);
m_pZeDMD->DisablePreUpscaling();
m_pZeDMD->RenderRgb24(rgb24Data);
m_pZeDMD->EnablePreUpscaling();
}
else if (m_pUpdateBufferQueue[bufferPosition]->mode == Mode::RGB16)
{
m_pZeDMD->DisablePreUpscaling();
m_pZeDMD->RenderRgb565(m_pUpdateBufferQueue[bufferPosition]->segData);
m_pZeDMD->EnablePreUpscaling();
}
else
{
Expand Down
25 changes: 22 additions & 3 deletions src/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void run(DMDUtil::DMD* pDmd)
}

FILE* fileptr;
uint16_t size = width * height * 2;
uint16_t size = 256 * 64 * 2;
uint8_t* buffer = (uint8_t*)malloc(size * sizeof(uint8_t));
uint16_t* rgb565 = (uint16_t*)malloc(size / 2 * sizeof(uint16_t));
char filename[28];
Expand All @@ -168,8 +168,27 @@ void run(DMDUtil::DMD* pDmd)
fclose(fileptr);

memcpy(rgb565, buffer, size);
pDmd->UpdateRGB16Data(rgb565, 128, 32);
std::this_thread::sleep_for(std::chrono::milliseconds(80));
pDmd->UpdateRGB16Data(rgb565, width, height);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

if (pDmd->HasHDDisplay())
{
width = 256;
height = 64;
for (int i = 1; i <= 100; i++)
{
snprintf(filename, 28, "test/rgb565_%dx%d/%04d.raw", width, height, i);
printf("Render raw: %s\n", filename);
fileptr = fopen(filename, "rb");
if (!fileptr) continue;
fread(buffer, size, 1, fileptr);
fclose(fileptr);

memcpy(rgb565, buffer, size);
pDmd->UpdateRGB16Data(rgb565, width, height);
std::this_thread::sleep_for(std::chrono::milliseconds(240));
}
}

free(buffer);
Expand Down

0 comments on commit 188e3e7

Please sign in to comment.