mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-04-04 22:24:12 -04:00
Update CMR6000 controller to direct mode and remove unreliable mode detection routine
This commit is contained in:
@@ -29,7 +29,6 @@ CMR6000Controller::CMR6000Controller(hid_device* dev_handle, char *_path)
|
||||
wName = std::wstring(tmpName);
|
||||
serial = std::string(wName.begin(), wName.end());
|
||||
|
||||
GetStatus(); //When setting up device get current status
|
||||
}
|
||||
|
||||
CMR6000Controller::~CMR6000Controller()
|
||||
@@ -40,30 +39,6 @@ CMR6000Controller::~CMR6000Controller()
|
||||
}
|
||||
}
|
||||
|
||||
void CMR6000Controller::GetStatus()
|
||||
{
|
||||
unsigned char buffer[CM_6K_PACKET_SIZE] = { 0x00, 0x52, 0xA0, 0x01, 0x00, 0x00, 0x03 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
|
||||
// Request mode
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read(dev, buffer, buffer_size);
|
||||
|
||||
unsigned char cmdbuffer[CM_6K_PACKET_SIZE] = { 0x00, 0x52, 0x2C, 0x01, 0x00 };
|
||||
int cmdbuffer_size = (sizeof(cmdbuffer) / sizeof(cmdbuffer[0]));
|
||||
|
||||
current_mode = buffer[0x0A];
|
||||
cmdbuffer[0x05] = current_mode;
|
||||
hid_write(dev, cmdbuffer, cmdbuffer_size);
|
||||
hid_read(dev, cmdbuffer, cmdbuffer_size);
|
||||
|
||||
current_speed = cmdbuffer[0x05];
|
||||
current_brightness = cmdbuffer[0x09];
|
||||
current_red = cmdbuffer[0x0A];
|
||||
current_green = cmdbuffer[0x0B];
|
||||
current_blue = cmdbuffer[0x0C];
|
||||
}
|
||||
|
||||
std::string CMR6000Controller::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
@@ -149,7 +124,7 @@ void CMR6000Controller::SendUpdate()
|
||||
buffer[0x03] = 0x01;
|
||||
buffer[0x04] = 0x00;
|
||||
buffer[0x05] = current_mode;
|
||||
buffer[0x06] = (current_mode == CM_MR6000_MODE_STATIC) ? 0xFF: current_speed;
|
||||
buffer[0x06] = (current_mode == CM_MR6000_MODE_DIRECT) ? 0xFF: current_speed;
|
||||
buffer[0x07] = (current_mode == CM_MR6000_MODE_BREATHE)? current_random : 0x00; //random (A0)
|
||||
buffer[0x08] = (current_mode == CM_MR6000_MODE_BREATHE)? 0x03 : 0xFF;
|
||||
//buffer[0x09] = 0xFF;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
enum
|
||||
{
|
||||
CM_MR6000_MODE_STATIC = 0x00, //Static Mode
|
||||
CM_MR6000_MODE_DIRECT = 0x00, //Direct Mode
|
||||
CM_MR6000_MODE_BREATHE = 0x01, //Breathe Mode
|
||||
CM_MR6000_MODE_COLOR_CYCLE = 0x02, //Color cycle
|
||||
CM_MR6000_MODE_OFF = 0xFF, //Off
|
||||
@@ -75,7 +75,6 @@ private:
|
||||
unsigned char current_blue;
|
||||
unsigned char current_brightness;
|
||||
|
||||
void GetStatus();
|
||||
void SendUpdate();
|
||||
void SendEnableCommand();
|
||||
void SendApplyCommand();
|
||||
|
||||
@@ -28,15 +28,18 @@ RGBController_CMR6000Controller::RGBController_CMR6000Controller(CMR6000Controll
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CM_MR6000_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = CM_MR6000_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR| MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
Direct.colors_min = 1;
|
||||
Direct.colors_max = 1;
|
||||
Direct.colors.resize(1);
|
||||
Direct.brightness_min = 0x00;
|
||||
Direct.brightness_max = 0xFF;
|
||||
Direct.brightness = 0xFF;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode ColorCycle;
|
||||
ColorCycle.name = "Color Cycle";
|
||||
@@ -55,11 +58,11 @@ RGBController_CMR6000Controller::RGBController_CMR6000Controller(CMR6000Controll
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = CM_MR6000_MODE_BREATHE;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Breathing.speed_min = MR6000_BREATHE_SPEED_SLOWEST;
|
||||
Breathing.speed = MR6000_BREATHE_SPEED_NORMAL;
|
||||
Breathing.speed_max = MR6000_BREATHE_SPEED_FASTEST;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.colors.resize(1);
|
||||
@@ -67,19 +70,7 @@ RGBController_CMR6000Controller::RGBController_CMR6000Controller(CMR6000Controll
|
||||
modes.push_back(Breathing);
|
||||
|
||||
SetupZones();
|
||||
active_mode = cmr6000->GetMode();
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_MODE_SPECIFIC_COLOR)
|
||||
{
|
||||
modes[active_mode].colors[0] = ToRGBColor(cmr6000->GetLedRed(), cmr6000->GetLedGreen(), cmr6000->GetLedBlue());
|
||||
}
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_RANDOM_COLOR)
|
||||
{
|
||||
modes[active_mode].color_mode = (cmr6000->GetRandomColours()) ? MODE_COLORS_RANDOM : MODE_COLORS_MODE_SPECIFIC;
|
||||
}
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
modes[active_mode].speed = cmr6000->GetLedSpeed();
|
||||
}
|
||||
active_mode = 1;
|
||||
}
|
||||
|
||||
RGBController_CMR6000Controller::~RGBController_CMR6000Controller()
|
||||
@@ -100,6 +91,7 @@ void RGBController_CMR6000Controller::SetupZones()
|
||||
|
||||
led GP_led;
|
||||
GP_led.name = "Logo";
|
||||
GP_led.value = 0;
|
||||
leds.push_back(GP_led);
|
||||
|
||||
SetupColors();
|
||||
@@ -119,11 +111,11 @@ void RGBController_CMR6000Controller::DeviceUpdateLEDs()
|
||||
unsigned char grn = 0;
|
||||
unsigned char blu = 0;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
|
||||
{
|
||||
red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
red = RGBGetRValue(colors[0]);
|
||||
grn = RGBGetGValue(colors[0]);
|
||||
blu = RGBGetBValue(colors[0]);
|
||||
}
|
||||
|
||||
unsigned char rnd = (modes[active_mode].color_mode == MODE_COLORS_RANDOM) ? 0xA0 : 0x20;
|
||||
|
||||
Reference in New Issue
Block a user