diff --git a/README.md b/README.md index 873b899..f58c4d8 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,8 @@ SaveSettings= Enabled= # Disable auto-detection and provide a fixed serial port Device= +# Set to 0 if rgb, 1 if rbg +Matrix=0 ``` ## Building: diff --git a/include/DMDUtil/Config.h b/include/DMDUtil/Config.h index 4ed5564..848f52b 100644 --- a/include/DMDUtil/Config.h +++ b/include/DMDUtil/Config.h @@ -44,6 +44,8 @@ class DMDUTILAPI Config void SetPixelcade(bool pixelcade) { m_pixelcade = pixelcade; } void SetPixelcadeDevice(const char* port) { m_pixelcadeDevice = port; } const char* GetPixelcadeDevice() const { return m_pixelcadeDevice.c_str(); } + int GetPixelcadeMatrix() const { return m_pixelcadeMatrix; } + void SetPixelcadeMatrix(int matrix) { m_pixelcadeMatrix = matrix; } void SetDMDServer(bool dmdServer) { m_dmdServer = dmdServer; } bool IsDmdServer() { return m_dmdServer; } void SetDMDServerAddr(const char* addr) { m_dmdServerAddr = addr; } @@ -73,6 +75,7 @@ class DMDUTILAPI Config int m_dmdServerPort; bool m_pixelcade; std::string m_pixelcadeDevice; + int m_pixelcadeMatrix; DMDUtil_LogCallback m_logCallback; }; diff --git a/src/Config.cpp b/src/Config.cpp index 0d5ab15..d48d34c 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -26,6 +26,7 @@ Config::Config() m_zedmdSaveSettings = false; m_pixelcade = true; m_pixelcadeDevice.clear(); + m_pixelcadeMatrix = 0; m_dmdServer = false; m_dmdServerAddr = "localhost"; m_dmdServerPort = 6789; diff --git a/src/DMD.cpp b/src/DMD.cpp index ac07540..da5bf92 100644 --- a/src/DMD.cpp +++ b/src/DMD.cpp @@ -461,7 +461,7 @@ void DMD::FindDisplays() if (pConfig->IsPixelcade()) { - pPixelcadeDMD = PixelcadeDMD::Connect(pConfig->GetPixelcadeDevice(), 128, 32); + pPixelcadeDMD = PixelcadeDMD::Connect(pConfig->GetPixelcadeDevice(), pConfig->GetPixelcadeMatrix(), 128, 32); if (pPixelcadeDMD) m_pPixelcadeDMDThread = new std::thread(&DMD::PixelcadeDMDThread, this); } diff --git a/src/PixelcadeDMD.cpp b/src/PixelcadeDMD.cpp index 9dc634b..6be07e0 100644 --- a/src/PixelcadeDMD.cpp +++ b/src/PixelcadeDMD.cpp @@ -16,11 +16,12 @@ namespace DMDUtil { -PixelcadeDMD::PixelcadeDMD(struct sp_port* pSerialPort, int width, int height) +PixelcadeDMD::PixelcadeDMD(struct sp_port* pSerialPort, int matrix, int width, int height) { m_pSerialPort = pSerialPort; m_width = width; m_height = height; + m_matrix = matrix; m_length = width * height; m_pThread = nullptr; m_running = false; @@ -46,7 +47,7 @@ PixelcadeDMD::~PixelcadeDMD() } } -PixelcadeDMD* PixelcadeDMD::Connect(const char* pDevice, int width, int height) +PixelcadeDMD* PixelcadeDMD::Connect(const char* pDevice, int matrix, int width, int height) { PixelcadeDMD* pPixelcadeDMD = nullptr; @@ -54,7 +55,7 @@ PixelcadeDMD* PixelcadeDMD::Connect(const char* pDevice, int width, int height) { Log("Connecting to Pixelcade on %s...", pDevice); - pPixelcadeDMD = Open(pDevice, width, height); + pPixelcadeDMD = Open(pDevice, matrix, width, height); if (!pPixelcadeDMD) Log("Unable to connect to Pixelcade on %s", pDevice); } @@ -68,7 +69,7 @@ PixelcadeDMD* PixelcadeDMD::Connect(const char* pDevice, int width, int height) { for (int i = 0; ppPorts[i]; i++) { - pPixelcadeDMD = Open(sp_get_port_name(ppPorts[i]), width, height); + pPixelcadeDMD = Open(sp_get_port_name(ppPorts[i]), matrix, width, height); if (pPixelcadeDMD) break; } sp_free_port_list(ppPorts); @@ -80,7 +81,7 @@ PixelcadeDMD* PixelcadeDMD::Connect(const char* pDevice, int width, int height) return pPixelcadeDMD; } -PixelcadeDMD* PixelcadeDMD::Open(const char* pDevice, int width, int height) +PixelcadeDMD* PixelcadeDMD::Open(const char* pDevice, int matrix, int width, int height) { struct sp_port* pSerialPort = nullptr; enum sp_return result = sp_get_port_by_name(pDevice, &pSerialPort); @@ -140,7 +141,7 @@ PixelcadeDMD* PixelcadeDMD::Open(const char* pDevice, int width, int height) Log("Pixelcade found: device=%s, Hardware ID=%s, Bootloader ID=%s, Firmware=%s", pDevice, hardwareId, bootloaderId, firmware); - return new PixelcadeDMD(pSerialPort, width, height); + return new PixelcadeDMD(pSerialPort, matrix, width, height); } void PixelcadeDMD::Update(uint16_t* pData) @@ -174,6 +175,7 @@ void PixelcadeDMD::Run() EnableRgbLedMatrix(4, 16); int errors = 0; + ColorMatrix colorMatrix = (m_matrix == 0) ? ColorMatrix::Rgb : ColorMatrix::Rbg; while (m_running) { @@ -198,12 +200,12 @@ void PixelcadeDMD::Run() { uint8_t planes[128 * 32 * 3 / 2]; if (m_width == 128 && m_height == 32) - FrameUtil::SplitIntoRgbPlanes(pFrame, 128 * 32, 128, 16, (uint8_t*)planes); + FrameUtil::SplitIntoRgbPlanes(pFrame, 128 * 32, 128, 16, (uint8_t*)planes, colorMatrix); else { uint16_t scaledFrame[128 * 32]; FrameUtil::ResizeRgb565Bilinear(pFrame, m_width, m_height, scaledFrame, 128, 32); - FrameUtil::SplitIntoRgbPlanes(scaledFrame, 128 * 32, 128, 16, (uint8_t*)planes); + FrameUtil::SplitIntoRgbPlanes(scaledFrame, 128 * 32, 128, 16, (uint8_t*)planes, colorMatrix); } static uint8_t command = PIXELCADE_COMMAND_RGB_LED_MATRIX_FRAME; diff --git a/src/PixelcadeDMD.h b/src/PixelcadeDMD.h index f78e817..3bd873e 100644 --- a/src/PixelcadeDMD.h +++ b/src/PixelcadeDMD.h @@ -27,18 +27,19 @@ namespace DMDUtil class PixelcadeDMD { public: - PixelcadeDMD(struct sp_port* pSerialPort, int width, int height); + PixelcadeDMD(struct sp_port* pSerialPort, int matrix, int width, int height); ~PixelcadeDMD(); - static PixelcadeDMD* Connect(const char* pDevice, int width, int height); + static PixelcadeDMD* Connect(const char* pDevice, int matrix, int width, int height); void Update(uint16_t* pData); private: - static PixelcadeDMD* Open(const char* pDevice, int width, int height); + static PixelcadeDMD* Open(const char* pDevice, int matrix, int width, int height); void Run(); void EnableRgbLedMatrix(int shifterLen32, int rows); struct sp_port* m_pSerialPort; + int m_matrix; int m_width; int m_height; int m_length; diff --git a/src/dmdServer.cpp b/src/dmdServer.cpp index 414e1f4..b96b9c3 100644 --- a/src/dmdServer.cpp +++ b/src/dmdServer.cpp @@ -226,6 +226,7 @@ int main(int argc, char* argv[]) // Pixelcade pConfig->SetPixelcade(r.Get("Pixelcade", "Enabled")); pConfig->SetPixelcadeDevice(r.Get("Pixelcade", "Device").c_str()); + pConfig->SetPixelcadeMatrix(r.Get("Pixelcade", "Matrix")); } else if (identifier == 'o') {