Skip to content

Commit

Permalink
added missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner committed Feb 14, 2024
1 parent 367c832 commit 518db66
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 17 deletions.
46 changes: 46 additions & 0 deletions include/DMDUtil/LevelDMD.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once

#ifdef _MSC_VER
#define DMDUTILAPI __declspec(dllexport)
#define DMDUTILCALLBACK __stdcall
#else
#define DMDUTILAPI __attribute__((visibility("default")))
#define DMDUTILCALLBACK
#endif

#include <cstdint>

namespace DMDUtil
{

class DMDUTILAPI LevelDMD
{
public:
LevelDMD(uint16_t width, uint16_t height, bool sam);
~LevelDMD();

void Update(uint8_t* pLevelData, uint8_t depth);
int GetWidth() { return m_width; }
int GetHeight() { return m_height; }
int GetLength() const { return m_length; }
int GetPitch() const { return m_pitch; }
uint8_t* GetData();

private:
static constexpr uint8_t LEVELS_WPC[] = {0x14, 0x21, 0x43, 0x64};
static constexpr uint8_t LEVELS_GTS3[] = {0x00, 0x1E, 0x23, 0x28, 0x2D, 0x32, 0x37, 0x3C,
0x41, 0x46, 0x4B, 0x50, 0x55, 0x5A, 0x5F, 0x64};
static constexpr uint8_t LEVELS_SAM[] = {0x00, 0x14, 0x19, 0x1E, 0x23, 0x28, 0x2D, 0x32,
0x37, 0x3C, 0x41, 0x46, 0x4B, 0x50, 0x5A, 0x64};

uint16_t m_width;
uint16_t m_height;
int m_length;
int m_pitch;
int m_update;
bool m_sam;

uint8_t* m_pData;
};

} // namespace DMDUtil
39 changes: 39 additions & 0 deletions include/DMDUtil/RGB24DMD.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#ifdef _MSC_VER
#define DMDUTILAPI __declspec(dllexport)
#define DMDUTILCALLBACK __stdcall
#else
#define DMDUTILAPI __attribute__((visibility("default")))
#define DMDUTILCALLBACK
#endif

#include <cstdint>

namespace DMDUtil
{

class DMDUTILAPI RGB24DMD
{
public:
RGB24DMD(uint16_t width, uint16_t height);
~RGB24DMD();

void Update(uint8_t* pRGB24Data);
int GetWidth() { return m_width; }
int GetHeight() { return m_height; }
int GetLength() const { return m_length; }
int GetPitch() const { return m_pitch; }
uint8_t* GetData();

private:
uint16_t m_width;
uint16_t m_height;
int m_length;
int m_pitch;
int m_update;

uint8_t* m_pData;
};

} // namespace DMDUtil
29 changes: 12 additions & 17 deletions src/DMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,9 @@ void DMD::ZeDMDThread()
if (update)
{
if (m_updateBuffer[bufferPosition]->hasSegData2)
m_pAlphaNumeric->Render(renderBuffer, m_updateBuffer[bufferPosition]->layout, (const uint16_t*)segData1,
(const uint16_t*)segData2);
m_pAlphaNumeric->Render(renderBuffer, m_updateBuffer[bufferPosition]->layout, segData1, segData2);
else
m_pAlphaNumeric->Render(renderBuffer, m_updateBuffer[bufferPosition]->layout, (const uint16_t*)segData1);
m_pAlphaNumeric->Render(renderBuffer, m_updateBuffer[bufferPosition]->layout, segData1);

m_pZeDMD->SetPalette(palette, 4);
m_pZeDMD->RenderGray2(renderBuffer);
Expand Down Expand Up @@ -514,14 +513,14 @@ void DMD::PixelcadeDMDThread()

if (m_updateBuffer[bufferPosition]->mode == DMDMode::RGB24)
{
AdjustRGB24Depth((uint8_t*)m_updateBuffer[bufferPosition]->data, rgb24Data, length * 3, palette,
AdjustRGB24Depth(m_updateBuffer[bufferPosition]->data, rgb24Data, length * 3, palette,
m_updateBuffer[bufferPosition]->depth);
for (int i = 0; i < length; i++)
{
int pos = i * 3;
uint32_t r = ((uint8_t*)(m_updateBuffer[bufferPosition]->data))[pos];
uint32_t g = ((uint8_t*)(m_updateBuffer[bufferPosition]->data))[pos + 1];
uint32_t b = ((uint8_t*)(m_updateBuffer[bufferPosition]->data))[pos + 2];
uint32_t r = m_updateBuffer[bufferPosition]->data[pos];
uint32_t g = m_updateBuffer[bufferPosition]->data[pos + 1];
uint32_t b = m_updateBuffer[bufferPosition]->data[pos + 2];

rgb565Data[i] = (uint16_t)(((r & 0xF8u) << 8) | ((g & 0xFCu) << 3) | (b >> 3));
}
Expand Down Expand Up @@ -565,11 +564,9 @@ void DMD::PixelcadeDMDThread()
uint8_t* pData;

if (m_updateBuffer[bufferPosition]->hasSegData2)
m_pAlphaNumeric->Render(renderBuffer, m_updateBuffer[bufferPosition]->layout, (const uint16_t*)segData1,
(const uint16_t*)segData2);
m_pAlphaNumeric->Render(renderBuffer, m_updateBuffer[bufferPosition]->layout, segData1, segData2);
else
m_pAlphaNumeric->Render(renderBuffer, m_updateBuffer[bufferPosition]->layout,
(const uint16_t*)segData1);
m_pAlphaNumeric->Render(renderBuffer, m_updateBuffer[bufferPosition]->layout, segData1);
}
}

Expand Down Expand Up @@ -668,7 +665,7 @@ void DMD::RGB24DMDThread()
m_updateBuffer[bufferPosition]->g, m_updateBuffer[bufferPosition]->b);
}

AdjustRGB24Depth((uint8_t*)m_updateBuffer[bufferPosition]->data, rgb24Data, length * 3, palette,
AdjustRGB24Depth(m_updateBuffer[bufferPosition]->data, rgb24Data, length * 3, palette,
m_updateBuffer[bufferPosition]->depth);

for (RGB24DMD* pRGB24DMD : m_rgb24DMDs)
Expand All @@ -685,7 +682,7 @@ void DMD::RGB24DMDThread()
// attached.
if (m_updateBuffer[bufferPosition]->mode == DMDMode::Data && m_pSerum && !HasDisplay())
{
update = m_pSerum->Convert((uint8_t*)m_updateBuffer[bufferPosition]->data, renderBuffer, palette,
update = m_pSerum->Convert(m_updateBuffer[bufferPosition]->data, renderBuffer, palette,
m_updateBuffer[bufferPosition]->width, m_updateBuffer[bufferPosition]->height);
}
else
Expand Down Expand Up @@ -719,11 +716,9 @@ void DMD::RGB24DMDThread()
if (update)
{
if (m_updateBuffer[bufferPosition]->hasSegData2)
m_pAlphaNumeric->Render(renderBuffer, m_updateBuffer[bufferPosition]->layout,
(const uint16_t*)segData1, (const uint16_t*)segData2);
m_pAlphaNumeric->Render(renderBuffer, m_updateBuffer[bufferPosition]->layout, segData1, segData2);
else
m_pAlphaNumeric->Render(renderBuffer, m_updateBuffer[bufferPosition]->layout,
(const uint16_t*)segData1);
m_pAlphaNumeric->Render(renderBuffer, m_updateBuffer[bufferPosition]->layout, segData1);
}
}
}
Expand Down
56 changes: 56 additions & 0 deletions src/LevelDMD.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include "DMDUtil/LevelDMD.h"

#include <cstdint>
#include <cstring>
#include <string>

namespace DMDUtil
{

LevelDMD::LevelDMD(uint16_t width, uint16_t height, bool sam)
{
m_width = width;
m_height = height;
m_length = width * height;
m_pitch = width * 3;
m_sam = sam;

m_pData = (uint8_t*)malloc(m_length);
memset(m_pData, 0, m_length);

m_update = false;
}

LevelDMD::~LevelDMD() { free(m_pData); }

void LevelDMD::Update(uint8_t* pData, uint8_t depth)
{
memcpy(m_pData, pData, m_length);
if (depth == 2)
{
for (int i = 0; i < m_length; i++) m_pData[i] = LEVELS_WPC[pData[i]];
m_update = true;
}
else if (depth == 4)
{
if (m_sam)
{
for (int i = 0; i < m_length; i++) m_pData[i] = LEVELS_SAM[pData[i]];
}
else
{
for (int i = 0; i < m_length; i++) m_pData[i] = LEVELS_GTS3[pData[i]];
}
m_update = true;
}
}

uint8_t* LevelDMD::GetData()
{
if (!m_update) return nullptr;

m_update = false;
return m_pData;
}

} // namespace DMDUtil
40 changes: 40 additions & 0 deletions src/RGB24DMD.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "DMDUtil/RGB24DMD.h"

#include <cstdint>
#include <cstring>
#include <string>

namespace DMDUtil
{

RGB24DMD::RGB24DMD(uint16_t width, uint16_t height)
{
m_width = width;
m_height = height;
m_length = width * height * 3;
m_pitch = width * 3;

m_pData = (uint8_t*)malloc(m_length);
memset(m_pData, 0, m_length);

m_update = false;
}

RGB24DMD::~RGB24DMD() { free(m_pData); }

void RGB24DMD::Update(uint8_t* pData)
{
memcpy(m_pData, pData, m_length);

m_update = true;
}

uint8_t* RGB24DMD::GetData()
{
if (!m_update) return nullptr;

m_update = false;
return m_pData;
}

} // namespace DMDUtil

0 comments on commit 518db66

Please sign in to comment.