Skip to content

Commit

Permalink
feature: Add new VirtualDMD class and replace RGB32 with RGB24 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsm174 authored Feb 1, 2024
1 parent 4877111 commit 63b9236
Show file tree
Hide file tree
Showing 10 changed files with 276 additions and 143 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/libdmdutil.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
- uses: actions/checkout@v4
- if: (matrix.platform == 'win')
name: Add msbuild to path (win runner)
uses: microsoft/setup-msbuild@v1.1
uses: microsoft/setup-msbuild@v2
- if: (matrix.platform == 'macos')
name: Add autoconf and automake (mac runner)
run: |
Expand Down Expand Up @@ -164,7 +164,7 @@ jobs:
fi
echo "artifact_path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: libdmdutil-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}
path: ${{ steps.artifacts.outputs.artifact_path }}
Expand All @@ -174,7 +174,7 @@ jobs:
needs: [ version, build ]
name: Build libdmdutil-macos
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
- name: Unpack artifacts
run: |
cd libdmdutil-${{ needs.version.outputs.tag }}-macos-x64
Expand Down Expand Up @@ -208,7 +208,7 @@ jobs:
cd tmp
tar -czvf ../libdmdutil-${{ needs.version.outputs.tag }}-macos.tar.gz *
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: libdmdutil-${{ needs.version.outputs.tag }}-macos
path: libdmdutil-${{ needs.version.outputs.tag }}-macos.tar.gz
Expand Down
126 changes: 68 additions & 58 deletions CMakeLists.txt

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,25 @@ void setup()
DMDUtil::Config* pConfig = DMDUtil::Config::GetInstance();
pConfig->SetZeDMD(true);
pConfig->SetZeDMDDevice("/dev/cu.usbserial-0001");
pConfig->SetPixelcade(false);
pConfig->SetPixelcadeDMD(false);
}
void test()
{
uint8_t* pData = (uint8_t*)malloc(128 * 32);
DMDUtil::DMD* pDmd = new DMDUtil::DMD(128, 32, false, "t2_l8");
DMDUtil::VirtualDMD* pVirtualDMD = pDmd->CreateVirtualDMD();
uint8_t* pData = (uint8_t*)malloc(128 * 32);
.
.
.
pDmd->UpdateData((const UINT8*)pData, 2, 255, 0, 0);
uint32_t* pRGB32Data = pDmd->GetRGB32Data();
uint8_t* pRGB24Data = pVirtualDMD->GetRGB24Data();
if (pRGB24Data) {
// Render pRGB24Data
}
}
```

Expand Down
18 changes: 8 additions & 10 deletions include/DMDUtil/DMD.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ enum class AlphaNumericLayout

class AlphaNumeric;
class Serum;
class Pixelcade;
class PixelcadeDMD;
class VirtualDMD;

class DMDUTILAPI DMD
{
Expand All @@ -59,14 +60,11 @@ class DMDUTILAPI DMD
int GetWidth() const { return m_width; }
int GetHeight() const { return m_height; }
int GetLength() const { return m_length; }
bool IsUpdated() const { return m_updated; }
void ResetUpdated() { m_updated = false; }
VirtualDMD* CreateVirtualDMD();
void UpdateData(const uint8_t* pData, int depth, uint8_t r, uint8_t g, uint8_t b);
void UpdateRGB24Data(const uint8_t* pData, int depth, uint8_t r, uint8_t g, uint8_t b);
void UpdateAlphaNumericData(AlphaNumericLayout layout, const uint16_t* pData1, const uint16_t* pData2, uint8_t r,
uint8_t g, uint8_t b);
const uint8_t* GetLevelData() const { return m_pLevelData; }
const uint32_t* GetRGB32Data() const { return m_pRGB32Data; }

private:
enum class DmdMode
Expand Down Expand Up @@ -107,12 +105,12 @@ class DMDUTILAPI DMD
int m_height;
int m_length;
bool m_sam;
uint8_t* m_pData;
uint8_t* m_pRGB24Data;
uint8_t* m_pBuffer;
uint8_t* m_pRGB24Buffer;
uint16_t m_segData1[128];
uint16_t m_segData2[128];
uint8_t* m_pLevelData;
uint32_t* m_pRGB32Data;
uint8_t* m_pRGB24Data;
uint16_t* m_pRGB565Data;
uint8_t m_palette[192];
AlphaNumeric* m_pAlphaNumeric;
Expand All @@ -121,9 +119,9 @@ class DMDUTILAPI DMD
#if !( \
(defined(__APPLE__) && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_TV) && TARGET_OS_TV))) || \
defined(__ANDROID__))
Pixelcade* m_pPixelcade;
PixelcadeDMD* m_pPixelcadeDMD;
#endif
bool m_updated;
std::vector<VirtualDMD*> m_virtualDMDs;

std::thread* m_pThread;
std::queue<DMDUpdate*> m_updates;
Expand Down
5 changes: 3 additions & 2 deletions include/DMDUtil/DMDUtil.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#define DMDUTIL_VERSION_MAJOR 0 // X Digits
#define DMDUTIL_VERSION_MINOR 1 // Max 2 Digits
#define DMDUTIL_VERSION_MINOR 2 // Max 2 Digits
#define DMDUTIL_VERSION_PATCH 0 // Max 2 Digits

#define _DMDUTIL_STR(x) #x
Expand All @@ -12,4 +12,5 @@
#define DMDUTIL_MINOR_VERSION DMDUTIL_STR(DMDUTIL_VERSION_MAJOR) "." DMDUTIL_STR(DMDUTIL_VERSION_MINOR)

#include "Config.h"
#include "DMD.h"
#include "DMD.h"
#include "VirtualDMD.h"
41 changes: 41 additions & 0 deletions include/DMDUtil/VirtualDMD.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#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 VirtualDMD
{
public:
VirtualDMD(int width, int height);
~VirtualDMD();

void Update(uint8_t* pLevelData, 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* GetLevelData();
uint8_t* GetRGB24Data();

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

uint8_t* m_pLevelData;
uint8_t* m_pRGB24Data;
};

} // namespace DMDUtil
Loading

0 comments on commit 63b9236

Please sign in to comment.