1616namespace DMDUtil
1717{
1818
19- PixelcadeDMD::PixelcadeDMD (struct sp_port * pSerialPort, int width, int height, bool colorSwap, bool isV2, bool isV23)
19+ PixelcadeDMD::PixelcadeDMD (struct sp_port * pSerialPort, int width, int height, bool colorSwap, bool isV2,
20+ int firmwareVersion)
2021{
2122 m_pSerialPort = pSerialPort;
2223 m_width = width;
2324 m_height = height;
2425 m_colorSwap = colorSwap;
2526 m_isV2 = isV2;
26- m_isV23 = isV23 ;
27+ m_firmwareVersion = firmwareVersion ;
2728 m_length = width * height;
2829 m_pThread = nullptr ;
2930 m_running = false ;
@@ -140,7 +141,7 @@ PixelcadeDMD* PixelcadeDMD::Open(const char* pDevice)
140141 int width = 128 ;
141142 int height = 32 ;
142143 bool isV2 = false ;
143- bool isV23 = false ;
144+ int firmwareVersion = 0 ;
144145 bool colorSwap = false ;
145146
146147 if (firmware[0 ] == ' P' && firmware[1 ] != 0 && firmware[2 ] != 0 && firmware[3 ] != 0 )
@@ -160,19 +161,18 @@ PixelcadeDMD* PixelcadeDMD::Open(const char* pDevice)
160161
161162 if (firmware[6 ] != 0 && firmware[7 ] != 0 )
162163 {
163- int version = (firmware[6 ] - ' 0' ) * 10 + (firmware[7 ] - ' 0' );
164- isV23 = (version >= 23 );
164+ firmwareVersion = (firmware[6 ] - ' 0' ) * 10 + (firmware[7 ] - ' 0' );
165165 }
166166
167167 colorSwap = (firmware[4 ] == ' C' ) && !isV2;
168168 }
169169
170170 Log (DMDUtil_LogLevel_INFO,
171- " Pixelcade found: device=%s, Hardware ID=%s, Bootloader ID=%s, Firmware=%s, Size=%dx%d, V2=%d, V23 =%d, "
171+ " Pixelcade found: device=%s, Hardware ID=%s, Bootloader ID=%s, Firmware=%s, Size=%dx%d, V2=%d, FW =%d, "
172172 " ColorSwap=%d" ,
173- pDevice, hardwareId, bootloaderId, firmware, width, height, isV2, isV23 , colorSwap);
173+ pDevice, hardwareId, bootloaderId, firmware, width, height, isV2, firmwareVersion , colorSwap);
174174
175- return new PixelcadeDMD (pSerialPort, width, height, colorSwap, isV2, isV23 );
175+ return new PixelcadeDMD (pSerialPort, width, height, colorSwap, isV2, firmwareVersion );
176176}
177177
178178void PixelcadeDMD::Update (uint16_t * pData)
@@ -247,11 +247,12 @@ void PixelcadeDMD::EnableRgbLedMatrix(int shifterLen32, int rows)
247247
248248 if (m_isV2)
249249 {
250- uint8_t command = m_isV23 ? PIXELCADE_COMMAND_RGB_LED_MATRIX_ENABLE_V23 : PIXELCADE_COMMAND_RGB_LED_MATRIX_ENABLE;
250+ uint8_t command =
251+ (m_firmwareVersion >= 23 ) ? PIXELCADE_COMMAND_RGB_LED_MATRIX_ENABLE_V23 : PIXELCADE_COMMAND_RGB_LED_MATRIX_ENABLE;
251252 uint8_t frame[8 ];
252253 int frameSize;
253254
254- if (m_isV23 )
255+ if (m_firmwareVersion >= 23 )
255256 {
256257 frameSize = BuildFrame (frame, sizeof (frame), command, &configData, 1 );
257258 }
@@ -280,7 +281,7 @@ void PixelcadeDMD::Run()
280281 {
281282 Log (DMDUtil_LogLevel_INFO, " PixelcadeDMD run thread starting" );
282283
283- if (m_isV23 )
284+ if (m_firmwareVersion >= 23 )
284285 {
285286 uint8_t initCmd = PIXELCADE_COMMAND_V23_INIT;
286287 sp_blocking_write (m_pSerialPort, &initCmd, 1 , 0 );
@@ -337,7 +338,7 @@ void PixelcadeDMD::Run()
337338 }
338339
339340 int frameSize;
340- if (m_isV23 )
341+ if (m_firmwareVersion >= 23 )
341342 {
342343 memcpy (pFrameData + 5 , frame.pData , payloadSize);
343344 frameSize = BuildFrame (pFrameData, maxFrameDataSize + 10 , command, pFrameData + 5 , payloadSize);
0 commit comments