Skip to content

Commit

Permalink
added functions to control libserum's features for incomplete coloriz…
Browse files Browse the repository at this point in the history
…ations (vpinball#13)

set configs for WIP Serum projects after Serum load
  • Loading branch information
mkalkbrenner authored Feb 23, 2024
1 parent 531516f commit c2ea18b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
6 changes: 6 additions & 0 deletions include/DMDUtil/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class DMDUTILAPI Config
bool IsAltColor() const { return m_altColor; }
void SetAltColor(bool altColor) { m_altColor = altColor; }
void SetAltColorPath(const char* path) { m_altColorPath = path; }
void SetIgnoreUnknownFramesTimeout(int framesTimeout) { m_framesTimeout = framesTimeout; }
void SetMaximumUnknownFramesToSkip(int framesToSkip) { m_framesToSkip = framesToSkip; }
int GetIgnoreUnknownFramesTimeout() { return m_framesTimeout; }
int GetMaximumUnknownFramesToSkip() { return m_framesToSkip; }
bool IsZeDMD() const { return m_zedmd; }
void SetZeDMD(bool zedmd) { m_zedmd = zedmd; }
const char* GetZeDMDDevice() const { return m_zedmdDevice.c_str(); }
Expand Down Expand Up @@ -50,6 +54,8 @@ class DMDUTILAPI Config
static Config* m_pInstance;
bool m_altColor;
std::string m_altColorPath;
int m_framesTimeout;
int m_framesToSkip;
bool m_zedmd;
std::string m_zedmdDevice;
bool m_zedmdDebug;
Expand Down
2 changes: 2 additions & 0 deletions src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Config::Config()
{
m_altColor = true;
m_altColorPath.clear();
m_framesTimeout = 0;
m_framesToSkip = 0;
m_zedmd = true;
m_zedmdDevice.clear();
m_zedmdDebug = false;
Expand Down
9 changes: 7 additions & 2 deletions src/DMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@ void DMD::DmdFrameReadyResetThread()
strcpy(name, m_updateBuffer[m_updateBufferPosition]->name);

m_pSerum = (Config::GetInstance()->IsAltColor() && name[0] != '\0') ? Serum::Load(name) : nullptr;
if (m_pSerum)
{
m_pSerum->SetIgnoreUnknownFramesTimeout((uint8_t)Config::GetInstance()->GetIgnoreUnknownFramesTimeout());
m_pSerum->SetMaximumUnknownFramesToSkip((uint8_t)Config::GetInstance()->GetMaximumUnknownFramesToSkip());
}
}

std::this_thread::sleep_for(std::chrono::milliseconds(1));
Expand Down Expand Up @@ -648,7 +653,7 @@ void DMD::PixelcadeDMDThread()
for (int i = 0; i < length; i++)
{
int pos = i * 3;
uint32_t r = rgb24Data[pos ];
uint32_t r = rgb24Data[pos];
uint32_t g = rgb24Data[pos + 1];
uint32_t b = rgb24Data[pos + 2];

Expand Down Expand Up @@ -960,7 +965,7 @@ void DMD::AdjustRGB24Depth(uint8_t* pData, uint8_t* pDstData, int length, uint8_
level = (uint8_t)(v >> 4);

int pos2 = level * 3;
pDstData[pos ] = palette[pos2];
pDstData[pos] = palette[pos2];
pDstData[pos + 1] = palette[pos2 + 1];
pDstData[pos + 2] = palette[pos2 + 2];
}
Expand Down
8 changes: 8 additions & 0 deletions src/Serum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,12 @@ bool Serum::ColorizeWithMetadata(uint8_t* frame, int width, int height, uint8_t*
return Serum_ColorizeWithMetadata(frame, width, height, palette, rotations, triggerID, hashcode, frameID);
}

void Serum::SetIgnoreUnknownFramesTimeout(uint8_t milliseconds){
return Serum_SetIgnoreUnknownFramesTimeout(milliseconds);
}

void Serum::SetMaximumUnknownFramesToSkip(uint8_t maximum){
return Serum_SetMaximumUnknownFramesToSkip(maximum);
}

} // namespace DMDUtil
2 changes: 2 additions & 0 deletions src/Serum.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Serum
void SetStandardPalette(const uint8_t* palette, const int bitDepth);
bool ColorizeWithMetadata(uint8_t* frame, int width, int height, uint8_t* palette, uint8_t* rotations,
uint32_t* triggerID, uint32_t* hashcode, int* frameID);
void SetIgnoreUnknownFramesTimeout(uint8_t milliseconds);
void SetMaximumUnknownFramesToSkip(uint8_t maximum);

private:
Serum(int width, int height);
Expand Down

0 comments on commit c2ea18b

Please sign in to comment.