Skip to content

Commit f93baff

Browse files
773534601CalcProgrammer1
authored andcommitted
Correcting DRGBcontroller error, ensuring correct compilation and running on Windows
1 parent 6928c50 commit f93baff

File tree

3 files changed

+56
-44
lines changed

3 files changed

+56
-44
lines changed

Controllers/DRGBController/DRGBController.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ unsigned short DRGBController::GetDevicePID()
4444
return(device_pid);
4545
}
4646

47+
void DRGBController::SetChannelLEDs(unsigned char channel, RGBColor* colors, unsigned int num_colors)
48+
{
49+
50+
}
51+
4752
void DRGBController::SendPacket(unsigned char* colors, unsigned int buf_packets , unsigned int Array)
4853
{
4954
unsigned char usb_buf[1025];

Controllers/DRGBController/DRGBController.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class DRGBController
2020
{
2121
public:
2222
DRGBController(hid_device* dev_handle, const char* path, unsigned short pid);
23-
~DRGBController();
2423
std::string GetLocationString();
2524
std::string GetSerialString();
2625
unsigned short GetDevicePID();
@@ -29,6 +28,6 @@ class DRGBController
2928
void SendPacketFS(unsigned char* colors,unsigned int buf_packets ,bool Array);
3029
private:
3130
hid_device* dev;
32-
unsigned short device_pid;
3331
std::string location;
32+
unsigned short device_pid;
3433
};

Controllers/DRGBController/RGBController_DRGB.cpp

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -68,62 +68,66 @@ void RGBController_DRGB::SetupZones()
6868
switch(controller->GetDevicePID())
6969
{
7070
case DRGB_LED_V4_PID:
71-
NUM_CHANNELS = 8;
72-
NUM_Channel_led = 256;
71+
NUM_CHANNELS = 8;
72+
NUM_Channel_led = 256;
73+
Version = 4;
7374
break;
7475
case DRGB_ULTRA_V4F_PID:
75-
NUM_CHANNELS = 16;
76-
NUM_Channel_led = 256;
76+
NUM_CHANNELS = 16;
77+
NUM_Channel_led = 256;
78+
Version = 4;
7779
break;
7880
case DRGB_CORE_V4F_PID:
79-
NUM_CHANNELS = 32;
80-
NUM_Channel_led = 256;
81+
NUM_CHANNELS = 32;
82+
NUM_Channel_led = 256;
83+
Version = 4;
8184
break;
8285
case DRGB_SIG_V4F_PID:
83-
NUM_CHANNELS = 36;
84-
NUM_Channel_led = 256;
86+
NUM_CHANNELS = 36;
87+
NUM_Channel_led = 256;
88+
Version = 4;
8589
break;
8690

8791
case DRGB_LED_V3_PID:
88-
NUM_CHANNELS = 8;
89-
NUM_Channel_led = 256;
90-
Version = 3;
92+
NUM_CHANNELS = 8;
93+
NUM_Channel_led = 256;
94+
Version = 3;
9195
break;
9296
case DRGB_Ultra_V3_PID:
93-
NUM_CHANNELS = 16;
94-
NUM_Channel_led = 256;
95-
Version = 3;
97+
NUM_CHANNELS = 16;
98+
NUM_Channel_led = 256;
99+
Version = 3;
96100
break;
97101
case DRGB_CORE_V3_PID:
98-
NUM_CHANNELS = 30;
99-
NUM_Channel_led = 256;
100-
Version = 3;
102+
NUM_CHANNELS = 30;
103+
NUM_Channel_led = 256;
104+
Version = 3;
101105
break;
102106

103107
case DRGB_LED_PID:
104-
NUM_CHANNELS = 8;
105-
NUM_Channel_led = 256;
106-
Version = 2;
108+
NUM_CHANNELS = 8;
109+
NUM_Channel_led = 256;
110+
Version = 2;
107111
break;
108112
case DRGB_ULTRA_PID:
109-
NUM_CHANNELS = 16;
110-
NUM_Channel_led = 256;
111-
Version = 2;
113+
NUM_CHANNELS = 16;
114+
NUM_Channel_led = 256;
115+
Version = 2;
112116
break;
113117
case DRGB_SIG_AB_PID:
114-
NUM_CHANNELS = 16;
115-
NUM_Channel_led = 256;
116-
Version = 2;
118+
NUM_CHANNELS = 16;
119+
NUM_Channel_led = 256;
120+
Version = 2;
117121
break;
118122
case DRGB_SIG_CD_PID:
119-
NUM_CHANNELS = 6;
120-
NUM_Channel_led = 256;
121-
Version = 2;
123+
NUM_CHANNELS = 6;
124+
NUM_Channel_led = 256;
125+
Version = 2;
122126
break;
123127
case DRGB_Strimer_PID:
124-
NUM_CHANNELS = 6;
125-
NUM_Channel_led = 256;
126-
Version = 2;
128+
NUM_CHANNELS = 6;
129+
NUM_Channel_led = 256;
130+
Version = 2;
127131
break;
128132
}
129133

@@ -271,15 +275,16 @@ void RGBController_DRGB::DeviceUpdateLEDs()
271275
switch(Version)
272276
{
273277
case 4:
274-
unsigned int led_index = 0;
275-
unsigned char RGBData [8192*3 + 72] = {0};
278+
{
279+
unsigned int led_index = 0;
280+
unsigned char RGBData[8192*3 + 72] = {0};
276281
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
277282
{
278283
unsigned char LEDnum = zones[zone_idx].leds_count;
279-
unsigned int QLedCount = (LEDnum & 0xFFFF)>>8;
280-
unsigned int PLedCount = LEDnum & 0xFF;
281-
RGBData[zone_idx * 2 ] = QLedCount;
282-
RGBData[zone_idx * 2 + 1] = PLedCount;
284+
unsigned int HighCount = (LEDnum & 0xFFFF)>>8;
285+
unsigned int LowCount = LEDnum & 0xFF;
286+
RGBData[zone_idx * 2 ] = HighCount;
287+
RGBData[zone_idx * 2 + 1] = LowCount;
283288
for(unsigned int i=0; i<LEDnum;i++)
284289
{
285290
unsigned int RGBcolors = zones[zone_idx].colors[i];
@@ -293,16 +298,18 @@ void RGBController_DRGB::DeviceUpdateLEDs()
293298
break;
294299
}
295300
}
296-
unsigned int col_packets = 1 ;
301+
unsigned int col_packets = 1 ;
297302
if(led_index > 316)
298303
{
299304
col_packets = ((led_index - 316) / 340) + (((led_index - 316) % 340) > 0);
300305
}
301306
controller->SendPacket(&RGBData[0], col_packets,led_index);
302307
break;
308+
}
303309

304310
case 3:
305-
unsigned int led_index = 0;
311+
{
312+
unsigned int led_index = 0;
306313
unsigned char RGBData[1801*3] = {0};
307314
unsigned char ArrayData[64] = {0};
308315
ArrayData[0] = 0x60;
@@ -331,11 +338,12 @@ void RGBController_DRGB::DeviceUpdateLEDs()
331338
controller->SendPacketFS(&ArrayData[0], 1,0);
332339
controller->SendPacketFS(&RGBData[0], col_packets,1);
333340
break;
341+
}
334342

335343
case 2:
336344
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
337345
{
338-
unsigned char RGBData [256*3] = {0};
346+
unsigned char RGBData[256*3] = {0};
339347
unsigned char ArrayData[64] = {0};
340348
unsigned char LEDnum = zones[zone_idx].leds_count;
341349
for(unsigned int i=0; i<LEDnum;i++)
@@ -345,7 +353,7 @@ void RGBController_DRGB::DeviceUpdateLEDs()
345353
RGBData[i * 3 +1] = (RGBcolors >> 8) & 0xFF;
346354
RGBData[i * 3 +2] = (RGBcolors >> 16) & 0xFF;
347355
}
348-
unsigned char NumPackets = LEDnum / 20 + (LEDnum % 20) > 0;
356+
unsigned char NumPackets = (LEDnum / 20) + ((LEDnum % 20) > 0);
349357
for (unsigned int CurrPacket = 1 ; CurrPacket <= NumPackets; CurrPacket++)
350358
{
351359
ArrayData[0] = CurrPacket;

0 commit comments

Comments
 (0)