4#include <TargetConditionals.h>
8 (defined(__APPLE__) && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_TV) && TARGET_OS_TV))) || \
10#include "libserialport.h"
23#define ZEDMDCALLBACK __stdcall
34 EnableCompression = 0x0e,
35 DisableCompression = 0x0f,
37 EnableUpscaling = 0x15,
38 DisableUpscaling = 0x14,
43 EnableFlowControlV2 = 0x1a,
45 SetWiFiPassword = 0x1c,
49 GetVersionBytes = 0x20,
53 RGB24ZonesStream = 0x04,
54 RGB565ZonesStream = 0x05,
72#define ZEDMD_COMM_BAUD_RATE 921600
73#define ZEDMD_S3_COMM_BAUD_RATE 921600 * 8
75#if defined(_WIN32) || defined(_WIN64)
76#define ZEDMD_COMM_MAX_SERIAL_WRITE_AT_ONCE 1888
77#define ZEDMD_COMM_SERIAL_READ_TIMEOUT 16
78#define ZEDMD_COMM_SERIAL_WRITE_TIMEOUT 16
80#define ZEDMD_COMM_MAX_SERIAL_WRITE_AT_ONCE 1888
81#define ZEDMD_COMM_SERIAL_READ_TIMEOUT 32
82#define ZEDMD_COMM_SERIAL_WRITE_TIMEOUT 16
85#define ZEDMD_COMM_FRAME_SIZE_COMMAND_LIMIT 10
86#define ZEDMD_COMM_FRAME_QUEUE_SIZE_MAX 8
87#define ZEDMD_COMM_FRAME_QUEUE_SIZE_MAX_DELAYED 2
89typedef void(ZEDMDCALLBACK* ZeDMD_LogCallback)(
const char* format, va_list args,
const void* userData);
94 static const int CTRL_CHARS_HEADER_SIZE = 6;
95 static constexpr uint8_t CTRL_CHARS_HEADER[] = {0x5a, 0x65, 0x64, 0x72, 0x75, 0x6d};
101 void SetLogCallback(ZeDMD_LogCallback callback,
const void* userData);
103 void IgnoreDevice(
const char* ignore_device);
104 void SetDevice(
const char* device);
106 virtual bool Connect();
107 virtual void Disconnect();
108 virtual bool IsConnected();
111 void QueueCommand(
char command, uint8_t* buffer,
int size, uint16_t width, uint16_t height, uint8_t bytes = 3);
112 void QueueCommand(
char command, uint8_t* buffer,
int size, int8_t streamId = -1,
bool delayed =
false);
113 void QueueCommand(
char command);
114 void QueueCommand(
char command, uint8_t value);
117 uint16_t
const GetWidth();
118 uint16_t
const GetHeight();
123 virtual void Reset();
125 uint16_t m_zonesBytesLimit = 0;
126 uint8_t m_zoneWidth = 8;
127 uint8_t m_zoneHeight = 4;
130 void Log(
const char* format, ...);
132 bool Connect(
char* pName);
134 ZeDMD_LogCallback m_logCallback =
nullptr;
135 const void* m_logUserData =
nullptr;
136 uint64_t m_zoneHashes[128] = {0};
137 uint16_t m_width = 128;
138 uint16_t m_height = 32;
139 int8_t m_streamId = -1;
140 int8_t m_lastStreamId = -1;
141 uint8_t m_flowControlCounter = 0;
142 char m_ignoredDevices[10][32] = {0};
143 uint8_t m_ignoredDevicesCounter = 0;
144 char m_device[32] = {0};
146 (defined(__APPLE__) && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_TV) && TARGET_OS_TV))) || \
147 defined(__ANDROID__))
148 struct sp_port* m_pSerialPort;
149 struct sp_port_config* m_pSerialPortConfig;
151 std::queue<ZeDMDFrame> m_frames;
152 std::thread* m_pThread;
153 std::mutex m_frameQueueMutex;
154 uint8_t m_frameCounter = 0;
155 std::queue<ZeDMDFrame> m_delayedFrames;
156 std::mutex m_delayedFrameMutex;
157 bool m_delayedFrameReady =
false;
Definition: ZeDMDComm.h:92
Definition: ZeDMDComm.h:65