Skip to content

Commit

Permalink
formatted code
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner committed Dec 29, 2023
1 parent 1c0ad4e commit 958fa99
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 36 deletions.
28 changes: 15 additions & 13 deletions src/ZeDMDComm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -437,7 +439,7 @@ bool ZeDMDComm::Connect(char *pDevice)

bool ZeDMDComm::IsConnected()
{
return m_serialPort.IsOpen();
return m_serialPort.IsOpen();
}

void ZeDMDComm::Reset()
Expand Down
10 changes: 5 additions & 5 deletions src/ZeDMDComm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...);
Expand Down
28 changes: 14 additions & 14 deletions src/ZeDMDWiFi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void ZeDMDWiFi::Disconnect()

bool ZeDMDWiFi::IsConnected()
{
return m_connected;
return m_connected;
}

void ZeDMDWiFi::Reset()
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/ZeDMDWiFi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit 958fa99

Please sign in to comment.