Skip to content

Commit

Permalink
initialize black palette
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner committed Dec 7, 2023
1 parent 9cffcdb commit 4156443
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ZeDMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ bool ZeDMD::Open(int width, int height)

void ZeDMD::SetPalette(uint8_t *pPalette)
{
memcpy(&m_palette, pPalette, sizeof(m_palette));
memcpy(&m_palette, pPalette, (sizeof(pPalette) < ZEDMD_MAX_PALETTE) ? sizeof(pPalette) : ZEDMD_MAX_PALETTE);
}

void ZeDMD::SetDefaultPalette(int bitDepth)
Expand Down
3 changes: 2 additions & 1 deletion src/ZeDMD.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#define ZEDMD_MAX_WIDTH 256
#define ZEDMD_MAX_HEIGHT 64
#define ZEDMD_MAX_PALETTE 64 * 3

#if defined(_WIN32) || defined(_WIN64)
#define ZEDMDAPI __declspec(dllexport)
Expand Down Expand Up @@ -103,7 +104,7 @@ class ZEDMDAPI ZeDMD
uint8_t *m_pCommandBuffer;
uint8_t *m_pPlanes;

uint8_t m_palette[64 * 3];
uint8_t m_palette[ZEDMD_MAX_PALETTE] = {0};
uint8_t m_DmdDefaultPalette2Bit[12] = {0, 0, 0, 144, 34, 0, 192, 76, 0, 255, 127, 0};
uint8_t m_DmdDefaultPalette4Bit[48] = {0, 0, 0, 51, 25, 0, 64, 32, 0, 77, 38, 0,
89, 44, 0, 102, 51, 0, 115, 57, 0, 128, 64, 0,
Expand Down

0 comments on commit 4156443

Please sign in to comment.