mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-12-03 07:04:15 -05:00
Fix DDP implementation to comply with official specification
- Fix sequence number to use 4-bit nibble (0-15) instead of full byte per DDP spec - Fix data type encoding to use proper RGB 8-bit format (0x0B) per spec - Reduce maximum data size to 1440 bytes as recommended in official spec - Add DDP_TYPE_RGB8 constant for better code clarity - Improve compliance with http://www.3waylabs.com/ddp/ specification These changes should improve compatibility with strict DDP implementations and devices that follow the official protocol specification exactly.
This commit is contained in:
1 parent
2a9cce70e1
commit
a00563f945
2 files changed
+10
-5
No files matched your search
@@ -176,7 +176,7 @@ void DDPController::UpdateLEDs(const std::vector<unsigned int>& colors)
|
||||
device_data[pixel_offset + 2] = b;
|
||||
}
|
||||
|
||||
unsigned int max_data_per_packet = DDP_MAX_PACKET_SIZE - DDP_HEADER_SIZE;
|
||||
unsigned int max_data_per_packet = DDP_MAX_DATA_SIZE;
|
||||
unsigned int bytes_sent = 0;
|
||||
|
||||
while(bytes_sent < total_bytes)
|
||||
@@ -225,8 +225,8 @@ bool DDPController::SendDDPPacket(const DDPDevice& device, const unsigned char*
|
||||
|
||||
// CRITICAL FIX: Use 0x41 instead of 0x40 - WLED requires the Push bit to be set
|
||||
header->flags = DDP_FLAG_VER_1 | DDP_FLAG_PUSH;
|
||||
header->sequence = sequence_number;
|
||||
header->data_type = 1; // RGB data type
|
||||
header->sequence = sequence_number & 0x0F; // Only use 4-bit nibble (0-15) per DDP spec
|
||||
header->data_type = DDP_TYPE_RGB8; // RGB 8-bit per DDP spec
|
||||
header->dest_id = 1; // Default output device
|
||||
header->data_offset = htonl(offset);
|
||||
header->data_length = htons(length);
|
||||
@@ -294,7 +294,7 @@ void DDPController::KeepaliveThreadFunction()
|
||||
device_data[pixel_offset + 2] = b;
|
||||
}
|
||||
|
||||
unsigned int max_data_per_packet = DDP_MAX_PACKET_SIZE - DDP_HEADER_SIZE;
|
||||
unsigned int max_data_per_packet = DDP_MAX_DATA_SIZE;
|
||||
unsigned int bytes_sent = 0;
|
||||
|
||||
while(bytes_sent < total_bytes)
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
#define DDP_HEADER_SIZE 10
|
||||
#define DDP_HEADER_SIZE_TC 14
|
||||
#define DDP_VERSION 1
|
||||
#define DDP_MAX_PACKET_SIZE 1480
|
||||
#define DDP_MAX_PACKET_SIZE 1450
|
||||
#define DDP_MAX_DATA_SIZE 1440
|
||||
|
||||
#define DDP_FLAG_VER_MASK 0xC0
|
||||
#define DDP_FLAG_VER_1 0x40
|
||||
@@ -32,6 +33,10 @@
|
||||
#define DDP_FLAG_QUERY 0x02
|
||||
#define DDP_FLAG_PUSH 0x01
|
||||
|
||||
// DDP Data Type definitions (bits: C R TTT SSS)
|
||||
// C: 0=standard, 1=custom; R: reserved; TTT: data type; SSS: size
|
||||
#define DDP_TYPE_RGB8 0x0B // TTT=001 (RGB), SSS=011 (8-bit)
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct ddp_header
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user