Skip to content

Commit b14abd9

Browse files
author
edbgon
committed
Update CMR6000 controller to direct mode and remove unreliable mode detection routine
1 parent bd8704a commit b14abd9

File tree

3 files changed

+22
-56
lines changed

3 files changed

+22
-56
lines changed

Controllers/CoolerMasterController/CMR6000Controller.cpp

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ CMR6000Controller::CMR6000Controller(hid_device* dev_handle, char *_path)
2929
wName = std::wstring(tmpName);
3030
serial = std::string(wName.begin(), wName.end());
3131

32-
GetStatus(); //When setting up device get current status
3332
}
3433

3534
CMR6000Controller::~CMR6000Controller()
@@ -40,30 +39,6 @@ CMR6000Controller::~CMR6000Controller()
4039
}
4140
}
4241

43-
void CMR6000Controller::GetStatus()
44-
{
45-
unsigned char buffer[CM_6K_PACKET_SIZE] = { 0x00, 0x52, 0xA0, 0x01, 0x00, 0x00, 0x03 };
46-
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
47-
48-
// Request mode
49-
hid_write(dev, buffer, buffer_size);
50-
hid_read(dev, buffer, buffer_size);
51-
52-
unsigned char cmdbuffer[CM_6K_PACKET_SIZE] = { 0x00, 0x52, 0x2C, 0x01, 0x00 };
53-
int cmdbuffer_size = (sizeof(cmdbuffer) / sizeof(cmdbuffer[0]));
54-
55-
current_mode = buffer[0x0A];
56-
cmdbuffer[0x05] = current_mode;
57-
hid_write(dev, cmdbuffer, cmdbuffer_size);
58-
hid_read(dev, cmdbuffer, cmdbuffer_size);
59-
60-
current_speed = cmdbuffer[0x05];
61-
current_brightness = cmdbuffer[0x09];
62-
current_red = cmdbuffer[0x0A];
63-
current_green = cmdbuffer[0x0B];
64-
current_blue = cmdbuffer[0x0C];
65-
}
66-
6742
std::string CMR6000Controller::GetDeviceName()
6843
{
6944
return device_name;
@@ -149,7 +124,7 @@ void CMR6000Controller::SendUpdate()
149124
buffer[0x03] = 0x01;
150125
buffer[0x04] = 0x00;
151126
buffer[0x05] = current_mode;
152-
buffer[0x06] = (current_mode == CM_MR6000_MODE_STATIC) ? 0xFF: current_speed;
127+
buffer[0x06] = (current_mode == CM_MR6000_MODE_DIRECT) ? 0xFF: current_speed;
153128
buffer[0x07] = (current_mode == CM_MR6000_MODE_BREATHE)? current_random : 0x00; //random (A0)
154129
buffer[0x08] = (current_mode == CM_MR6000_MODE_BREATHE)? 0x03 : 0xFF;
155130
//buffer[0x09] = 0xFF;

Controllers/CoolerMasterController/CMR6000Controller.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
enum
2222
{
23-
CM_MR6000_MODE_STATIC = 0x00, //Static Mode
23+
CM_MR6000_MODE_DIRECT = 0x00, //Direct Mode
2424
CM_MR6000_MODE_BREATHE = 0x01, //Breathe Mode
2525
CM_MR6000_MODE_COLOR_CYCLE = 0x02, //Color cycle
2626
CM_MR6000_MODE_OFF = 0xFF, //Off
@@ -75,7 +75,6 @@ class CMR6000Controller
7575
unsigned char current_blue;
7676
unsigned char current_brightness;
7777

78-
void GetStatus();
7978
void SendUpdate();
8079
void SendEnableCommand();
8180
void SendApplyCommand();

Controllers/CoolerMasterController/RGBController_CMR6000Controller.cpp

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,18 @@ RGBController_CMR6000Controller::RGBController_CMR6000Controller(CMR6000Controll
2828
Off.color_mode = MODE_COLORS_NONE;
2929
modes.push_back(Off);
3030

31-
mode Static;
32-
Static.name = "Static";
33-
Static.value = CM_MR6000_MODE_STATIC;
34-
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
35-
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
36-
Static.colors_min = 1;
37-
Static.colors_max = 1;
38-
Static.colors.resize(1);
39-
modes.push_back(Static);
31+
mode Direct;
32+
Direct.name = "Direct";
33+
Direct.value = CM_MR6000_MODE_DIRECT;
34+
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR| MODE_FLAG_HAS_BRIGHTNESS;
35+
Direct.color_mode = MODE_COLORS_PER_LED;
36+
Direct.colors_min = 1;
37+
Direct.colors_max = 1;
38+
Direct.colors.resize(1);
39+
Direct.brightness_min = 0x00;
40+
Direct.brightness_max = 0xFF;
41+
Direct.brightness = 0xFF;
42+
modes.push_back(Direct);
4043

4144
mode ColorCycle;
4245
ColorCycle.name = "Color Cycle";
@@ -55,31 +58,19 @@ RGBController_CMR6000Controller::RGBController_CMR6000Controller(CMR6000Controll
5558
mode Breathing;
5659
Breathing.name = "Breathing";
5760
Breathing.value = CM_MR6000_MODE_BREATHE;
58-
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
61+
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
5962
Breathing.speed_min = MR6000_BREATHE_SPEED_SLOWEST;
6063
Breathing.speed = MR6000_BREATHE_SPEED_NORMAL;
6164
Breathing.speed_max = MR6000_BREATHE_SPEED_FASTEST;
62-
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
65+
Breathing.color_mode = MODE_COLORS_PER_LED;
6366
Breathing.colors_min = 1;
6467
Breathing.colors_max = 1;
6568
Breathing.colors.resize(1);
6669
Breathing.speed = speed;
6770
modes.push_back(Breathing);
6871

6972
SetupZones();
70-
active_mode = cmr6000->GetMode();
71-
if (modes[active_mode].flags & MODE_FLAG_HAS_MODE_SPECIFIC_COLOR)
72-
{
73-
modes[active_mode].colors[0] = ToRGBColor(cmr6000->GetLedRed(), cmr6000->GetLedGreen(), cmr6000->GetLedBlue());
74-
}
75-
if (modes[active_mode].flags & MODE_FLAG_HAS_RANDOM_COLOR)
76-
{
77-
modes[active_mode].color_mode = (cmr6000->GetRandomColours()) ? MODE_COLORS_RANDOM : MODE_COLORS_MODE_SPECIFIC;
78-
}
79-
if (modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
80-
{
81-
modes[active_mode].speed = cmr6000->GetLedSpeed();
82-
}
73+
active_mode = 1;
8374
}
8475

8576
RGBController_CMR6000Controller::~RGBController_CMR6000Controller()
@@ -100,6 +91,7 @@ void RGBController_CMR6000Controller::SetupZones()
10091

10192
led GP_led;
10293
GP_led.name = "Logo";
94+
GP_led.value = 0;
10395
leds.push_back(GP_led);
10496

10597
SetupColors();
@@ -119,11 +111,11 @@ void RGBController_CMR6000Controller::DeviceUpdateLEDs()
119111
unsigned char grn = 0;
120112
unsigned char blu = 0;
121113

122-
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
114+
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
123115
{
124-
red = RGBGetRValue(modes[active_mode].colors[0]);
125-
grn = RGBGetGValue(modes[active_mode].colors[0]);
126-
blu = RGBGetBValue(modes[active_mode].colors[0]);
116+
red = RGBGetRValue(colors[0]);
117+
grn = RGBGetGValue(colors[0]);
118+
blu = RGBGetBValue(colors[0]);
127119
}
128120

129121
unsigned char rnd = (modes[active_mode].color_mode == MODE_COLORS_RANDOM) ? 0xA0 : 0x20;

0 commit comments

Comments
 (0)