Skip to content

Commit 18aa3d3

Browse files
Fix serial port issues on Linux and add proper Direct mode to NZXT Hue+
1 parent e7dc953 commit 18aa3d3

4 files changed

Lines changed: 7 additions & 4 deletions

File tree

Controllers/NZXTHuePlusController/NZXTHuePlusController.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void HuePlusController::SetChannelLEDs
169169
/*-----------------------------------------------------*\
170170
| Send color data |
171171
\*-----------------------------------------------------*/
172-
SendPacket(channel, HUE_PLUS_MODE_FIXED, false, 0, 0, num_colors, &color_data[0]);
172+
SendPacket(channel, HUE_PLUS_MODE_DIRECT, false, 0, 0, num_colors, &color_data[0]);
173173
}
174174

175175
/*-------------------------------------------------------------------------------------------------*\
@@ -187,7 +187,7 @@ void HuePlusController::SendPacket
187187
unsigned char* color_data
188188
)
189189
{
190-
unsigned char serial_buf[125];
190+
unsigned char serial_buf[HUE_PLUS_PACKET_SIZE];
191191

192192
/*-----------------------------------------------------*\
193193
| Zero out buffer |
@@ -233,5 +233,5 @@ void HuePlusController::SendPacket
233233
/*-----------------------------------------------------*\
234234
| Delay to allow Hue+ device to ready for next packet |
235235
\*-----------------------------------------------------*/
236-
std::this_thread::sleep_for(20ms);
236+
std::this_thread::sleep_for(5ms);
237237
}

Controllers/NZXTHuePlusController/NZXTHuePlusController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ enum
6262
HUE_PLUS_MODE_CANDLELIGHT = 0x09, /* Candlelight mode */
6363
HUE_PLUS_MODE_WINGS = 0x0C, /* Wings mode */
6464
HUE_PLUS_MODE_WAVE = 0x0D, /* Wave mode */
65+
HUE_PLUS_MODE_DIRECT = 0x0E, /* Direct mode */
6566
};
6667

6768
class HuePlusController

Controllers/NZXTHuePlusController/RGBController_NZXTHuePlus.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RGBController_HuePlus::RGBController_HuePlus(HuePlusController* hueplus_ptr)
2121

2222
mode Direct;
2323
Direct.name = "Direct";
24-
Direct.value = HUE_PLUS_MODE_FIXED;
24+
Direct.value = HUE_PLUS_MODE_DIRECT;
2525
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
2626
Direct.color_mode = MODE_COLORS_PER_LED;
2727
modes.push_back(Direct);

serial_port/serial_port.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ int serial_port::serial_write(char * buffer, int length)
202202
#ifdef __linux__
203203

204204
int byteswritten;
205+
tcdrain(file_descriptor);
205206
byteswritten = write(file_descriptor, buffer, length);
207+
tcdrain(file_descriptor);
206208
return byteswritten;
207209

208210
#endif /* __linux__ */

0 commit comments

Comments
 (0)