diff --git a/src/ZeDMDComm.cpp b/src/ZeDMDComm.cpp index 1a3962c..f7126a9 100644 --- a/src/ZeDMDComm.cpp +++ b/src/ZeDMDComm.cpp @@ -197,19 +197,21 @@ void ZeDMDComm::QueueCommand(char command) void ZeDMDComm::QueueCommand(char command, uint8_t *data, int size, uint16_t width, uint16_t height) { - uint8_t buffer[256 * 16 * 3 + 16]; + uint8_t buffer[256 * 16 * 3 + 16]; uint16_t bufferSize = 0; uint8_t idx = 0; - uint8_t zone[16 * 8 * 3] = { 0 }; + uint8_t zone[16 * 8 * 3] = {0}; uint16_t zonesBytesLimit = 0; - if (m_zonesBytesLimit) { - while (zonesBytesLimit < m_zonesBytesLimit) - { - zonesBytesLimit += m_zoneWidth * m_zoneHeight * 3 + 1; - } + if (m_zonesBytesLimit) + { + while (zonesBytesLimit < m_zonesBytesLimit) + { + zonesBytesLimit += m_zoneWidth * m_zoneHeight * 3 + 1; + } } - else { - zonesBytesLimit = width * m_zoneHeight * 3 + 16; + else + { + zonesBytesLimit = width * m_zoneHeight * 3 + 16; } if (++m_streamId > 64) @@ -233,9 +235,9 @@ void ZeDMDComm::QueueCommand(char command, uint8_t *data, int size, uint16_t wid } for (uint16_t y = 0; y < height; y += m_zoneHeight) - { - for (uint16_t x = 0; x < width; x += m_zoneWidth) - { + { + for (uint16_t x = 0; x < width; x += m_zoneWidth) + { for (uint8_t z = 0; z < m_zoneHeight; z++) { memcpy(&zone[z * m_zoneWidth * 3], &data[((y + z) * width + x) * 3], m_zoneWidth * 3); @@ -437,7 +439,7 @@ bool ZeDMDComm::Connect(char *pDevice) bool ZeDMDComm::IsConnected() { - return m_serialPort.IsOpen(); + return m_serialPort.IsOpen(); } void ZeDMDComm::Reset() diff --git a/src/ZeDMDComm.h b/src/ZeDMDComm.h index ad1eed6..6681bac 100644 --- a/src/ZeDMDComm.h +++ b/src/ZeDMDComm.h @@ -118,12 +118,12 @@ class ZeDMDComm uint16_t GetHeight(); protected: - virtual bool StreamBytes(ZeDMDFrame* pFrame); - virtual void Reset(); + virtual bool StreamBytes(ZeDMDFrame *pFrame); + virtual void Reset(); - uint16_t m_zonesBytesLimit = 0; - uint8_t m_zoneWidth = 8; - uint8_t m_zoneHeight = 4; + uint16_t m_zonesBytesLimit = 0; + uint8_t m_zoneWidth = 8; + uint8_t m_zoneHeight = 4; private: void LogMessage(const char *format, ...); diff --git a/src/ZeDMDWiFi.cpp b/src/ZeDMDWiFi.cpp index dd29894..c8afeed 100644 --- a/src/ZeDMDWiFi.cpp +++ b/src/ZeDMDWiFi.cpp @@ -36,7 +36,7 @@ void ZeDMDWiFi::Disconnect() bool ZeDMDWiFi::IsConnected() { - return m_connected; + return m_connected; } void ZeDMDWiFi::Reset() @@ -76,24 +76,24 @@ bool ZeDMDWiFi::StreamBytes(ZeDMDFrame *pFrame) } else { - uint8_t data[ZEDMD_WIFI_ZONES_BYTES_LIMIT] = { 0 }; - data[0] = pFrame->command; // command - data[1] = (uint8_t)(128 | (pFrame->size / (m_zoneWidth * m_zoneHeight * 3 + 1))); // compressed + zone index + uint8_t data[ZEDMD_WIFI_ZONES_BYTES_LIMIT] = {0}; + data[0] = pFrame->command; // command + data[1] = (uint8_t)(128 | (pFrame->size / (m_zoneWidth * m_zoneHeight * 3 + 1))); // compressed + zone index - mz_ulong compressedSize = pFrame->size; - int status = mz_compress(&data[4], &compressedSize, pFrame->data, pFrame->size); - data[2] = (uint8_t)(compressedSize >> 8 & 0xFF); - data[3] = (uint8_t)(compressedSize & 0xFF); + mz_ulong compressedSize = pFrame->size; + int status = mz_compress(&data[4], &compressedSize, pFrame->data, pFrame->size); + data[2] = (uint8_t)(compressedSize >> 8 & 0xFF); + data[3] = (uint8_t)(compressedSize & 0xFF); - if (status == MZ_OK) - { + if (status == MZ_OK) + { #if defined(_WIN32) || defined(_WIN64) - sendto(m_wifiSocket, (const char*)data, compressedSize + 4, 0, (struct sockaddr*)&m_wifiServer, sizeof(m_wifiServer)); + sendto(m_wifiSocket, (const char *)data, compressedSize + 4, 0, (struct sockaddr *)&m_wifiServer, sizeof(m_wifiServer)); #else - sendto(m_wifiSocket, data, compressedSize + 4, 0, (struct sockaddr*)&m_wifiServer, sizeof(m_wifiServer)); + sendto(m_wifiSocket, data, compressedSize + 4, 0, (struct sockaddr *)&m_wifiServer, sizeof(m_wifiServer)); #endif - return true; - } + return true; + } } return false; diff --git a/src/ZeDMDWiFi.h b/src/ZeDMDWiFi.h index 519986a..c8068fd 100644 --- a/src/ZeDMDWiFi.h +++ b/src/ZeDMDWiFi.h @@ -26,11 +26,11 @@ class ZeDMDWiFi : public ZeDMDComm virtual bool IsConnected(); protected: - virtual bool StreamBytes(ZeDMDFrame* pFrame); + virtual bool StreamBytes(ZeDMDFrame *pFrame); virtual void Reset(); private: - int m_wifiSocket; - struct sockaddr_in m_wifiServer; - bool m_connected = false; + int m_wifiSocket; + struct sockaddr_in m_wifiServer; + bool m_connected = false; }; \ No newline at end of file