Compare commits
35
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a31751ea1 | ||
|
|
862bf8605d | ||
|
|
3ea9839770 | ||
|
|
320bf22274 | ||
|
|
8f911d9a85 | ||
|
|
7e9df3ab7d | ||
|
|
16b488169e | ||
|
|
60531f4d76 | ||
|
|
6bbbcffcad | ||
|
|
f4dc9862f5 | ||
|
|
fb3690127c | ||
|
|
79f0137440 | ||
|
|
24d7d8a3b0 | ||
|
|
ef5bec4a59 | ||
|
|
8cfca6ba16 | ||
|
|
d9eb5ff3f4 | ||
|
|
7343c570df | ||
|
|
74708b91bb | ||
|
|
3cb2fa7e75 | ||
|
|
8a56e712c2 | ||
|
|
b9ead7ae17 | ||
|
|
3f710119f2 | ||
|
|
0a0818a3a5 | ||
|
|
dcea6502bf | ||
|
|
d0b4e2078f | ||
|
|
b2f2fb2204 | ||
|
|
4beeaf4044 | ||
|
|
6c6e75b673 | ||
|
|
50517b5159 | ||
|
|
b4de1177e5 | ||
|
|
3cec45bdc2 | ||
|
|
6e7c248407 | ||
|
|
c75874d4d6 | ||
|
|
34f8df07f3 | ||
|
|
aa52d93198 |
@@ -18,9 +18,19 @@ AMDWraithPrismController::AMDWraithPrismController(libusb_device_handle* dev_han
|
||||
|
||||
strcpy(device_name, "AMD Wraith Prism");
|
||||
|
||||
current_fan_mode = AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC;
|
||||
current_fan_speed = 0xFF;
|
||||
current_fan_random_color = false;
|
||||
|
||||
current_logo_mode = AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC;
|
||||
current_logo_speed = 0xFF;
|
||||
current_logo_random_color = false;
|
||||
|
||||
current_ring_mode = AMD_WRAITH_PRISM_EFFECT_CHANNEL_STATIC;
|
||||
current_ring_speed = 0xFF;
|
||||
current_ring_direction = false;
|
||||
|
||||
SendEnableCommand();
|
||||
SetRingEffectChannel(0x00);
|
||||
SendApplyCommand();
|
||||
}
|
||||
|
||||
AMDWraithPrismController::~AMDWraithPrismController()
|
||||
@@ -116,133 +126,83 @@ std::string AMDWraithPrismController::GetFirmwareVersionString()
|
||||
return(ret_string);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SetFanMode(unsigned char mode, unsigned char speed, bool random_color)
|
||||
{
|
||||
current_fan_mode = mode;
|
||||
current_fan_speed = speed_values_fan_logo[mode][speed];
|
||||
current_fan_random_color = random_color;
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SetFanColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x51, 0x2C, 0x01, 0x00,
|
||||
0x06, 0xFF, 0x00, 0x01,
|
||||
0xFF, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF
|
||||
};
|
||||
SendEffectChannelUpdate
|
||||
(
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_FAN_LED,
|
||||
current_fan_speed,
|
||||
false,
|
||||
current_fan_random_color,
|
||||
current_fan_mode,
|
||||
max_brightness_fan_logo[current_fan_mode],
|
||||
red,
|
||||
green,
|
||||
blue
|
||||
);
|
||||
}
|
||||
|
||||
int actual;
|
||||
|
||||
usb_buf[0x0A] = red;
|
||||
usb_buf[0x0B] = green;
|
||||
usb_buf[0x0C] = blue;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
void AMDWraithPrismController::SetLogoMode(unsigned char mode, unsigned char speed, bool random_color)
|
||||
{
|
||||
current_logo_mode = mode;
|
||||
current_logo_speed = speed_values_fan_logo[mode][speed];
|
||||
current_logo_random_color = random_color;
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SetLogoColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x51, 0x2C, 0x01, 0x00,
|
||||
0x05, 0xFF, 0x00, 0x01,
|
||||
0xFF, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF
|
||||
};
|
||||
SendEffectChannelUpdate
|
||||
(
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_LOGO_LED,
|
||||
current_logo_speed,
|
||||
false,
|
||||
current_logo_random_color,
|
||||
current_logo_mode,
|
||||
max_brightness_fan_logo[current_logo_mode],
|
||||
red,
|
||||
green,
|
||||
blue
|
||||
);
|
||||
}
|
||||
|
||||
int actual;
|
||||
|
||||
usb_buf[0x0A] = red;
|
||||
usb_buf[0x0B] = green;
|
||||
usb_buf[0x0C] = blue;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
void AMDWraithPrismController::SetRingMode(unsigned char mode, unsigned char speed, bool direction, bool random_color)
|
||||
{
|
||||
current_ring_mode = mode;
|
||||
current_ring_speed = speed_values_ring[mode][speed];
|
||||
current_ring_direction = direction;
|
||||
current_ring_random_color = random_color;
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SetRingColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x51, 0x2C, 0x01, 0x00,
|
||||
0x00, 0xFF, 0x00, 0xFF,
|
||||
0xFF, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF
|
||||
};
|
||||
SetRingEffectChannel(current_ring_mode);
|
||||
|
||||
int actual;
|
||||
SendEffectChannelUpdate
|
||||
(
|
||||
current_ring_mode,
|
||||
current_ring_speed,
|
||||
current_ring_direction,
|
||||
current_ring_random_color,
|
||||
mode_value_ring[current_ring_mode],
|
||||
max_brightness_ring[current_ring_mode],
|
||||
red,
|
||||
green,
|
||||
blue
|
||||
);
|
||||
|
||||
usb_buf[0x0A] = red;
|
||||
usb_buf[0x0B] = green;
|
||||
usb_buf[0x0C] = blue;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
SendApplyCommand();
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SetRingEffectChannel(unsigned char channel)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x51, 0xA0, 0x01, 0x00,
|
||||
0x00, 0x03, 0x00, 0x00,
|
||||
0x05, 0x06, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
int actual;
|
||||
|
||||
for(int led = 0x0A; led <= 0x18; led++)
|
||||
{
|
||||
usb_buf[led] = channel;
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
SendChannelRemap(channel, AMD_WRAITH_PRISM_EFFECT_CHANNEL_LOGO_LED, AMD_WRAITH_PRISM_EFFECT_CHANNEL_FAN_LED);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SendEnableCommand()
|
||||
@@ -301,7 +261,18 @@ void AMDWraithPrismController::SendApplyCommand()
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SendEffectCommand()
|
||||
void AMDWraithPrismController::SendEffectChannelUpdate
|
||||
(
|
||||
unsigned char effect_channel,
|
||||
unsigned char speed,
|
||||
bool direction,
|
||||
bool random_color,
|
||||
unsigned char mode,
|
||||
unsigned char brightness,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
@@ -325,6 +296,53 @@ void AMDWraithPrismController::SendEffectCommand()
|
||||
|
||||
int actual;
|
||||
|
||||
usb_buf[0x04] = effect_channel;
|
||||
usb_buf[0x05] = speed;
|
||||
usb_buf[0x06] = (direction ? 0x01 : 0x00) | (random_color ? 0x80 : 0x00);
|
||||
usb_buf[0x07] = mode;
|
||||
|
||||
usb_buf[0x09] = brightness;
|
||||
|
||||
usb_buf[0x0A] = red;
|
||||
usb_buf[0x0B] = green;
|
||||
usb_buf[0x0C] = blue;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SendChannelRemap(unsigned char ring_channel, unsigned char logo_channel, unsigned char fan_channel)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x51, 0xA0, 0x01, 0x00,
|
||||
0x00, 0x03, 0x00, 0x00,
|
||||
0x05, 0x06, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
int actual;
|
||||
|
||||
usb_buf[0x08] = logo_channel;
|
||||
usb_buf[0x09] = fan_channel;
|
||||
|
||||
for(int led = 0x0A; led <= 0x18; led++)
|
||||
{
|
||||
usb_buf[led] = ring_channel;
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,100 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
static const unsigned char max_brightness_fan_logo[] =
|
||||
{
|
||||
0x00,
|
||||
0xFF,
|
||||
0x7F,
|
||||
0xFF
|
||||
};
|
||||
|
||||
static const unsigned char speed_values_fan_logo[][5] =
|
||||
{
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
|
||||
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, /* Static */
|
||||
{ 0x96, 0x8C, 0x80, 0x6E, 0x68 }, /* Color Cycle */
|
||||
{ 0x3C, 0x37, 0x31, 0x2C, 0x26 }, /* Breathing */
|
||||
};
|
||||
|
||||
static const unsigned char max_brightness_ring[] =
|
||||
{
|
||||
0xFF,
|
||||
0xFF,
|
||||
0x7F,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0xFF
|
||||
};
|
||||
|
||||
static const unsigned char mode_value_ring[] =
|
||||
{
|
||||
0xFF,
|
||||
0x03,
|
||||
0xFF,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x05,
|
||||
0xFF,
|
||||
0xC3,
|
||||
0x4A,
|
||||
0x05
|
||||
};
|
||||
|
||||
static const unsigned char speed_values_ring[][5] =
|
||||
{
|
||||
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, /* Static */
|
||||
{ 0x3C, 0x37, 0x31, 0x2C, 0x26 }, /* Breathing */
|
||||
{ 0x96, 0x8C, 0x80, 0x6E, 0x68 }, /* Color Cycle */
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
|
||||
{ 0x72, 0x68, 0x64, 0x62, 0x61 }, /* Rainbow */
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Bounce */
|
||||
{ 0x77, 0x74, 0x6E, 0x6B, 0x67 }, /* Chase */
|
||||
{ 0x77, 0x74, 0x6E, 0x6B, 0x67 }, /* Swirl */
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Morse Code */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC = 0x01, /* Fan/Logo Static Mode */
|
||||
AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE = 0x02, /* Fan/Logo Color Cycle Mode */
|
||||
AMD_WRAITH_PRISM_FAN_LOGO_MODE_BREATHING = 0x03, /* Fan/Logo Breathing Mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_STATIC = 0x00, /* Static effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_BREATHING = 0x01, /* Breathing effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_COLOR_CYCLE = 0x02, /* Color cycle effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_LOGO_LED = 0x05, /* Logo LED effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_FAN_LED = 0x06, /* Fan LED effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_RAINBOW = 0x07, /* Rainbow effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_BOUNCE = 0x08, /* Bounce effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_CHASE = 0x09, /* Chase effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_SWIRL = 0x0A, /* Swirl effect channel */
|
||||
AMD_WRAITH_PRISM_EFFECT_CHANNEL_MORSE = 0x0B, /* Morse code effect channel */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AMD_WRAITH_PRISM_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
AMD_WRAITH_PRISM_SPEED_SLOW = 0x01, /* Slow speed */
|
||||
AMD_WRAITH_PRISM_SPEED_NORMAL = 0x02, /* Normal speed */
|
||||
AMD_WRAITH_PRISM_SPEED_FAST = 0x03, /* Fast speed */
|
||||
AMD_WRAITH_PRISM_SPEED_FASTEST = 0x04, /* Fastest speed */
|
||||
};
|
||||
|
||||
class AMDWraithPrismController
|
||||
{
|
||||
public:
|
||||
@@ -25,15 +119,48 @@ public:
|
||||
|
||||
void SetRingEffectChannel(unsigned char channel);
|
||||
|
||||
void SetFanMode(unsigned char mode, unsigned char speed, bool random_color);
|
||||
void SetFanColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLogoColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetRingColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
void SendEnableCommand();
|
||||
void SendApplyCommand();
|
||||
void SendEffectCommand();
|
||||
void SetLogoMode(unsigned char mode, unsigned char speed, bool random_color);
|
||||
void SetLogoColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
void SetRingMode(unsigned char mode, unsigned char speed, bool direction, bool random_color);
|
||||
void SetRingColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
libusb_device_handle* dev;
|
||||
|
||||
unsigned char current_fan_mode;
|
||||
unsigned char current_fan_speed;
|
||||
bool current_fan_random_color;
|
||||
|
||||
unsigned char current_logo_mode;
|
||||
unsigned char current_logo_speed;
|
||||
bool current_logo_random_color;
|
||||
|
||||
unsigned char current_ring_mode;
|
||||
unsigned char current_ring_speed;
|
||||
bool current_ring_direction;
|
||||
bool current_ring_random_color;
|
||||
|
||||
void SendEnableCommand();
|
||||
|
||||
void SendApplyCommand();
|
||||
|
||||
void SendEffectChannelUpdate
|
||||
(
|
||||
unsigned char effect_channel,
|
||||
unsigned char speed,
|
||||
bool direction,
|
||||
bool random_color,
|
||||
unsigned char mode,
|
||||
unsigned char brightness,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
void SendChannelRemap(unsigned char ring_channel, unsigned char logo_channel, unsigned char fan_channel);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,504 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Processing Code for Corsair Commander Pro |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 1/16/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "CorsairCmdrProController.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
//Include thread libraries for Windows or Linux
|
||||
#ifdef WIN32
|
||||
#include <process.h>
|
||||
#else
|
||||
#include "pthread.h"
|
||||
#include "unistd.h"
|
||||
#endif
|
||||
|
||||
//Thread functions have different types in Windows and Linux
|
||||
#ifdef WIN32
|
||||
#define THREAD static void
|
||||
#define THREADRETURN
|
||||
#else
|
||||
#define THREAD static void*
|
||||
#define THREADRETURN return(NULL);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
THREAD keepalive_thread(void *param)
|
||||
{
|
||||
CorsairCmdrProController* corsair = static_cast<CorsairCmdrProController*>(param);
|
||||
corsair->KeepaliveThread();
|
||||
THREADRETURN
|
||||
}
|
||||
|
||||
CorsairCmdrProController::CorsairCmdrProController(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
channel_leds[0] = 60;
|
||||
channel_leds[1] = 60;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| The Corsair Lighting Node Pro requires a packet within|
|
||||
| 20 seconds of sending the lighting change in order |
|
||||
| to not revert back into rainbow mode. Start a thread |
|
||||
| to continuously send a keepalive packet every 5s |
|
||||
\*-----------------------------------------------------*/
|
||||
#ifdef WIN32
|
||||
_beginthread(keepalive_thread, 0, this);
|
||||
#else
|
||||
pthread_t thread;
|
||||
pthread_create(&thread, NULL, &keepalive_thread, this);
|
||||
#endif
|
||||
}
|
||||
|
||||
CorsairCmdrProController::~CorsairCmdrProController()
|
||||
{
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::KeepaliveThread()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
SendCommit();
|
||||
Sleep(5000);
|
||||
}
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SetChannelEffect(unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
bool random,
|
||||
unsigned char red1,
|
||||
unsigned char grn1,
|
||||
unsigned char blu1,
|
||||
unsigned char red2,
|
||||
unsigned char grn2,
|
||||
unsigned char blu2
|
||||
)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Reset packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendReset(channel);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Begin packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendBegin(channel);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set Port State packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set Effect Configuration packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendEffectConfig
|
||||
(
|
||||
channel,
|
||||
0,
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP,
|
||||
mode,
|
||||
speed,
|
||||
direction,
|
||||
random,
|
||||
red1,
|
||||
grn1,
|
||||
blu1,
|
||||
red2,
|
||||
grn2,
|
||||
blu2,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char color_data[50];
|
||||
unsigned char pkt_max;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Port State packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send red channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetRValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send red channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetRValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send green channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetGValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send green channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetGValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send blue channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetBValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send blue channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetBValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void CorsairCmdrProController::SendDirect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char start,
|
||||
unsigned char count,
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Direct packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_DIRECT;
|
||||
usb_buf[0x01] = channel;
|
||||
usb_buf[0x02] = start;
|
||||
usb_buf[0x03] = count;
|
||||
usb_buf[0x04] = color_channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x05], color_data, count);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendCommit()
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_COMMIT;
|
||||
usb_buf[0x01] = 0xFF;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendBegin
|
||||
(
|
||||
unsigned char channel
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Begin packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_BEGIN;
|
||||
usb_buf[0x01] = channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendEffectConfig
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char count,
|
||||
unsigned char led_type,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
unsigned char change_style,
|
||||
unsigned char color_0_red,
|
||||
unsigned char color_0_green,
|
||||
unsigned char color_0_blue,
|
||||
unsigned char color_1_red,
|
||||
unsigned char color_1_green,
|
||||
unsigned char color_1_blue,
|
||||
unsigned char color_2_red,
|
||||
unsigned char color_2_green,
|
||||
unsigned char color_2_blue,
|
||||
unsigned short temperature_0,
|
||||
unsigned short temperature_1,
|
||||
unsigned short temperature_2
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Effect Config packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG;
|
||||
usb_buf[0x01] = channel;
|
||||
usb_buf[0x02] = count * 10;
|
||||
usb_buf[0x03] = led_type;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up mode parameters |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x04] = mode;
|
||||
usb_buf[0x05] = speed;
|
||||
usb_buf[0x06] = direction;
|
||||
usb_buf[0x07] = change_style;
|
||||
usb_buf[0x08] = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up mode colors |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x09] = color_0_red;
|
||||
usb_buf[0x10] = color_0_green;
|
||||
usb_buf[0x11] = color_0_blue;
|
||||
usb_buf[0x12] = color_1_red;
|
||||
usb_buf[0x13] = color_1_green;
|
||||
usb_buf[0x14] = color_1_blue;
|
||||
usb_buf[0x15] = color_2_red;
|
||||
usb_buf[0x16] = color_2_green;
|
||||
usb_buf[0x17] = color_2_blue;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up temperatures |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x12] = (temperature_0 >> 8);
|
||||
usb_buf[0x13] = (temperature_0 & 0xFF);
|
||||
usb_buf[0x14] = (temperature_1 >> 8);
|
||||
usb_buf[0x15] = (temperature_1 & 0xFF);
|
||||
usb_buf[0x16] = (temperature_2 >> 8);
|
||||
usb_buf[0x17] = (temperature_2 & 0xFF);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendTemperature()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendReset
|
||||
(
|
||||
unsigned char channel
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Reset packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_RESET;
|
||||
usb_buf[0x01] = channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendPortState
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char state
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Port State packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE;
|
||||
usb_buf[0x01] = channel;
|
||||
usb_buf[0x02] = state;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendBrightness()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendLEDCount()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendProtocol()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Definitions for Corsair Commander Pro |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 1/16/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_DIRECT = 0x32, /* Direct mode LED update packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_COMMIT = 0x33, /* Commit changes packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_BEGIN = 0x34, /* Begin effect packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG = 0x35, /* Effect mode configuration packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_TEMPERATURE = 0x36, /* Update temperature value packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_RESET = 0x37, /* Reset channel packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE = 0x38, /* Set port state packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_BRIGHTNESS = 0x39, /* Set brightness packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_LED_COUNT = 0x3A, /* Set LED count packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_PROTOCOL = 0x3B, /* Set protocol packet */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED = 0x00, /* Red channel for direct update */
|
||||
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN = 0x01, /* Green channel for direct update */
|
||||
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE = 0x02, /* Blue channel for direct update */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE = 0x01, /* Effect hardware control of channel */
|
||||
CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE = 0x02, /* Direct software control of channel */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP = 0x0A, /* Corsair LED Strip Type */
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_HD_FAN = 0x0C, /* Corsair HD-series Fan Type */
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_SP_FAN = 0x01, /* Corsair SP-series Fan Type */
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_ML_FAN = 0x02, /* Corsair ML-series Fan Type */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_CHANNEL_1 = 0x00, /* Channel 1 */
|
||||
CORSAIR_CMDR_PRO_CHANNEL_2 = 0x01, /* Channel 2 */
|
||||
CORSAIR_CMDR_PRO_NUM_CHANNELS = 0x02, /* Number of channels */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_SPEED_FAST = 0x00, /* Fast speed */
|
||||
CORSAIR_CMDR_PRO_SPEED_MEDIUM = 0x01, /* Medium speed */
|
||||
CORSAIR_CMDR_PRO_SPEED_SLOW = 0x02, /* Slow speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE = 0x00, /* Rainbow Wave mode */
|
||||
CORSAIR_CMDR_PRO_MODE_COLOR_SHIFT = 0x01, /* Color Shift mode */
|
||||
CORSAIR_CMDR_PRO_MODE_COLOR_PULSE = 0x02, /* Color Pulse mode */
|
||||
CORSAIR_CMDR_PRO_MODE_COLOR_WAVE = 0x03, /* Color Wave mode */
|
||||
CORSAIR_CMDR_PRO_MODE_STATIC = 0x04, /* Static mode */
|
||||
CORSAIR_CMDR_PRO_MODE_TEMPERATURE = 0x05, /* Temperature mode */
|
||||
CORSAIR_CMDR_PRO_MODE_VISOR = 0x06, /* Visor mode */
|
||||
CORSAIR_CMDR_PRO_MODE_MARQUEE = 0x07, /* Marquee mode */
|
||||
CORSAIR_CMDR_PRO_MODE_BLINK = 0x08, /* Blink mode */
|
||||
CORSAIR_CMDR_PRO_MODE_SEQUENTIAL = 0x09, /* Sequential mode */
|
||||
CORSAIR_CMDR_PRO_MODE_RAINBOW = 0x0A, /* Rainbow mode */
|
||||
};
|
||||
|
||||
class CorsairCmdrProController
|
||||
{
|
||||
public:
|
||||
CorsairCmdrProController(libusb_device_handle* dev_handle);
|
||||
~CorsairCmdrProController();
|
||||
|
||||
char* GetLEDString();
|
||||
unsigned int GetStripsOnChannel(unsigned int channel);
|
||||
|
||||
void SetChannelEffect(unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
bool random,
|
||||
unsigned char red1,
|
||||
unsigned char grn1,
|
||||
unsigned char blu1,
|
||||
unsigned char red2,
|
||||
unsigned char grn2,
|
||||
unsigned char blu2
|
||||
);
|
||||
|
||||
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
|
||||
unsigned int channel_leds[CORSAIR_CMDR_PRO_NUM_CHANNELS];
|
||||
|
||||
void KeepaliveThread();
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
|
||||
void SendDirect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char start,
|
||||
unsigned char count,
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
);
|
||||
|
||||
void SendCommit();
|
||||
|
||||
void SendBegin
|
||||
(
|
||||
unsigned char channel
|
||||
);
|
||||
|
||||
void SendEffectConfig
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char count,
|
||||
unsigned char led_type,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
unsigned char change_style,
|
||||
unsigned char color_0_red,
|
||||
unsigned char color_0_green,
|
||||
unsigned char color_0_blue,
|
||||
unsigned char color_1_red,
|
||||
unsigned char color_1_green,
|
||||
unsigned char color_1_blue,
|
||||
unsigned char color_2_red,
|
||||
unsigned char color_2_green,
|
||||
unsigned char color_2_blue,
|
||||
unsigned short temperature_0,
|
||||
unsigned short temperature_1,
|
||||
unsigned short temperature_2
|
||||
);
|
||||
|
||||
void SendTemperature();
|
||||
|
||||
void SendReset
|
||||
(
|
||||
unsigned char channel
|
||||
);
|
||||
|
||||
void SendPortState
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char state
|
||||
);
|
||||
|
||||
void SendBrightness();
|
||||
|
||||
void SendLEDCount();
|
||||
|
||||
void SendProtocol();
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "CorsairCmdrProController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairCmdrPro.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#define CORSAIR_COMMANDER_PRO_VID 0x1B1C
|
||||
#define CORSAIR_COMMANDER_PRO_PID 0x0C10
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairCmdrProControllers *
|
||||
* *
|
||||
* Detect devices supported by the Corsair Commander Pro driver *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairCmdrProControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
|
||||
//Look for Corsair Commander Pro
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, CORSAIR_COMMANDER_PRO_VID, CORSAIR_COMMANDER_PRO_PID);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
|
||||
CorsairCmdrProController* controller = new CorsairCmdrProController(dev);
|
||||
|
||||
RGBController_CorsairCmdrPro* rgb_controller = new RGBController_CorsairCmdrPro(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
} /* DetectCorsairCmdrProControllers() */
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
//Include thread libraries for Windows or Linux
|
||||
#ifdef WIN32
|
||||
@@ -69,171 +70,122 @@ CorsairNodeProController::~CorsairNodeProController()
|
||||
{
|
||||
}
|
||||
|
||||
void CorsairNodeProController::SendKeepalive()
|
||||
{
|
||||
unsigned char usb_apply[] =
|
||||
{
|
||||
0x33, 0xFF, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
int actual;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send apply packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_apply, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairNodeProController::KeepaliveThread()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
SendKeepalive();
|
||||
|
||||
SendCommit();
|
||||
Sleep(5000);
|
||||
}
|
||||
}
|
||||
|
||||
void CorsairNodeProController::SetChannelLEDs(unsigned int channel, std::vector<RGBColor> colors)
|
||||
void CorsairNodeProController::SetChannelEffect(unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
bool random,
|
||||
unsigned char red1,
|
||||
unsigned char grn1,
|
||||
unsigned char blu1,
|
||||
unsigned char red2,
|
||||
unsigned char grn2,
|
||||
unsigned char blu2
|
||||
)
|
||||
{
|
||||
unsigned char usb_start[] =
|
||||
{
|
||||
0x38, 0x00, 0x02, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
unsigned char usb_data[] =
|
||||
{
|
||||
0x32, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
unsigned char usb_apply[] =
|
||||
{
|
||||
0x33, 0xFF, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
int actual;
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Reset packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendReset(channel);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set channel in USB packets |
|
||||
| Send Begin packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_data[0x01] = channel;
|
||||
usb_start[0x01] = channel;
|
||||
SendBegin(channel);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send start packet |
|
||||
| Set Port State packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_start, 64, &actual, 0);
|
||||
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set Effect Configuration packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendEffectConfig
|
||||
(
|
||||
channel,
|
||||
0,
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP,
|
||||
mode,
|
||||
speed,
|
||||
direction,
|
||||
random,
|
||||
red1,
|
||||
grn1,
|
||||
blu1,
|
||||
red2,
|
||||
grn2,
|
||||
blu2,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
void CorsairNodeProController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char color_data[50];
|
||||
unsigned char pkt_max;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Port State packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send red channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
std::size_t pkt_max = 50;
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = colors.size();
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
usb_data[0x02] = 0;
|
||||
usb_data[0x03] = pkt_max;
|
||||
usb_data[0x04] = 0x00; //red
|
||||
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
RGBColor color = colors[idx];
|
||||
usb_data[idx + 5] = RGBGetRValue(color);
|
||||
color_data[idx] = RGBGetRValue(colors[idx]);
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_data, 64, &actual, 0);
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send red channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int idx = 4; idx < 64; idx++)
|
||||
{
|
||||
usb_data[idx] = 0;
|
||||
}
|
||||
|
||||
pkt_max = 0;
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = colors.size() - 50;
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
usb_data[0x02] = 50;
|
||||
usb_data[0x03] = pkt_max;
|
||||
usb_data[0x04] = 0x00; //red
|
||||
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
RGBColor color = colors[idx + 50];
|
||||
usb_data[idx + 5] = RGBGetRValue(color);
|
||||
color_data[idx] = RGBGetRValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_data, 64, &actual, 0);
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send green channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -241,49 +193,34 @@ void CorsairNodeProController::SetChannelLEDs(unsigned int channel, std::vector<
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = colors.size();
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
usb_data[0x02] = 0;
|
||||
usb_data[0x03] = pkt_max;
|
||||
usb_data[0x04] = 0x01; //green
|
||||
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
RGBColor color = colors[idx];
|
||||
usb_data[idx + 5] = RGBGetGValue(color);
|
||||
color_data[idx] = RGBGetGValue(colors[idx]);
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_data, 64, &actual, 0);
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send green channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int idx = 4; idx < 64; idx++)
|
||||
{
|
||||
usb_data[idx] = 0;
|
||||
}
|
||||
|
||||
pkt_max = 0;
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = colors.size() - 50;
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
usb_data[0x02] = 50;
|
||||
usb_data[0x03] = pkt_max;
|
||||
usb_data[0x04] = 0x01; //green
|
||||
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
RGBColor color = colors[idx + 50];
|
||||
usb_data[idx + 5] = RGBGetGValue(color);
|
||||
color_data[idx] = RGBGetGValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_data, 64, &actual, 0);
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -293,53 +230,275 @@ void CorsairNodeProController::SetChannelLEDs(unsigned int channel, std::vector<
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = colors.size();
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
usb_data[0x02] = 0;
|
||||
usb_data[0x03] = pkt_max;
|
||||
usb_data[0x04] = 0x02; //blue
|
||||
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
RGBColor color = colors[idx];
|
||||
usb_data[idx + 5] = RGBGetBValue(color);
|
||||
color_data[idx] = RGBGetBValue(colors[idx]);
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_data, 64, &actual, 0);
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send blue channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int idx = 4; idx < 64; idx++)
|
||||
{
|
||||
usb_data[idx] = 0;
|
||||
}
|
||||
|
||||
pkt_max = 0;
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = colors.size() - 50;
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
usb_data[0x02] = 50;
|
||||
usb_data[0x03] = pkt_max;
|
||||
usb_data[0x04] = 0x02; //blue
|
||||
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
RGBColor color = colors[idx + 50];
|
||||
usb_data[idx + 5] = RGBGetBValue(color);
|
||||
color_data[idx] = RGBGetBValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_data, 64, &actual, 0);
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send apply packet |
|
||||
| Send Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_apply, 64, &actual, 0);
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void CorsairNodeProController::SendDirect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char start,
|
||||
unsigned char count,
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Direct packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_DIRECT;
|
||||
usb_buf[0x01] = channel;
|
||||
usb_buf[0x02] = start;
|
||||
usb_buf[0x03] = count;
|
||||
usb_buf[0x04] = color_channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x05], color_data, count);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairNodeProController::SendCommit()
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_COMMIT;
|
||||
usb_buf[0x01] = 0xFF;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairNodeProController::SendBegin
|
||||
(
|
||||
unsigned char channel
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Begin packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_BEGIN;
|
||||
usb_buf[0x01] = channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairNodeProController::SendEffectConfig
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char count,
|
||||
unsigned char led_type,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
unsigned char change_style,
|
||||
unsigned char color_0_red,
|
||||
unsigned char color_0_green,
|
||||
unsigned char color_0_blue,
|
||||
unsigned char color_1_red,
|
||||
unsigned char color_1_green,
|
||||
unsigned char color_1_blue,
|
||||
unsigned char color_2_red,
|
||||
unsigned char color_2_green,
|
||||
unsigned char color_2_blue,
|
||||
unsigned short temperature_0,
|
||||
unsigned short temperature_1,
|
||||
unsigned short temperature_2
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Effect Config packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG;
|
||||
usb_buf[0x01] = channel;
|
||||
usb_buf[0x02] = count * 10;
|
||||
usb_buf[0x03] = led_type;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up mode parameters |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x04] = mode;
|
||||
usb_buf[0x05] = speed;
|
||||
usb_buf[0x06] = direction;
|
||||
usb_buf[0x07] = change_style;
|
||||
usb_buf[0x08] = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up mode colors |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x09] = color_0_red;
|
||||
usb_buf[0x10] = color_0_green;
|
||||
usb_buf[0x11] = color_0_blue;
|
||||
usb_buf[0x12] = color_1_red;
|
||||
usb_buf[0x13] = color_1_green;
|
||||
usb_buf[0x14] = color_1_blue;
|
||||
usb_buf[0x15] = color_2_red;
|
||||
usb_buf[0x16] = color_2_green;
|
||||
usb_buf[0x17] = color_2_blue;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up temperatures |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x12] = (temperature_0 >> 8);
|
||||
usb_buf[0x13] = (temperature_0 & 0xFF);
|
||||
usb_buf[0x14] = (temperature_1 >> 8);
|
||||
usb_buf[0x15] = (temperature_1 & 0xFF);
|
||||
usb_buf[0x16] = (temperature_2 >> 8);
|
||||
usb_buf[0x17] = (temperature_2 & 0xFF);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairNodeProController::SendTemperature()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairNodeProController::SendReset
|
||||
(
|
||||
unsigned char channel
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Reset packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_RESET;
|
||||
usb_buf[0x01] = channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairNodeProController::SendPortState
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char state
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Port State packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE;
|
||||
usb_buf[0x01] = channel;
|
||||
usb_buf[0x02] = state;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairNodeProController::SendBrightness()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairNodeProController::SendLEDCount()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairNodeProController::SendProtocol()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,70 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_DIRECT = 0x32, /* Direct mode LED update packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_COMMIT = 0x33, /* Commit changes packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_BEGIN = 0x34, /* Begin effect packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG = 0x35, /* Effect mode configuration packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_TEMPERATURE = 0x36, /* Update temperature value packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_RESET = 0x37, /* Reset channel packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE = 0x38, /* Set port state packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_BRIGHTNESS = 0x39, /* Set brightness packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_LED_COUNT = 0x3A, /* Set LED count packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_PROTOCOL = 0x3B, /* Set protocol packet */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED = 0x00, /* Red channel for direct update */
|
||||
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN = 0x01, /* Green channel for direct update */
|
||||
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE = 0x02, /* Blue channel for direct update */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE = 0x01, /* Effect hardware control of channel */
|
||||
CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE = 0x02, /* Direct software control of channel */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP = 0x0A, /* Corsair LED Strip Type */
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_HD_FAN = 0x0C, /* Corsair HD-series Fan Type */
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_SP_FAN = 0x01, /* Corsair SP-series Fan Type */
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_ML_FAN = 0x02, /* Corsair ML-series Fan Type */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_CHANNEL_1 = 0x00, /* Channel 1 */
|
||||
CORSAIR_CMDR_PRO_CHANNEL_2 = 0x01, /* Channel 2 */
|
||||
CORSAIR_CMDR_PRO_NUM_CHANNELS = 0x02, /* Number of channels */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_SPEED_FAST = 0x00, /* Fast speed */
|
||||
CORSAIR_CMDR_PRO_SPEED_MEDIUM = 0x01, /* Medium speed */
|
||||
CORSAIR_CMDR_PRO_SPEED_SLOW = 0x02, /* Slow speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE = 0x00, /* Rainbow Wave mode */
|
||||
CORSAIR_CMDR_PRO_MODE_COLOR_SHIFT = 0x01, /* Color Shift mode */
|
||||
CORSAIR_CMDR_PRO_MODE_COLOR_PULSE = 0x02, /* Color Pulse mode */
|
||||
CORSAIR_CMDR_PRO_MODE_COLOR_WAVE = 0x03, /* Color Wave mode */
|
||||
CORSAIR_CMDR_PRO_MODE_STATIC = 0x04, /* Static mode */
|
||||
CORSAIR_CMDR_PRO_MODE_TEMPERATURE = 0x05, /* Temperature mode */
|
||||
CORSAIR_CMDR_PRO_MODE_VISOR = 0x06, /* Visor mode */
|
||||
CORSAIR_CMDR_PRO_MODE_MARQUEE = 0x07, /* Marquee mode */
|
||||
CORSAIR_CMDR_PRO_MODE_BLINK = 0x08, /* Blink mode */
|
||||
CORSAIR_CMDR_PRO_MODE_SEQUENTIAL = 0x09, /* Sequential mode */
|
||||
CORSAIR_CMDR_PRO_MODE_RAINBOW = 0x0A, /* Rainbow mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_NODE_PRO_CHANNEL_1 = 0x00, /* Channel 1 */
|
||||
@@ -25,13 +89,83 @@ public:
|
||||
|
||||
char* GetLEDString();
|
||||
unsigned int GetStripsOnChannel(unsigned int channel);
|
||||
void SetChannelEffect(unsigned int channel, unsigned int mode, std::vector<RGBColor> colors);
|
||||
void SetChannelLEDs(unsigned int channel, std::vector<RGBColor> colors);
|
||||
void SendKeepalive();
|
||||
|
||||
void SetChannelEffect(unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
bool random,
|
||||
unsigned char red1,
|
||||
unsigned char grn1,
|
||||
unsigned char blu1,
|
||||
unsigned char red2,
|
||||
unsigned char grn2,
|
||||
unsigned char blu2
|
||||
);
|
||||
|
||||
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
|
||||
unsigned int channel_leds[CORSAIR_NODE_PRO_NUM_CHANNELS];
|
||||
|
||||
void KeepaliveThread();
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
|
||||
void SendDirect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char start,
|
||||
unsigned char count,
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
);
|
||||
|
||||
void SendCommit();
|
||||
|
||||
void SendBegin
|
||||
(
|
||||
unsigned char channel
|
||||
);
|
||||
|
||||
void SendEffectConfig
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char count,
|
||||
unsigned char led_type,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
unsigned char change_style,
|
||||
unsigned char color_0_red,
|
||||
unsigned char color_0_green,
|
||||
unsigned char color_0_blue,
|
||||
unsigned char color_1_red,
|
||||
unsigned char color_1_green,
|
||||
unsigned char color_1_blue,
|
||||
unsigned char color_2_red,
|
||||
unsigned char color_2_green,
|
||||
unsigned char color_2_blue,
|
||||
unsigned short temperature_0,
|
||||
unsigned short temperature_1,
|
||||
unsigned short temperature_2
|
||||
);
|
||||
|
||||
void SendTemperature();
|
||||
|
||||
void SendReset
|
||||
(
|
||||
unsigned char channel
|
||||
);
|
||||
|
||||
void SendPortState
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char state
|
||||
);
|
||||
|
||||
void SendBrightness();
|
||||
|
||||
void SendLEDCount();
|
||||
|
||||
void SendProtocol();
|
||||
};
|
||||
|
||||
@@ -104,7 +104,17 @@ void CorsairProController::ApplyColors()
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x82, 0x02);
|
||||
}
|
||||
|
||||
void CorsairProController::SetEffect(unsigned char mode)
|
||||
void CorsairProController::SetEffect(unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
bool random,
|
||||
unsigned char red1,
|
||||
unsigned char grn1,
|
||||
unsigned char blu1,
|
||||
unsigned char red2,
|
||||
unsigned char grn2,
|
||||
unsigned char blu2
|
||||
)
|
||||
{
|
||||
effect_mode = mode;
|
||||
|
||||
@@ -113,17 +123,28 @@ void CorsairProController::SetEffect(unsigned char mode)
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
|
||||
Sleep(1);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, effect_mode); //Mode
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, CORSAIR_PRO_SPEED_MEDIUM); //Speed
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, CORSAIR_PRO_EFFECT_RANDOM_COLORS); //Custom color
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, CORSAIR_PRO_DIRECTION_UP); //Direction
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 1 red
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 1 green
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 1 blue
|
||||
unsigned char random_byte;
|
||||
|
||||
if(random)
|
||||
{
|
||||
random_byte = CORSAIR_PRO_EFFECT_RANDOM_COLORS;
|
||||
}
|
||||
else
|
||||
{
|
||||
random_byte = CORSAIR_PRO_EFFECT_CUSTOM_COLORS;
|
||||
}
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, effect_mode); //Mode
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, speed); //Speed
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, random_byte); //Custom color
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, direction); //Direction
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, red1); // Custom color 1 red
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, grn1); // Custom color 1 green
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, blu1); // Custom color 1 blue
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 2 red
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 2 green
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 2 blue
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, red2); // Custom color 2 red
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, grn2); // Custom color 2 green
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, blu2); // Custom color 2 blue
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
|
||||
@@ -138,11 +159,6 @@ void CorsairProController::SetEffect(unsigned char mode)
|
||||
WaitReady();
|
||||
}
|
||||
|
||||
void CorsairProController::SetCustom()
|
||||
{
|
||||
SetEffect(CORSAIR_PRO_MODE_STATIC);
|
||||
}
|
||||
|
||||
bool CorsairProController::WaitReady()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@@ -70,8 +70,17 @@ public:
|
||||
std::string GetDeviceLocation();
|
||||
unsigned int GetLEDCount();
|
||||
unsigned char GetEffect();
|
||||
void SetEffect(unsigned char mode);
|
||||
void SetCustom();
|
||||
void SetEffect(unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
bool random,
|
||||
unsigned char red1,
|
||||
unsigned char grn1,
|
||||
unsigned char blu1,
|
||||
unsigned char red2,
|
||||
unsigned char grn2,
|
||||
unsigned char blu2
|
||||
);
|
||||
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
@@ -6,6 +6,17 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForCorsairProController *
|
||||
@@ -24,20 +35,6 @@ bool TestForCorsairProController(i2c_smbus_interface* bus, unsigned char address
|
||||
{
|
||||
pass = true;
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x24);
|
||||
|
||||
if (res != 0x02)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x25);
|
||||
|
||||
if (res != 0x02)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x43);
|
||||
|
||||
if (res != 0x1C)
|
||||
@@ -53,6 +50,8 @@ bool TestForCorsairProController(i2c_smbus_interface* bus, unsigned char address
|
||||
}
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForCorsairProController() */
|
||||
|
||||
@@ -19,6 +19,9 @@ Hue2Controller::Hue2Controller(libusb_device_handle* dev_handle)
|
||||
|
||||
Hue2Controller::~Hue2Controller()
|
||||
{
|
||||
current_mode = HUE_2_MODE_FIXED;
|
||||
current_speed = HUE_2_SPEED_NORMAL;
|
||||
current_direction = false;
|
||||
}
|
||||
|
||||
unsigned int Hue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
|
||||
@@ -82,7 +85,14 @@ unsigned int Hue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
|
||||
return(ret_val);
|
||||
}
|
||||
|
||||
void Hue2Controller::SetChannelEffect(unsigned int channel, unsigned int mode, std::vector<RGBColor> colors)
|
||||
void Hue2Controller::SetMode(unsigned char mode, unsigned char speed, bool direction)
|
||||
{
|
||||
current_mode = mode;
|
||||
current_speed = speed;
|
||||
current_direction = direction;
|
||||
}
|
||||
|
||||
void Hue2Controller::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
@@ -113,8 +123,18 @@ void Hue2Controller::SetChannelEffect(unsigned int channel, unsigned int mode, s
|
||||
/*-----------------------------------------------------*\
|
||||
| Set mode in USB packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x04] = mode;
|
||||
usb_buf[0x04] = current_mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set speed in USB packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x05] = current_speed;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set direction in USB packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x06] = current_direction ? 0x01 : 0x00;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set color count in USB packet |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -134,110 +154,4 @@ void Hue2Controller::SetChannelEffect(unsigned int channel, unsigned int mode, s
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void Hue2Controller::SetChannelLEDs(unsigned int channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x22, 0x10, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
unsigned char usb_apply[] =
|
||||
{
|
||||
0x22, 0xA0, 0x01, 0x00,
|
||||
0x01, 0x00, 0x00, 0x28,
|
||||
0x00, 0x00, 0x80, 0x00,
|
||||
0x32, 0x00, 0x00, 0x01,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
int actual;
|
||||
|
||||
std::size_t pkt_max = 20;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set channel in USB packets |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x02] = 1 << channel;
|
||||
usb_apply[0x02] = 1 << channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send first packet for first 20 LEDs |
|
||||
\*-----------------------------------------------------*/
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = colors.size();
|
||||
}
|
||||
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
int pixel_idx = idx * 3;
|
||||
RGBColor color = colors[idx];
|
||||
usb_buf[pixel_idx + 4] = RGBGetGValue(color);
|
||||
usb_buf[pixel_idx + 5] = RGBGetRValue(color);
|
||||
usb_buf[pixel_idx + 6] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send second packet for second 20 LEDs if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int idx = 4; idx < 64; idx++)
|
||||
{
|
||||
usb_buf[idx] = 0;
|
||||
}
|
||||
|
||||
usb_buf[0x01] = 0x11;
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 20)
|
||||
{
|
||||
pkt_max = colors.size() - 20;
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
int pixel_idx = idx * 3;
|
||||
RGBColor color = colors[idx + 20];
|
||||
usb_buf[pixel_idx + 4] = RGBGetGValue(color);
|
||||
usb_buf[pixel_idx + 5] = RGBGetRValue(color);
|
||||
usb_buf[pixel_idx + 6] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send apply packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_apply, 64, &actual, 0);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,15 @@ enum
|
||||
HUE_2_CHANNEL_4_IDX = 0x01, /* Channel 4 array index */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HUE_2_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
HUE_2_SPEED_SLOW = 0x01, /* Slow speed */
|
||||
HUE_2_SPEED_NORMAL = 0x02, /* Normal speed */
|
||||
HUE_2_SPEED_FAST = 0x03, /* Fast speed */
|
||||
HUE_2_SPEED_FASTEST = 0x04, /* Fastest speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HUE_2_MODE_FIXED = 0x00, /* Fixed colors mode */
|
||||
@@ -49,11 +58,15 @@ public:
|
||||
|
||||
char* GetLEDString();
|
||||
unsigned int GetStripsOnChannel(unsigned int channel);
|
||||
void SetChannelEffect(unsigned int channel, unsigned int mode, std::vector<RGBColor> colors);
|
||||
void SetChannelLEDs(unsigned int channel, std::vector<RGBColor> colors);
|
||||
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
|
||||
void SetMode(unsigned char mode, unsigned char speed, bool direction);
|
||||
|
||||
unsigned int channel_leds[HUE_2_NUM_CHANNELS];
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
|
||||
unsigned char current_mode;
|
||||
unsigned char current_speed;
|
||||
bool current_direction;
|
||||
};
|
||||
|
||||
@@ -24,16 +24,18 @@ static void Sleep(unsigned int milliseconds)
|
||||
|
||||
HuePlusController::HuePlusController()
|
||||
{
|
||||
|
||||
current_mode = HUE_PLUS_MODE_FIXED;
|
||||
current_speed = HUE_PLUS_SPEED_NORMAL;
|
||||
current_direction = false;
|
||||
}
|
||||
|
||||
HuePlusController::~HuePlusController()
|
||||
{
|
||||
}
|
||||
|
||||
void HuePlusController::Initialize(char* port_name)
|
||||
void HuePlusController::Initialize(char* port)
|
||||
{
|
||||
strcpy(led_string, port_name);
|
||||
strcpy(port_name, port);
|
||||
|
||||
serialport = new serial_port(port_name, HUE_PLUS_BAUD);
|
||||
|
||||
@@ -41,9 +43,9 @@ void HuePlusController::Initialize(char* port_name)
|
||||
channel_leds[HUE_PLUS_CHANNEL_2_IDX] = GetLEDsOnChannel(HUE_PLUS_CHANNEL_2);
|
||||
}
|
||||
|
||||
char* HuePlusController::GetLEDString()
|
||||
char* HuePlusController::GetLocation()
|
||||
{
|
||||
return(led_string);
|
||||
return(port_name);
|
||||
}
|
||||
|
||||
unsigned int HuePlusController::GetLEDsOnChannel(unsigned int channel)
|
||||
@@ -68,7 +70,6 @@ unsigned int HuePlusController::GetLEDsOnChannel(unsigned int channel)
|
||||
|
||||
int bytes_read = serialport->serial_read((char *)serial_buf, 5);
|
||||
|
||||
printf("%x %x %x %x %x \r\n", serial_buf[0], serial_buf[1], serial_buf[2], serial_buf[3], serial_buf[4]);
|
||||
if(bytes_read == 5)
|
||||
{
|
||||
if(serial_buf[3] == 0x01)
|
||||
@@ -84,7 +85,14 @@ unsigned int HuePlusController::GetLEDsOnChannel(unsigned int channel)
|
||||
return(ret_val);
|
||||
}
|
||||
|
||||
void HuePlusController::SetChannelEffect(unsigned int channel, unsigned int mode, std::vector<RGBColor> colors)
|
||||
void HuePlusController::SetMode(unsigned char mode, unsigned char speed, bool direction)
|
||||
{
|
||||
current_mode = mode;
|
||||
current_speed = speed;
|
||||
current_direction = direction;
|
||||
}
|
||||
|
||||
void HuePlusController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char serial_buf[] =
|
||||
{
|
||||
@@ -130,7 +138,18 @@ void HuePlusController::SetChannelEffect(unsigned int channel, unsigned int mode
|
||||
/*-----------------------------------------------------*\
|
||||
| Set mode in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x02] = mode;
|
||||
serial_buf[0x02] = current_mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set options bitfield in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x03] = 0;
|
||||
serial_buf[0x03] |= current_direction ? ( 1 << 4 ) : 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set speed in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x04] = current_speed;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
@@ -148,70 +167,4 @@ void HuePlusController::SetChannelEffect(unsigned int channel, unsigned int mode
|
||||
serialport->serial_flush_tx();
|
||||
|
||||
Sleep(10);
|
||||
}
|
||||
|
||||
void HuePlusController::SetChannelLEDs(unsigned int channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char serial_buf[] =
|
||||
{
|
||||
0x4B, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set channel in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x01] = channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set mode in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x02] = HUE_PLUS_MODE_FIXED;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for (unsigned int idx = 0; idx < (colors.size() * 3); idx += 3)
|
||||
{
|
||||
int pixel_idx = idx / 3;
|
||||
RGBColor color = colors[pixel_idx];
|
||||
serial_buf[idx + 5] = RGBGetGValue(color);
|
||||
serial_buf[idx + 6] = RGBGetRValue(color);
|
||||
serial_buf[idx + 7] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
serialport->serial_write((char *)serial_buf, HUE_PLUS_PACKET_SIZE);
|
||||
serialport->serial_flush_tx();
|
||||
|
||||
Sleep(10);
|
||||
}
|
||||
}
|
||||
@@ -41,10 +41,27 @@ enum
|
||||
|
||||
enum
|
||||
{
|
||||
HUE_PLUS_MODE_FIXED = 0x00, /* Fixed colors mode */
|
||||
HUE_PLUS_MODE_FADING = 0x01, /* Fading mode */
|
||||
HUE_PLUS_MODE_SPECTRUM = 0x02, /* Spectrum cycle mode */
|
||||
HUE_PLUS_NUM_MODES /* Number of Hue Plus modes */
|
||||
HUE_PLUS_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
HUE_PLUS_SPEED_SLOW = 0x01, /* Slow speed */
|
||||
HUE_PLUS_SPEED_NORMAL = 0x02, /* Normal speed */
|
||||
HUE_PLUS_SPEED_FAST = 0x03, /* Fast speed */
|
||||
HUE_PLUS_SPEED_FASTEST = 0x04, /* Fastest speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HUE_PLUS_MODE_FIXED = 0x00, /* Fixed colors mode */
|
||||
HUE_PLUS_MODE_FADING = 0x01, /* Fading mode */
|
||||
HUE_PLUS_MODE_SPECTRUM = 0x02, /* Spectrum cycle mode */
|
||||
HUE_PLUS_MODE_MARQUEE = 0x03, /* Marquee mode */
|
||||
HUE_PLUS_MODE_COVER_MARQUEE = 0x04, /* Cover marquee mode */
|
||||
HUE_PLUS_MODE_ALTERNATING = 0x05, /* Alternating mode */
|
||||
HUE_PLUS_MODE_PULSING = 0x06, /* Pulsing mode */
|
||||
HUE_PLUS_MODE_BREATHING = 0x07, /* Breathing mode */
|
||||
HUE_PLUS_MODE_ALERT = 0x08, /* Alert mode */
|
||||
HUE_PLUS_MODE_CANDLELIGHT = 0x09, /* Candlelight mode */
|
||||
HUE_PLUS_MODE_WINGS = 0x0C, /* Wings mode */
|
||||
HUE_PLUS_MODE_WAVE = 0x0D, /* Wave mode */
|
||||
};
|
||||
|
||||
class HuePlusController
|
||||
@@ -53,18 +70,21 @@ public:
|
||||
HuePlusController();
|
||||
~HuePlusController();
|
||||
|
||||
void Initialize(char* port_name);
|
||||
char* GetLEDString();
|
||||
void Initialize(char* port);
|
||||
char* GetLocation();
|
||||
unsigned int GetLEDsOnChannel(unsigned int channel);
|
||||
void SetChannelEffect(unsigned int channel, unsigned int mode, std::vector<RGBColor> colors);
|
||||
void SetChannelLEDs(unsigned int channel, std::vector<RGBColor> colors);
|
||||
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
|
||||
void SetMode(unsigned char mode, unsigned char speed, bool direction);
|
||||
|
||||
unsigned int channel_leds[HUE_PLUS_NUM_CHANNELS];
|
||||
|
||||
private:
|
||||
char led_string[1024];
|
||||
char port_name[128];
|
||||
serial_port *serialport;
|
||||
char port_name[128];
|
||||
serial_port *serialport;
|
||||
|
||||
unsigned char current_mode;
|
||||
unsigned char current_speed;
|
||||
bool current_direction;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* DetectHuePlusControllers *
|
||||
* *
|
||||
* Detect devices supported by the HuePlus driver *
|
||||
* * *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectHuePlusControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
|
||||
@@ -109,7 +109,7 @@ void HyperXController::SetAllColors(unsigned char red, unsigned char green, unsi
|
||||
|
||||
if(mode == HYPERX_MODE_DIRECT)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE3, HYPERX_MODE3_DIRECT);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE_INDEPENDENT, HYPERX_MODE3_DIRECT);
|
||||
}
|
||||
|
||||
for(int led = 0; led < 5; led++)
|
||||
@@ -194,48 +194,91 @@ void HyperXController::SetLEDColor(unsigned int slot, unsigned int led, unsigned
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
|
||||
}
|
||||
|
||||
void HyperXController::SetMode(unsigned char new_mode)
|
||||
void HyperXController::SetMode(unsigned char new_mode, bool random, unsigned short new_speed)
|
||||
{
|
||||
mode = new_mode;
|
||||
mode = new_mode;
|
||||
speed = new_speed;
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Determine which mode register to use. |
|
||||
| If set to random color mode, use Mode1. |
|
||||
| If set to fixed color mode, use Mode2. |
|
||||
\*-----------------------------------------------------*/
|
||||
unsigned char mode_reg;
|
||||
|
||||
if(random)
|
||||
{
|
||||
mode_reg = HYPERX_REG_MODE_RANDOM;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode_reg = HYPERX_REG_MODE_CUSTOM;
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case HYPERX_MODE_DIRECT:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE3, HYPERX_MODE3_DIRECT);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE_INDEPENDENT, HYPERX_MODE3_DIRECT);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_STATIC:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_STATIC);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE_CUSTOM, HYPERX_MODE2_STATIC);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_RAINBOW:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE1, HYPERX_MODE1_RAINBOW);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE_RANDOM, HYPERX_MODE1_RAINBOW);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_LSB, speed & 0xFF);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_COMET:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_COMET);
|
||||
bus->i2c_smbus_write_byte_data(dev, mode_reg, HYPERX_MODE2_COMET);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_LSB, speed & 0xFF);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_HEARTBEAT:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_HEARTBEAT);
|
||||
bus->i2c_smbus_write_byte_data(dev, mode_reg, HYPERX_MODE2_HEARTBEAT);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_LSB, speed & 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_LSB, speed & 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_DELAY_TIME_MSB, 0x03);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_DELAY_TIME_LSB, 0xE8);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_CYCLE:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE1, HYPERX_MODE1_CYCLE);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE_RANDOM, HYPERX_MODE1_CYCLE);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_LSB, speed & 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_CHANGE_TIME_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_CHANGE_TIME_LSB, speed & 0xFF);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_BREATHING:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_BREATHING);
|
||||
bus->i2c_smbus_write_byte_data(dev, mode_reg, HYPERX_MODE2_BREATHING);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_FADE_IN_TIME_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_FADE_IN_TIME_LSB, speed & 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_FADE_OUT_TIME_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_FADE_OUT_TIME_LSB, speed & 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_MSB, 0x00);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_LSB, 0x00);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_BOUNCE:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_BOUNCE);
|
||||
bus->i2c_smbus_write_byte_data(dev, mode_reg, HYPERX_MODE2_BOUNCE);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_LSB, speed & 0xFF);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_BLINK:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_BLINK);
|
||||
bus->i2c_smbus_write_byte_data(dev, mode_reg, HYPERX_MODE2_BLINK);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_MSB, speed >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_LSB, speed & 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_MSB, 0x07);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_LSB, 0xD4);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,11 +101,25 @@ enum
|
||||
HYPERX_REG_SLOT3_LED3_BRIGHTNESS = 0xBA, /* Brightness for LED 3, Slot 3 (0-100) */
|
||||
HYPERX_REG_SLOT3_LED4_BRIGHTNESS = 0xBD, /* Brightness for LED 4, Slot 3 (0-100) */
|
||||
|
||||
HYPERX_REG_TIMER_MSB = 0xD1, /* Timer MSB */
|
||||
HYPERX_REG_TIMER_LSB = 0xD2, /* Timer LSB */
|
||||
HYPERX_REG_ON_TIME_MSB = 0xD3, /* Effect on time MSB */
|
||||
HYPERX_REG_ON_TIME_LSB = 0xD4, /* Effect on time LSB */
|
||||
HYPERX_REG_CHANGE_TIME_MSB = 0xD5, /* Change time MSB */
|
||||
HYPERX_REG_CHANGE_TIME_LSB = 0xD6, /* Change time LSB */
|
||||
HYPERX_REG_FADE_IN_TIME_MSB = 0xD7, /* Fade in time MSB */
|
||||
HYPERX_REG_FADE_IN_TIME_LSB = 0xD8, /* Fade in time LSB */
|
||||
HYPERX_REG_FADE_OUT_TIME_MSB = 0xD9, /* Fade out time MSB */
|
||||
HYPERX_REG_FADE_OUT_TIME_LSB = 0xDA, /* Fade out time LSB */
|
||||
HYPERX_REG_OFF_TIME_MSB = 0xDB, /* Effect off time MSB */
|
||||
HYPERX_REG_OFF_TIME_LSB = 0xDC, /* Effect off time LSB */
|
||||
HYPERX_REG_EFFECT_BRIGHTNESS = 0xDD, /* Brightness for effects (0-100) */
|
||||
HYPERX_REG_APPLY = 0xE1, /* Apply changes register */
|
||||
HYPERX_REG_MODE1 = 0xE3, /* Mode control register 1 */
|
||||
HYPERX_REG_MODE2 = 0xE4, /* Mode control register 2 */
|
||||
HYPERX_REG_MODE3 = 0xE5, /* Mode control register 3 */
|
||||
HYPERX_REG_MODE_RANDOM = 0xE3, /* Mode control register, random colors */
|
||||
HYPERX_REG_MODE_CUSTOM = 0xE4, /* Mode control register, custom colors */
|
||||
HYPERX_REG_MODE_INDEPENDENT = 0xE5, /* Mode control register, independent */
|
||||
HYPERX_REG_DELAY_TIME_MSB = 0xEA, /* Delay time MSB */
|
||||
HYPERX_REG_DELAY_TIME_LSB = 0xEB, /* Delay time LSB */
|
||||
HYPERX_REG_EFFECT_RED = 0xEC, /* Red color register for effects */
|
||||
HYPERX_REG_EFFECT_GREEN = 0xED, /* Green color register for effects */
|
||||
HYPERX_REG_EFFECT_BLUE = 0xEE, /* Blue color register for effects */
|
||||
@@ -146,6 +160,31 @@ enum
|
||||
HYPERX_NUMBER_MODES /* Number of HyperX modes */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_SPEED_BOUNCE_SLOW = 0x07D0, /* Slowest speed for bounce mode */
|
||||
HYPERX_SPEED_BOUNCE_NORMAL = 0x07D0, /* Normal speed for bounce mode */
|
||||
HYPERX_SPEED_BOUNCE_FAST = 0x0064, /* Fastest speed for bounce mode */
|
||||
HYPERX_SPEED_BREATHING_SLOW = 0x07D0, /* Slowest speed for breathing mode */
|
||||
HYPERX_SPEED_BREATHING_NORMAL = 0x07D0, /* Normal speed for breathing mode */
|
||||
HYPERX_SPEED_BREATHING_FAST = 0x0064, /* Fastest speed for breathing mode */
|
||||
HYPERX_SPEED_CYCLE_SLOW = 0x05DC, /* Slowest speed for cycle mode */
|
||||
HYPERX_SPEED_CYCLE_NORMAL = 0x05DC, /* Normal speed for cycle mode */
|
||||
HYPERX_SPEED_CYCLE_FAST = 0x00FA, /* Fastest speed for cycle mode */
|
||||
HYPERX_SPEED_RAINBOW_SLOW = 0x07D0, /* Slowest speed for rainbow mode */
|
||||
HYPERX_SPEED_RAINBOW_NORMAL = 0x07D0, /* Normal speed for rainbow mode */
|
||||
HYPERX_SPEED_RAINBOW_FAST = 0x0064, /* Fastest speed for rainbow mode */
|
||||
HYPERX_SPEED_BLINK_SLOW = 0x07D0, /* Slowest speed for blink mode */
|
||||
HYPERX_SPEED_BLINK_NORMAL = 0x07D0, /* Normal speed for blink mode */
|
||||
HYPERX_SPEED_BLINK_FAST = 0x01F4, /* Fastest speed for blink mode */
|
||||
HYPERX_SPEED_HEARTBEAT_SLOW = 0x07D0, /* Slowest speed for heartbeat mode */
|
||||
HYPERX_SPEED_HEARTBEAT_NORMAL = 0x07D0, /* Normal speed for heartbeat mode */
|
||||
HYPERX_SPEED_HEARTBEAT_FAST = 0x01F4, /* Fastest speed for heartbeat mode */
|
||||
HYPERX_SPEED_COMET_SLOW = 0x07D0, /* Slowest speed for comet mode */
|
||||
HYPERX_SPEED_COMET_NORMAL = 0x07D0, /* Normal speed for comet mode */
|
||||
HYPERX_SPEED_COMET_FAST = 0x0064, /* Fastest speed for comet mode */
|
||||
};
|
||||
|
||||
static const unsigned char slot_base[4] =
|
||||
{
|
||||
HYPERX_REG_SLOT0_LED0_RED, /* SPD 0x50 maps to slot 0 */
|
||||
@@ -165,7 +204,7 @@ public:
|
||||
unsigned int GetLEDCount();
|
||||
unsigned int GetSlotCount();
|
||||
unsigned int GetMode();
|
||||
void SetMode(unsigned char new_mode);
|
||||
void SetMode(unsigned char new_mode, bool random, unsigned short new_speed);
|
||||
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetEffectColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
@@ -179,4 +218,5 @@ private:
|
||||
i2c_smbus_interface* bus;
|
||||
hyperx_dev_id dev;
|
||||
unsigned int mode;
|
||||
unsigned short speed;
|
||||
};
|
||||
|
||||
@@ -85,7 +85,7 @@ void PatriotViperController::SetEffectColor(unsigned char red, unsigned char gre
|
||||
ViperRegisterWrite(VIPER_REG_LED3_EFFECT_COLOR, red, blue, green);
|
||||
ViperRegisterWrite(VIPER_REG_LED4_EFFECT_COLOR, red, blue, green);
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, 0x0C);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, speed);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
|
||||
}
|
||||
@@ -121,7 +121,7 @@ void PatriotViperController::SetLEDEffectColor(unsigned int led, unsigned char r
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_LED0_EFFECT_COLOR + led, red, blue, green);
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, 0x0C);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, speed);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
|
||||
}
|
||||
@@ -143,19 +143,20 @@ void PatriotViperController::SetLEDEffectColor(unsigned int slot, unsigned int l
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_LED0_EFFECT_COLOR + led, red, blue, green);
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, 0x0C);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, speed);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
|
||||
}
|
||||
|
||||
void PatriotViperController::SetMode(unsigned char new_mode)
|
||||
void PatriotViperController::SetMode(unsigned char new_mode, unsigned char new_speed)
|
||||
{
|
||||
direct = false;
|
||||
mode = new_mode;
|
||||
mode = new_mode;
|
||||
speed = new_speed;
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, new_mode, 0x00, 0x0C);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, speed);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,16 @@ enum
|
||||
VIPER_MODE_NEON = 0x08, /* Neon mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
VIPER_SPEED_MIN = 0xC8, /* Slowest speed for non-breathing mode */
|
||||
VIPER_SPEED_DEFAULT = 0x64, /* Default speed for non-breathing mode */
|
||||
VIPER_SPEED_MAX = 0x14, /* Fastest speed for non-breathing mode */
|
||||
VIPER_SPEED_BREATHING_MIN = 0xFF, /* Slowest speed for breathing mode */
|
||||
VIPER_SPEED_BREATHING_DEFAULT = 0x0C, /* Default speed for breathing mode */
|
||||
VIPER_SPEED_BREATHING_MAX = 0x00, /* Fastest speed for breathing mode */
|
||||
};
|
||||
|
||||
class PatriotViperController
|
||||
{
|
||||
public:
|
||||
@@ -56,7 +66,7 @@ public:
|
||||
unsigned int GetLEDCount();
|
||||
unsigned int GetSlotCount();
|
||||
unsigned int GetMode();
|
||||
void SetMode(unsigned char new_mode);
|
||||
void SetMode(unsigned char new_mode, unsigned char new_speed);
|
||||
void SetDirect();
|
||||
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
@@ -75,5 +85,6 @@ private:
|
||||
unsigned char slots_valid;
|
||||
i2c_smbus_interface* bus;
|
||||
viper_dev_id dev;
|
||||
unsigned int mode;
|
||||
unsigned char mode;
|
||||
unsigned char speed;
|
||||
};
|
||||
|
||||
@@ -102,11 +102,13 @@ void RGBFusionController::SetLEDColor(unsigned int led, unsigned char red, unsig
|
||||
}
|
||||
}
|
||||
|
||||
void RGBFusionController::SetMode(unsigned char mode)
|
||||
void RGBFusionController::SetMode(unsigned char mode, unsigned char speed)
|
||||
{
|
||||
switch_bank(0);
|
||||
set_mode_ch_0(mode);
|
||||
set_timers_ch_0(speed_table[0][speed], speed_table[1][speed]);
|
||||
set_mode_ch_1(mode);
|
||||
set_timers_ch_1(speed_table[0][speed], speed_table[1][speed]);
|
||||
}
|
||||
|
||||
void RGBFusionController::dump()
|
||||
@@ -170,6 +172,22 @@ void RGBFusionController::set_mode_ch_1(unsigned char mode)
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_MODE, mode + RGB_FUSION_WRITE_MODE_OFST);
|
||||
}
|
||||
|
||||
void RGBFusionController::set_timers_ch_0(unsigned short timer0, unsigned short timer1)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_TIMER_0_MSB, timer0 >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_TIMER_0_LSB, timer0 & 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_TIMER_1_MSB, timer1 >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_TIMER_1_LSB, timer1 & 0xFF);
|
||||
}
|
||||
|
||||
void RGBFusionController::set_timers_ch_1(unsigned short timer0, unsigned short timer1)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_TIMER_0_MSB, timer0 >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_TIMER_0_LSB, timer0 & 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_TIMER_1_MSB, timer1 >> 8);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_TIMER_1_LSB, timer1 & 0xFF);
|
||||
}
|
||||
|
||||
void RGBFusionController::switch_bank(unsigned char bank)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_SWITCH_REG, bank);
|
||||
|
||||
@@ -17,7 +17,23 @@ typedef unsigned char rgb_fusion_dev_id;
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_BANK_0_REG_CH_0_MODE = 0x03, /* Channel 0 Mode Selection */
|
||||
RGB_FUSION_BANK_0_REG_CH_0_TIMER_0_MSB
|
||||
= 0x06, /* Channel 0 Timer 0 MSB */
|
||||
RGB_FUSION_BANK_0_REG_CH_0_TIMER_0_LSB
|
||||
= 0x07, /* Channel 0 Timer 0 LSB */
|
||||
RGB_FUSION_BANK_0_REG_CH_0_TIMER_1_MSB
|
||||
= 0x08, /* Channel 0 Timer 1 MSB */
|
||||
RGB_FUSION_BANK_0_REG_CH_0_TIMER_1_LSB
|
||||
= 0x09, /* Channel 0 Timer 1 LSB */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_MODE = 0x13, /* Channel 1 Mode Selection */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_TIMER_0_MSB
|
||||
= 0x16, /* Channel 1 Timer 0 MSB */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_TIMER_0_LSB
|
||||
= 0x17, /* Channel 1 Timer 0 LSB */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_TIMER_1_MSB
|
||||
= 0x18, /* Channel 1 Timer 1 MSB */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_TIMER_1_LSB
|
||||
= 0x19, /* Channel 1 Timer 1 LSB */
|
||||
RGB_FUSION_BANK_1_REG_CH_0_R = 0x00, /* Channel 0 Red Value */
|
||||
RGB_FUSION_BANK_1_REG_CH_0_G = 0x01, /* Channel 0 Green Value */
|
||||
RGB_FUSION_BANK_1_REG_CH_0_B = 0x02, /* Channel 0 Blue Value */
|
||||
@@ -27,6 +43,19 @@ enum
|
||||
RGB_FUSION_BANK_SWITCH_REG = 0xF0, /* Bank Switch Register */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_SPEED_SLOW = 0x00, /* Slowest speed */
|
||||
RGB_FUSION_SPEED_NORMAL = 0x01, /* Normal speed */
|
||||
RGB_FUSION_SPEED_FAST = 0x02, /* Fastest speed */
|
||||
};
|
||||
|
||||
static const short speed_table[2][3] =
|
||||
{
|
||||
{ 0x01E0, 0x00F0, 0x0078 },
|
||||
{ 0x4000, 0x2000, 0x1000 }
|
||||
};
|
||||
|
||||
#define RGB_FUSION_NUMBER_MODES 3 /* Number of RGB Fusion modes */
|
||||
#define RGB_FUSION_WRITE_MODE_OFST 0x10 /* offset to add when writing mode */
|
||||
|
||||
@@ -49,7 +78,7 @@ public:
|
||||
unsigned char GetMode();
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetMode(unsigned char mode);
|
||||
void SetMode(unsigned char mode, unsigned char speed);
|
||||
|
||||
private:
|
||||
void dump();
|
||||
@@ -61,6 +90,8 @@ private:
|
||||
void set_color_ch_1(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void set_mode_ch_0(unsigned char mode);
|
||||
void set_mode_ch_1(unsigned char mode);
|
||||
void set_timers_ch_0(unsigned short timer0, unsigned short timer1);
|
||||
void set_timers_ch_1(unsigned short timer0, unsigned short timer1);
|
||||
void switch_bank(unsigned char bank);
|
||||
|
||||
char device_name[32];
|
||||
|
||||
@@ -334,6 +334,7 @@ void DetectAMDWraithPrismControllers(std::vector<RGBController*>& rgb_controller
|
||||
void DetectAorusGPUControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectMSI3ZoneControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectPoseidonZRGBControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectCorsairCmdrProControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectCorsairNodeProControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
|
||||
/******************************************************************************************\
|
||||
@@ -363,6 +364,7 @@ void DetectRGBControllers(void)
|
||||
DetectAMDWraithPrismControllers(rgb_controllers);
|
||||
DetectMSI3ZoneControllers(rgb_controllers);
|
||||
DetectPoseidonZRGBControllers(rgb_controllers);
|
||||
DetectCorsairCmdrProControllers(rgb_controllers);
|
||||
DetectCorsairNodeProControllers(rgb_controllers);
|
||||
|
||||
DetectE131Controllers(rgb_controllers);
|
||||
|
||||
@@ -14,6 +14,7 @@ INCLUDEPATH += \
|
||||
Controllers/AMDWraithPrismController/ \
|
||||
Controllers/AuraController/ \
|
||||
Controllers/CorsairController/ \
|
||||
Controllers/CorsairCmdrProController/ \
|
||||
Controllers/CorsairNodeProController/ \
|
||||
Controllers/CorsairProController/ \
|
||||
Controllers/Hue2Controller/ \
|
||||
@@ -48,6 +49,8 @@ SOURCES += \
|
||||
Controllers/AuraController/AuraControllerDetect.cpp \
|
||||
Controllers/CorsairController/CorsairController.cpp \
|
||||
Controllers/CorsairController/CorsairControllerDetect.cpp \
|
||||
Controllers/CorsairCmdrProController/CorsairCmdrProController.cpp \
|
||||
Controllers/CorsairCmdrProController/CorsairCmdrProControllerDetect.cpp \
|
||||
Controllers/CorsairNodeProController/CorsairNodeProController.cpp \
|
||||
Controllers/CorsairNodeProController/CorsairNodeProControllerDetect.cpp \
|
||||
Controllers/CorsairProController/CorsairProController.cpp \
|
||||
@@ -75,6 +78,7 @@ SOURCES += \
|
||||
RGBController/RGBController_AMDWraithPrism.cpp \
|
||||
RGBController/RGBController_Aura.cpp \
|
||||
RGBController/RGBController_Corsair.cpp \
|
||||
RGBController/RGBController_CorsairCmdrPro.cpp \
|
||||
RGBController/RGBController_CorsairNodePro.cpp \
|
||||
RGBController/RGBController_CorsairPro.cpp \
|
||||
RGBController/RGBController_Hue2.cpp \
|
||||
@@ -102,6 +106,7 @@ HEADERS += \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismController.h \
|
||||
Controllers/AuraController/AuraController.h \
|
||||
Controllers/CorsairController/CorsairController.h \
|
||||
Controllers/CorsairCmdrProController/CorsairCmdrProController.h \
|
||||
Controllers/CorsairNodeProController/CorsairNodeProController.h \
|
||||
Controllers/CorsairProController/CorsairProController.h \
|
||||
Controllers/Hue2Controller/Hue2Controller.h \
|
||||
@@ -117,6 +122,7 @@ HEADERS += \
|
||||
RGBController/RGBController_AMDWraithPrism.h \
|
||||
RGBController/RGBController_Aura.h \
|
||||
RGBController/RGBController_Corsair.h \
|
||||
RGBController/RGBController_CorsairCmdrPro.h \
|
||||
RGBController/RGBController_CorsairNodePro.h \
|
||||
RGBController/RGBController_CorsairPro.h \
|
||||
RGBController/RGBController_E131.h \
|
||||
|
||||
@@ -44,3 +44,15 @@ void RGBController::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
|
||||
UpdateZoneLEDs(zone);
|
||||
}
|
||||
|
||||
int RGBController::GetMode()
|
||||
{
|
||||
return(active_mode);
|
||||
}
|
||||
|
||||
void RGBController::SetMode(int mode)
|
||||
{
|
||||
active_mode = mode;
|
||||
|
||||
UpdateMode();
|
||||
}
|
||||
@@ -20,16 +20,61 @@ typedef unsigned int RGBColor;
|
||||
|
||||
#define ToRGBColor(r, g, b) ((b << 16) | (g << 8) | (r))
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
| Mode Flags |
|
||||
\*------------------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
MODE_FLAG_HAS_SPEED = (1 << 0), /* Mode has speed parameter */
|
||||
MODE_FLAG_HAS_DIRECTION_LR = (1 << 1), /* Mode has left/right parameter */
|
||||
MODE_FLAG_HAS_DIRECTION_UD = (1 << 2), /* Mode has up/down parameter */
|
||||
MODE_FLAG_HAS_DIRECTION_HV = (1 << 3), /* Mode has horiz/vert parameter */
|
||||
MODE_FLAG_HAS_BRIGHTNESS = (1 << 4), /* Mode has brightness parameter */
|
||||
MODE_FLAG_HAS_COLOR = (1 << 5), /* Mode has custom color parameter */
|
||||
MODE_FLAG_RANDOM_COLOR = (1 << 6), /* Mode has random color option */
|
||||
MODE_FLAG_PER_LED_COLOR = (1 << 7), /* Mode uses device LED colors */
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
| Mode Directions |
|
||||
\*------------------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
MODE_DIRECTION_LEFT = 0, /* Mode direction left */
|
||||
MODE_DIRECTION_RIGHT = 1, /* Mode direction right */
|
||||
MODE_DIRECTION_UP = 2, /* Mode direction up */
|
||||
MODE_DIRECTION_DOWN = 3, /* Mode direction down */
|
||||
MODE_DIRECTION_HORIZONTAL = 4, /* Mode direction horizontal */
|
||||
MODE_DIRECTION_VERTICAL = 5, /* Mode direction vertical */
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
| Mode Type |
|
||||
\*------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
/*--------------------------------------------------------------*\
|
||||
| Mode Information |
|
||||
\*--------------------------------------------------------------*/
|
||||
std::string name; /* Mode name */
|
||||
int value; /* Device-specific mode value */
|
||||
unsigned int flags; /* Mode flags bitfield */
|
||||
unsigned int speed_min; /* speed minimum value */
|
||||
unsigned int speed_max; /* speed maximum value */
|
||||
|
||||
/*--------------------------------------------------------------*\
|
||||
| Mode Settings |
|
||||
\*--------------------------------------------------------------*/
|
||||
unsigned int speed; /* Mode speed parameter value */
|
||||
unsigned int direction; /* Mode direction value */
|
||||
bool random; /* Random color mode enabled */
|
||||
} mode;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name; /* LED name */
|
||||
} led;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name; /* Mode name */
|
||||
} mode;
|
||||
|
||||
typedef int zone_type;
|
||||
|
||||
enum
|
||||
@@ -76,6 +121,7 @@ public:
|
||||
std::vector<mode> modes; /* Modes */
|
||||
std::vector<RGBColor> colors; /* Color buffer */
|
||||
device_type type; /* device type */
|
||||
int active_mode = 0;/* active mode */
|
||||
|
||||
virtual ~RGBController() = default;
|
||||
|
||||
@@ -87,13 +133,16 @@ public:
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Functions to be implemented in device implementation |
|
||||
\*---------------------------------------------------------*/
|
||||
virtual int GetMode() = 0;
|
||||
virtual void SetMode(int mode) = 0;
|
||||
virtual void SetCustomMode() = 0;
|
||||
virtual void UpdateLEDs() = 0;
|
||||
virtual void UpdateZoneLEDs(int zone) = 0;
|
||||
virtual void UpdateSingleLED(int led) = 0;
|
||||
|
||||
virtual void SetCustomMode() = 0;
|
||||
virtual void UpdateMode() = 0;
|
||||
};
|
||||
|
||||
@@ -17,9 +17,72 @@ RGBController_AMDWraithPrism::RGBController_AMDWraithPrism(AMDWraithPrismControl
|
||||
type = DEVICE_TYPE_COOLER;
|
||||
version = wraith->GetFirmwareVersionString();
|
||||
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Static.random = false;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Breathing.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
|
||||
Breathing.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
|
||||
Breathing.random = false;
|
||||
Breathing.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode ColorCycle;
|
||||
ColorCycle.name = "Color Cycle";
|
||||
ColorCycle.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_COLOR_CYCLE;
|
||||
ColorCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
ColorCycle.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
|
||||
ColorCycle.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
|
||||
ColorCycle.random = false;
|
||||
ColorCycle.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
|
||||
modes.push_back(ColorCycle);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED;
|
||||
Rainbow.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
|
||||
Rainbow.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
|
||||
Rainbow.random = false;
|
||||
Rainbow.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode Bounce;
|
||||
Bounce.name = "Bounce";
|
||||
Bounce.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_BOUNCE;
|
||||
Bounce.flags = MODE_FLAG_HAS_SPEED;
|
||||
Bounce.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
|
||||
Bounce.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
|
||||
Bounce.random = true;
|
||||
Bounce.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
|
||||
modes.push_back(Bounce);
|
||||
|
||||
mode Chase;
|
||||
Chase.name = "Chase";
|
||||
Chase.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_CHASE;
|
||||
Chase.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Chase.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
|
||||
Chase.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
|
||||
Chase.random = false;
|
||||
Chase.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
|
||||
modes.push_back(Chase);
|
||||
|
||||
mode Swirl;
|
||||
Swirl.name = "Swirl";
|
||||
Swirl.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_SWIRL;
|
||||
Swirl.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Swirl.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
|
||||
Swirl.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
|
||||
Swirl.random = false;
|
||||
Swirl.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
|
||||
modes.push_back(Swirl);
|
||||
|
||||
led logo_led;
|
||||
logo_led.name = "Logo";
|
||||
@@ -66,21 +129,6 @@ RGBController_AMDWraithPrism::~RGBController_AMDWraithPrism()
|
||||
|
||||
}
|
||||
|
||||
int RGBController_AMDWraithPrism::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::UpdateLEDs()
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
@@ -124,3 +172,43 @@ void RGBController_AMDWraithPrism::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateZoneLEDs(led);
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::SetCustomMode()
|
||||
{
|
||||
SetMode(0);
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::UpdateMode()
|
||||
{
|
||||
wraith->SetRingMode(modes[active_mode].value, modes[active_mode].speed, modes[active_mode].direction, modes[active_mode].random);
|
||||
|
||||
switch(modes[active_mode].value)
|
||||
{
|
||||
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_COLOR_CYCLE:
|
||||
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_RAINBOW:
|
||||
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_BOUNCE:
|
||||
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].random);
|
||||
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].random);
|
||||
break;
|
||||
|
||||
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_BREATHING:
|
||||
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_BREATHING, modes[active_mode].speed, modes[active_mode].random);
|
||||
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_BREATHING, modes[active_mode].speed, modes[active_mode].random);
|
||||
break;
|
||||
|
||||
default:
|
||||
if(modes[active_mode].random)
|
||||
{
|
||||
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].random);
|
||||
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].random);
|
||||
}
|
||||
else
|
||||
{
|
||||
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC, modes[active_mode].speed, modes[active_mode].random);
|
||||
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC, modes[active_mode].speed, modes[active_mode].random);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
@@ -16,13 +16,13 @@ class RGBController_AMDWraithPrism : public RGBController
|
||||
public:
|
||||
RGBController_AMDWraithPrism(AMDWraithPrismController* wraith_ptr);
|
||||
~RGBController_AMDWraithPrism();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
AMDWraithPrismController* wraith;
|
||||
};
|
||||
|
||||
@@ -20,21 +20,6 @@ static unsigned char data[] = { 0x8E, 0x00, 0x00, 0x00,
|
||||
0x64, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00 };
|
||||
|
||||
int RGBController_AorusGPU::GetMode()
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::SetMode(int mode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::UpdateLEDs()
|
||||
{
|
||||
RGBColor color = colors[0];
|
||||
@@ -86,3 +71,13 @@ RGBController_AorusGPU::RGBController_AorusGPU()
|
||||
aorus_zone.map.push_back(aorus_zone_map);
|
||||
zones.push_back(aorus_zone);
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::UpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -19,13 +19,13 @@ class RGBController_AorusGPU : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AorusGPU();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
_GvWriteI2C GvWriteI2C;
|
||||
_GvFreeDispLib GvFreeDispLib;
|
||||
|
||||
@@ -9,34 +9,44 @@
|
||||
|
||||
#include "RGBController_Aura.h"
|
||||
|
||||
int RGBController_Aura::GetMode()
|
||||
int RGBController_Aura::GetDeviceMode()
|
||||
{
|
||||
int dev_mode = aura->AuraRegisterRead(AURA_REG_MODE);
|
||||
bool random = false;
|
||||
|
||||
switch(dev_mode)
|
||||
{
|
||||
case AURA_MODE_SPECTRUM_CYCLE_CHASE:
|
||||
dev_mode = AURA_MODE_CHASE;
|
||||
random = true;
|
||||
break;
|
||||
|
||||
case AURA_MODE_SPECTRUM_CYCLE_BREATHING:
|
||||
dev_mode = AURA_MODE_BREATHING;
|
||||
random = true;
|
||||
break;
|
||||
|
||||
case AURA_MODE_SPECTRUM_CYCLE_CHASE_FADE:
|
||||
dev_mode = AURA_MODE_CHASE_FADE;
|
||||
random = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (aura->AuraRegisterRead(AURA_REG_DIRECT))
|
||||
{
|
||||
return(0);
|
||||
dev_mode = 0xFFFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
return(aura->AuraRegisterRead(AURA_REG_MODE) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Aura::SetMode(int mode)
|
||||
{
|
||||
if (mode == 0)
|
||||
for(int mode = 0; mode < modes.size(); mode++)
|
||||
{
|
||||
aura->SetDirect(true);
|
||||
if(modes[mode].value == dev_mode)
|
||||
{
|
||||
active_mode = mode;
|
||||
modes[mode].random = random;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetMode(mode - 1);
|
||||
aura->SetDirect(false);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Aura::SetCustomMode()
|
||||
{
|
||||
aura->SetDirect(true);
|
||||
return(active_mode);
|
||||
}
|
||||
|
||||
void RGBController_Aura::UpdateLEDs()
|
||||
@@ -118,28 +128,65 @@ RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
|
||||
name = "ASUS Aura Motherboard";
|
||||
}
|
||||
|
||||
mode aura_modes[AURA_NUMBER_MODES + 1];
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(Direct);
|
||||
|
||||
aura_modes[0].name = "Direct";
|
||||
aura_modes[1].name = "Off";
|
||||
aura_modes[2].name = "Static";
|
||||
aura_modes[3].name = "Breathing";
|
||||
aura_modes[4].name = "Flashing";
|
||||
aura_modes[5].name = "Spectrum Cycle";
|
||||
aura_modes[6].name = "Rainbow";
|
||||
aura_modes[7].name = "Spectrum Cycle Breathing";
|
||||
aura_modes[8].name = "Chase Fade";
|
||||
aura_modes[9].name = "Spectrum Cycle Chase Fade";
|
||||
aura_modes[10].name = "Chase";
|
||||
aura_modes[11].name = "Spectrum Cycle Chase";
|
||||
aura_modes[12].name = "Spectrum Cycle Wave";
|
||||
aura_modes[13].name = "Chase Rainbow Pulse";
|
||||
aura_modes[14].name = "Random Flicker";
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = AURA_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
modes.push_back(Off);
|
||||
|
||||
for (std::size_t i = 0; i < (AURA_NUMBER_MODES + 1); i++)
|
||||
{
|
||||
modes.push_back(aura_modes[i]);
|
||||
}
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = AURA_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = AURA_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Flashing;
|
||||
Flashing.name = "Flashing";
|
||||
Flashing.value = AURA_MODE_FLASHING;
|
||||
Flashing.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(Flashing);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = AURA_MODE_SPECTRUM_CYCLE;
|
||||
SpectrumCycle.flags = 0;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = AURA_MODE_RAINBOW;
|
||||
Rainbow.flags = 0;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode ChaseFade;
|
||||
ChaseFade.name = "Chase Fade";
|
||||
ChaseFade.value = AURA_MODE_CHASE_FADE;
|
||||
ChaseFade.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(ChaseFade);
|
||||
|
||||
mode Chase;
|
||||
Chase.name = "Chase";
|
||||
Chase.value = AURA_MODE_CHASE;
|
||||
Chase.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(Chase);
|
||||
|
||||
mode RandomFlicker;
|
||||
RandomFlicker.name = "Random Flicker";
|
||||
RandomFlicker.value = AURA_MODE_RANDOM_FLICKER;
|
||||
RandomFlicker.flags = 0;
|
||||
modes.push_back(RandomFlicker);
|
||||
|
||||
colors.resize(aura->GetLEDCount());
|
||||
|
||||
@@ -205,4 +252,43 @@ RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize active mode
|
||||
active_mode = GetDeviceMode();
|
||||
}
|
||||
|
||||
void RGBController_Aura::SetCustomMode()
|
||||
{
|
||||
SetMode(0);
|
||||
}
|
||||
|
||||
void RGBController_Aura::UpdateMode()
|
||||
{
|
||||
if (modes[active_mode].value == 0xFFFF)
|
||||
{
|
||||
aura->SetDirect(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
int new_mode = modes[active_mode].value;
|
||||
|
||||
if(modes[active_mode].random == true)
|
||||
{
|
||||
switch(new_mode)
|
||||
{
|
||||
case AURA_MODE_CHASE:
|
||||
new_mode = AURA_MODE_SPECTRUM_CYCLE_CHASE;
|
||||
break;
|
||||
case AURA_MODE_BREATHING:
|
||||
new_mode = AURA_MODE_SPECTRUM_CYCLE_BREATHING;
|
||||
break;
|
||||
case AURA_MODE_CHASE_FADE:
|
||||
new_mode = AURA_MODE_SPECTRUM_CYCLE_CHASE_FADE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
aura->SetMode(new_mode);
|
||||
aura->SetDirect(false);
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,15 @@ class RGBController_Aura : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Aura(AuraController* aura_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
AuraController* aura;
|
||||
|
||||
int GetDeviceMode();
|
||||
};
|
||||
|
||||
@@ -9,21 +9,6 @@
|
||||
|
||||
#include "RGBController_Corsair.h"
|
||||
|
||||
int RGBController_Corsair::GetMode()
|
||||
{
|
||||
return(CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
|
||||
}
|
||||
|
||||
void RGBController_Corsair::SetMode(int mode)
|
||||
{
|
||||
corsair->SetMode(mode);
|
||||
}
|
||||
|
||||
void RGBController_Corsair::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Corsair::UpdateLEDs()
|
||||
{
|
||||
RGBColor color = colors[0];
|
||||
@@ -53,16 +38,23 @@ RGBController_Corsair::RGBController_Corsair(CorsairController* corsair_ptr)
|
||||
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
|
||||
mode corsair_modes[CORSAIR_NUMBER_MODES];
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CORSAIR_VENGEANCE_RGB_MODE_SINGLE;
|
||||
Static.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(Static);
|
||||
|
||||
corsair_modes[0].name = "Static";
|
||||
corsair_modes[1].name = "Fade";
|
||||
corsair_modes[2].name = "Pulse";
|
||||
mode Fade;
|
||||
Fade.name = "Fade";
|
||||
Fade.value = CORSAIR_VENGEANCE_RGB_MODE_FADE;
|
||||
Fade.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(Fade);
|
||||
|
||||
for (int i = 0; i < CORSAIR_NUMBER_MODES; i++)
|
||||
{
|
||||
modes.push_back(corsair_modes[i]);
|
||||
}
|
||||
mode Pulse;
|
||||
Pulse.name = "Pulse";
|
||||
Pulse.value = CORSAIR_VENGEANCE_RGB_MODE_PULSE;
|
||||
Pulse.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(Pulse);
|
||||
|
||||
for (unsigned int i = 0; i < corsair->GetLEDCount(); i++)
|
||||
{
|
||||
@@ -90,3 +82,13 @@ RGBController_Corsair::RGBController_Corsair(CorsairController* corsair_ptr)
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
|
||||
void RGBController_Corsair::SetCustomMode()
|
||||
{
|
||||
SetMode(0);
|
||||
}
|
||||
|
||||
void RGBController_Corsair::UpdateMode()
|
||||
{
|
||||
corsair->SetMode(modes[active_mode].value);
|
||||
}
|
||||
@@ -16,13 +16,13 @@ class RGBController_Corsair : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Corsair(CorsairController* corsair_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
CorsairController* corsair;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,276 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairCmdrPro.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Corsair |
|
||||
| Commander Pro |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/16/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_CorsairCmdrPro.h"
|
||||
|
||||
|
||||
RGBController_CorsairCmdrPro::RGBController_CorsairCmdrPro(CorsairCmdrProController* corsair_ptr)
|
||||
{
|
||||
corsair = corsair_ptr;
|
||||
|
||||
name = "Corsair Commander Pro";
|
||||
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode RainbowWave;
|
||||
RainbowWave.name = "Rainbow Wave";
|
||||
RainbowWave.value = CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE;
|
||||
RainbowWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
RainbowWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
RainbowWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
RainbowWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
RainbowWave.direction = MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(RainbowWave);
|
||||
|
||||
mode ColorShift;
|
||||
ColorShift.name = "Color Shift";
|
||||
ColorShift.value = CORSAIR_CMDR_PRO_MODE_COLOR_SHIFT;
|
||||
ColorShift.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
ColorShift.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
ColorShift.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
ColorShift.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
modes.push_back(ColorShift);
|
||||
|
||||
mode ColorPulse;
|
||||
ColorPulse.name = "Color Pulse";
|
||||
ColorPulse.value = CORSAIR_CMDR_PRO_MODE_COLOR_PULSE;
|
||||
ColorPulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
ColorPulse.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
ColorPulse.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
ColorPulse.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
modes.push_back(ColorPulse);
|
||||
|
||||
mode ColorWave;
|
||||
ColorWave.name = "Color Wave";
|
||||
ColorWave.value = CORSAIR_CMDR_PRO_MODE_COLOR_WAVE;
|
||||
ColorWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
ColorWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
ColorWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
ColorWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
ColorWave.direction = MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(ColorWave);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CORSAIR_CMDR_PRO_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_COLOR;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Temperature;
|
||||
Temperature.name = "Temperature";
|
||||
Temperature.value = CORSAIR_CMDR_PRO_MODE_TEMPERATURE;
|
||||
Temperature.flags = MODE_FLAG_HAS_COLOR;
|
||||
modes.push_back(Temperature);
|
||||
|
||||
mode Visor;
|
||||
Visor.name = "Visor";
|
||||
Visor.value = CORSAIR_CMDR_PRO_MODE_VISOR;
|
||||
Visor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Visor.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Visor.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Visor.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
modes.push_back(Visor);
|
||||
|
||||
mode Marquee;
|
||||
Marquee.name = "Marquee";
|
||||
Marquee.value = CORSAIR_CMDR_PRO_MODE_MARQUEE;
|
||||
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Marquee.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Marquee.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Marquee.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
Marquee.direction = MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(Marquee);
|
||||
|
||||
mode Blink;
|
||||
Blink.name = "Blink";
|
||||
Blink.value = CORSAIR_CMDR_PRO_MODE_BLINK;
|
||||
Blink.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Blink.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Blink.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Blink.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
modes.push_back(Blink);
|
||||
|
||||
mode Sequential;
|
||||
Sequential.name = "Sequential";
|
||||
Sequential.value = CORSAIR_CMDR_PRO_MODE_SEQUENTIAL;
|
||||
Sequential.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Sequential.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Sequential.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Sequential.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
Sequential.direction = MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(Sequential);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = CORSAIR_CMDR_PRO_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED;
|
||||
Rainbow.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Rainbow.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Rainbow.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set size of colors array |
|
||||
\*-------------------------------------------------*/
|
||||
unsigned int led_count = 0;
|
||||
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel_idx++)
|
||||
{
|
||||
led_count += corsair->channel_leds[channel_idx];
|
||||
}
|
||||
colors.resize(led_count);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set zones and leds |
|
||||
\*-------------------------------------------------*/
|
||||
unsigned int led_idx = 0;
|
||||
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel_idx++)
|
||||
{
|
||||
if(corsair->channel_leds[channel_idx] > 0)
|
||||
{
|
||||
zone* new_zone = new zone;
|
||||
|
||||
char ch_idx_string[2];
|
||||
sprintf(ch_idx_string, "%d", channel_idx + 1);
|
||||
|
||||
new_zone->name = "Corsair Channel ";
|
||||
new_zone->name.append(ch_idx_string);
|
||||
new_zone->type = ZONE_TYPE_LINEAR;
|
||||
|
||||
std::vector<int> *new_zone_map = new std::vector<int>();
|
||||
|
||||
for (unsigned int led_ch_idx = 0; led_ch_idx < corsair->channel_leds[channel_idx]; led_ch_idx++)
|
||||
{
|
||||
char led_idx_string[3];
|
||||
sprintf(led_idx_string, "%d", led_ch_idx + 1);
|
||||
|
||||
led new_led;
|
||||
new_led.name = "Corsair Channel ";
|
||||
new_led.name.append(ch_idx_string);
|
||||
new_led.name.append(", LED ");
|
||||
new_led.name.append(led_idx_string);
|
||||
|
||||
leds.push_back(new_led);
|
||||
leds_channel.push_back(channel_idx);
|
||||
|
||||
new_zone_map->push_back(led_idx);
|
||||
led_idx++;
|
||||
}
|
||||
|
||||
new_zone->map.push_back(*new_zone_map);
|
||||
zones.push_back(*new_zone);
|
||||
zones_channel.push_back(channel_idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairCmdrPro::UpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone_idx];
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
corsair->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairCmdrPro::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone];
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
corsair->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairCmdrPro::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned int channel = leds_channel[led];
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
corsair->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairCmdrPro::SetCustomMode()
|
||||
{
|
||||
SetMode(9);
|
||||
}
|
||||
|
||||
void RGBController_CorsairCmdrPro::UpdateMode()
|
||||
{
|
||||
if(modes[active_mode].value == 0xFFFF)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int channel = 0; channel < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel++)
|
||||
{
|
||||
unsigned int direction = 0;
|
||||
|
||||
if(modes[active_mode].direction == MODE_DIRECTION_RIGHT)
|
||||
{
|
||||
direction = 1;
|
||||
}
|
||||
|
||||
corsair->SetChannelEffect(channel,
|
||||
modes[active_mode].value,
|
||||
modes[active_mode].speed,
|
||||
direction,
|
||||
modes[active_mode].random,
|
||||
RGBGetRValue(colors[0]),
|
||||
RGBGetGValue(colors[0]),
|
||||
RGBGetBValue(colors[0]),
|
||||
RGBGetRValue(colors[1]),
|
||||
RGBGetGValue(colors[1]),
|
||||
RGBGetBValue(colors[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairCmdrPro.h |
|
||||
| |
|
||||
| Generic RGB Interface for Corsair |
|
||||
| Commander Pro |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/16/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "serial_port.h"
|
||||
#include "CorsairCmdrProController.h"
|
||||
|
||||
class RGBController_CorsairCmdrPro : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CorsairCmdrPro(CorsairCmdrProController* corsair_ptr);
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
CorsairCmdrProController* corsair;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
std::vector<unsigned int> zones_channel;
|
||||
};
|
||||
@@ -17,11 +17,110 @@ RGBController_CorsairNodePro::RGBController_CorsairNodePro(CorsairNodeProControl
|
||||
name = "Corsair Lighting Node Pro";
|
||||
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode RainbowWave;
|
||||
RainbowWave.name = "Rainbow Wave";
|
||||
RainbowWave.value = CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE;
|
||||
RainbowWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
RainbowWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
RainbowWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
RainbowWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
RainbowWave.direction = MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(RainbowWave);
|
||||
|
||||
mode ColorShift;
|
||||
ColorShift.name = "Color Shift";
|
||||
ColorShift.value = CORSAIR_CMDR_PRO_MODE_COLOR_SHIFT;
|
||||
ColorShift.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
ColorShift.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
ColorShift.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
ColorShift.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
modes.push_back(ColorShift);
|
||||
|
||||
mode ColorPulse;
|
||||
ColorPulse.name = "Color Pulse";
|
||||
ColorPulse.value = CORSAIR_CMDR_PRO_MODE_COLOR_PULSE;
|
||||
ColorPulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
ColorPulse.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
ColorPulse.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
ColorPulse.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
modes.push_back(ColorPulse);
|
||||
|
||||
mode ColorWave;
|
||||
ColorWave.name = "Color Wave";
|
||||
ColorWave.value = CORSAIR_CMDR_PRO_MODE_COLOR_WAVE;
|
||||
ColorWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
ColorWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
ColorWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
ColorWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
ColorWave.direction = MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(ColorWave);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CORSAIR_CMDR_PRO_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_COLOR;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Temperature;
|
||||
Temperature.name = "Temperature";
|
||||
Temperature.value = CORSAIR_CMDR_PRO_MODE_TEMPERATURE;
|
||||
Temperature.flags = MODE_FLAG_HAS_COLOR;
|
||||
modes.push_back(Temperature);
|
||||
|
||||
mode Visor;
|
||||
Visor.name = "Visor";
|
||||
Visor.value = CORSAIR_CMDR_PRO_MODE_VISOR;
|
||||
Visor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Visor.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Visor.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Visor.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
modes.push_back(Visor);
|
||||
|
||||
mode Marquee;
|
||||
Marquee.name = "Marquee";
|
||||
Marquee.value = CORSAIR_CMDR_PRO_MODE_MARQUEE;
|
||||
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Marquee.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Marquee.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Marquee.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
Marquee.direction = MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(Marquee);
|
||||
|
||||
mode Blink;
|
||||
Blink.name = "Blink";
|
||||
Blink.value = CORSAIR_CMDR_PRO_MODE_BLINK;
|
||||
Blink.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Blink.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Blink.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Blink.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
modes.push_back(Blink);
|
||||
|
||||
mode Sequential;
|
||||
Sequential.name = "Sequential";
|
||||
Sequential.value = CORSAIR_CMDR_PRO_MODE_SEQUENTIAL;
|
||||
Sequential.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Sequential.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Sequential.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Sequential.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
Sequential.direction = MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(Sequential);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = CORSAIR_CMDR_PRO_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED;
|
||||
Rainbow.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
|
||||
Rainbow.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
|
||||
Rainbow.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set size of colors array |
|
||||
\*-------------------------------------------------*/
|
||||
@@ -76,21 +175,6 @@ RGBController_CorsairNodePro::RGBController_CorsairNodePro(CorsairNodeProControl
|
||||
}
|
||||
}
|
||||
|
||||
int RGBController_CorsairNodePro::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_CorsairNodePro::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_CorsairNodePro::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_CorsairNodePro::UpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
@@ -130,9 +214,8 @@ void RGBController_CorsairNodePro::UpdateZoneLEDs(int zone)
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
//corsair->SetChannelLEDs(channel, channel_colors);
|
||||
corsair->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
corsair->SendKeepalive();
|
||||
}
|
||||
|
||||
void RGBController_CorsairNodePro::UpdateSingleLED(int led)
|
||||
@@ -154,3 +237,40 @@ void RGBController_CorsairNodePro::UpdateSingleLED(int led)
|
||||
corsair->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairNodePro::SetCustomMode()
|
||||
{
|
||||
SetMode(9);
|
||||
}
|
||||
|
||||
void RGBController_CorsairNodePro::UpdateMode()
|
||||
{
|
||||
if(modes[active_mode].value == 0xFFFF)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int channel = 0; channel < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel++)
|
||||
{
|
||||
unsigned int direction = 0;
|
||||
|
||||
if(modes[active_mode].direction == MODE_DIRECTION_RIGHT)
|
||||
{
|
||||
direction = 1;
|
||||
}
|
||||
|
||||
corsair->SetChannelEffect(channel,
|
||||
modes[active_mode].value,
|
||||
modes[active_mode].speed,
|
||||
direction,
|
||||
modes[active_mode].random,
|
||||
RGBGetRValue(colors[0]),
|
||||
RGBGetGValue(colors[0]),
|
||||
RGBGetBValue(colors[0]),
|
||||
RGBGetRValue(colors[1]),
|
||||
RGBGetGValue(colors[1]),
|
||||
RGBGetBValue(colors[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,13 @@ class RGBController_CorsairNodePro : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CorsairNodePro(CorsairNodeProController* corsair_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
CorsairNodeProController* corsair;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
|
||||
@@ -9,87 +9,6 @@
|
||||
|
||||
#include "RGBController_CorsairPro.h"
|
||||
|
||||
int RGBController_CorsairPro::GetMode()
|
||||
{
|
||||
switch (corsair->GetEffect())
|
||||
{
|
||||
case CORSAIR_PRO_MODE_COLOR_SHIFT:
|
||||
return(0);
|
||||
break;
|
||||
case CORSAIR_PRO_MODE_COLOR_PULSE:
|
||||
return(1);
|
||||
break;
|
||||
case CORSAIR_PRO_MODE_RAINBOW_WAVE:
|
||||
return(2);
|
||||
break;
|
||||
case CORSAIR_PRO_MODE_COLOR_WAVE:
|
||||
return(3);
|
||||
break;
|
||||
case CORSAIR_PRO_MODE_VISOR:
|
||||
return(4);
|
||||
break;
|
||||
case CORSAIR_PRO_MODE_RAIN:
|
||||
return(5);
|
||||
break;
|
||||
case CORSAIR_PRO_MODE_MARQUEE:
|
||||
return(6);
|
||||
break;
|
||||
case CORSAIR_PRO_MODE_RAINBOW:
|
||||
return(7);
|
||||
break;
|
||||
case CORSAIR_PRO_MODE_SEQUENTIAL:
|
||||
return(8);
|
||||
break;
|
||||
case CORSAIR_PRO_MODE_STATIC:
|
||||
return(9);
|
||||
break;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::SetMode(int mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_COLOR_SHIFT);
|
||||
break;
|
||||
case 1:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_COLOR_PULSE);
|
||||
break;
|
||||
case 2:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_RAINBOW_WAVE);
|
||||
break;
|
||||
case 3:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_COLOR_WAVE);
|
||||
break;
|
||||
case 4:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_VISOR);
|
||||
break;
|
||||
case 5:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_RAIN);
|
||||
break;
|
||||
case 6:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_MARQUEE);
|
||||
break;
|
||||
case 7:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_RAINBOW);
|
||||
break;
|
||||
case 8:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_SEQUENTIAL);
|
||||
break;
|
||||
case 9:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_STATIC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::SetCustomMode()
|
||||
{
|
||||
corsair->SetCustom();
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::UpdateLEDs()
|
||||
{
|
||||
for (std::size_t led = 0; led < colors.size(); led++)
|
||||
@@ -129,23 +48,112 @@ RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair
|
||||
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
|
||||
mode corsair_modes[CORSAIR_PRO_NUMBER_MODES];
|
||||
mode ColorShift;
|
||||
ColorShift.name = "Color Shift";
|
||||
ColorShift.value = CORSAIR_PRO_MODE_COLOR_SHIFT;
|
||||
ColorShift.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
ColorShift.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
ColorShift.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
ColorShift.random = false;
|
||||
ColorShift.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
modes.push_back(ColorShift);
|
||||
|
||||
corsair_modes[0].name = "Color Shift";
|
||||
corsair_modes[1].name = "Color Pulse";
|
||||
corsair_modes[2].name = "Rainbow Wave";
|
||||
corsair_modes[3].name = "Color Wave";
|
||||
corsair_modes[4].name = "Visor";
|
||||
corsair_modes[5].name = "Rain";
|
||||
corsair_modes[6].name = "Marquee";
|
||||
corsair_modes[7].name = "Rainbow";
|
||||
corsair_modes[8].name = "Sequential";
|
||||
corsair_modes[9].name = "Static";
|
||||
mode ColorPulse;
|
||||
ColorPulse.name = "Color Pulse";
|
||||
ColorPulse.value = CORSAIR_PRO_MODE_COLOR_PULSE;
|
||||
ColorPulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
ColorPulse.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
ColorPulse.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
ColorPulse.random = false;
|
||||
ColorPulse.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
modes.push_back(ColorPulse);
|
||||
|
||||
for (int i = 0; i < CORSAIR_PRO_NUMBER_MODES; i++)
|
||||
{
|
||||
modes.push_back(corsair_modes[i]);
|
||||
}
|
||||
mode RainbowWave;
|
||||
RainbowWave.name = "Rainbow Wave";
|
||||
RainbowWave.value = CORSAIR_PRO_MODE_RAINBOW_WAVE;
|
||||
RainbowWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_DIRECTION_UD;
|
||||
RainbowWave.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
RainbowWave.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
RainbowWave.random = false;
|
||||
RainbowWave.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
RainbowWave.direction = MODE_DIRECTION_DOWN;
|
||||
modes.push_back(RainbowWave);
|
||||
|
||||
mode ColorWave;
|
||||
ColorWave.name = "Color Wave";
|
||||
ColorWave.value = CORSAIR_PRO_MODE_COLOR_WAVE;
|
||||
ColorWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
ColorWave.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
ColorWave.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
ColorWave.random = false;
|
||||
ColorWave.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
ColorWave.direction = MODE_DIRECTION_DOWN;
|
||||
modes.push_back(ColorWave);
|
||||
|
||||
mode Visor;
|
||||
Visor.name = "Visor";
|
||||
Visor.value = CORSAIR_PRO_MODE_VISOR;
|
||||
Visor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_HV | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Visor.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
Visor.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
Visor.random = false;
|
||||
Visor.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
Visor.direction = MODE_DIRECTION_VERTICAL;
|
||||
modes.push_back(Visor);
|
||||
|
||||
mode Rain;
|
||||
Rain.name = "Rain";
|
||||
Rain.value = CORSAIR_PRO_MODE_RAIN;
|
||||
Rain.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Rain.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
Rain.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
Rain.random = false;
|
||||
Rain.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
Rain.direction = MODE_DIRECTION_DOWN;
|
||||
modes.push_back(Rain);
|
||||
|
||||
mode Marquee;
|
||||
Marquee.name = "Marquee";
|
||||
Marquee.value = CORSAIR_PRO_MODE_MARQUEE;
|
||||
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR;
|
||||
Marquee.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
Marquee.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
Marquee.random = false;
|
||||
Marquee.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
modes.push_back(Marquee);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = CORSAIR_PRO_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED;
|
||||
Rainbow.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
Rainbow.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
Rainbow.random = false;
|
||||
Rainbow.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode Sequential;
|
||||
Sequential.name = "Sequential";
|
||||
Sequential.value = CORSAIR_PRO_MODE_SEQUENTIAL;
|
||||
Sequential.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Sequential.speed_min = CORSAIR_PRO_SPEED_SLOW;
|
||||
Sequential.speed_max = CORSAIR_PRO_SPEED_FAST;
|
||||
Sequential.random = false;
|
||||
Sequential.speed = CORSAIR_PRO_SPEED_SLOW;
|
||||
Sequential.direction = MODE_DIRECTION_DOWN;
|
||||
modes.push_back(Sequential);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CORSAIR_PRO_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Static.speed_min = 0;
|
||||
Static.speed_max = 0;
|
||||
Static.random = false;
|
||||
Static.speed = 0;
|
||||
modes.push_back(Static);
|
||||
|
||||
active_mode = 9;
|
||||
|
||||
colors.resize(corsair->GetLEDCount());
|
||||
|
||||
@@ -174,3 +182,46 @@ RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::SetCustomMode()
|
||||
{
|
||||
SetMode(9);
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::UpdateMode()
|
||||
{
|
||||
unsigned int corsair_direction;
|
||||
|
||||
switch(modes[active_mode].direction)
|
||||
{
|
||||
case MODE_DIRECTION_LEFT:
|
||||
corsair_direction = CORSAIR_PRO_DIRECTION_LEFT;
|
||||
break;
|
||||
case MODE_DIRECTION_RIGHT:
|
||||
corsair_direction = CORSAIR_PRO_DIRECTION_RIGHT;
|
||||
break;
|
||||
case MODE_DIRECTION_UP:
|
||||
corsair_direction = CORSAIR_PRO_DIRECTION_UP;
|
||||
break;
|
||||
case MODE_DIRECTION_DOWN:
|
||||
corsair_direction = CORSAIR_PRO_DIRECTION_DOWN;
|
||||
break;
|
||||
case MODE_DIRECTION_HORIZONTAL:
|
||||
corsair_direction = CORSAIR_PRO_DIRECTION_HORIZONTAL;
|
||||
break;
|
||||
case MODE_DIRECTION_VERTICAL:
|
||||
corsair_direction = CORSAIR_PRO_DIRECTION_VERTICAL;
|
||||
break;
|
||||
}
|
||||
|
||||
corsair->SetEffect(modes[active_mode].value,
|
||||
modes[active_mode].speed,
|
||||
corsair_direction,
|
||||
modes[active_mode].random,
|
||||
RGBGetRValue(colors[0]),
|
||||
RGBGetGValue(colors[0]),
|
||||
RGBGetBValue(colors[0]),
|
||||
RGBGetRValue(colors[1]),
|
||||
RGBGetGValue(colors[1]),
|
||||
RGBGetBValue(colors[1]));
|
||||
}
|
||||
@@ -16,13 +16,13 @@ class RGBController_CorsairPro : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CorsairPro(CorsairProController* corsair_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
CorsairProController* corsair;
|
||||
};
|
||||
|
||||
@@ -86,21 +86,6 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
|
||||
}
|
||||
}
|
||||
|
||||
int RGBController_E131::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_E131::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_E131::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_E131::UpdateLEDs()
|
||||
{
|
||||
int color_idx = 0;
|
||||
@@ -171,3 +156,13 @@ void RGBController_E131::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_E131::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_E131::UpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -37,13 +37,13 @@ class RGBController_E131 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_E131(std::vector<E131Device> device_list);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
std::vector<E131Device> devices;
|
||||
std::vector<e131_packet_t> packets;
|
||||
|
||||
@@ -17,9 +17,78 @@ RGBController_Hue2::RGBController_Hue2(Hue2Controller* hue2_ptr)
|
||||
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = HUE_2_MODE_FIXED;
|
||||
Direct.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Fading;
|
||||
Fading.name = "Fading";
|
||||
Fading.value = HUE_2_MODE_FADING;
|
||||
Fading.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Fading.speed_min = HUE_2_SPEED_SLOWEST;
|
||||
Fading.speed_max = HUE_2_SPEED_FASTEST;
|
||||
Fading.speed = HUE_2_SPEED_NORMAL;
|
||||
modes.push_back(Fading);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = HUE_2_MODE_SPECTRUM;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
SpectrumCycle.speed_min = HUE_2_SPEED_SLOWEST;
|
||||
SpectrumCycle.speed_max = HUE_2_SPEED_FASTEST;
|
||||
SpectrumCycle.speed = HUE_2_SPEED_NORMAL;
|
||||
SpectrumCycle.direction = MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Marquee;
|
||||
Marquee.name = "Marquee";
|
||||
Marquee.value = HUE_2_MODE_MARQUEE;
|
||||
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Marquee.speed_min = HUE_2_SPEED_SLOWEST;
|
||||
Marquee.speed_max = HUE_2_SPEED_FASTEST;
|
||||
Marquee.speed = HUE_2_SPEED_NORMAL;
|
||||
Marquee.direction = MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(Marquee);
|
||||
|
||||
mode CoverMarquee;
|
||||
CoverMarquee.name = "Cover Marquee";
|
||||
CoverMarquee.value = HUE_2_MODE_COVER_MARQUEE;
|
||||
CoverMarquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
CoverMarquee.speed_min = HUE_2_SPEED_SLOWEST;
|
||||
CoverMarquee.speed_max = HUE_2_SPEED_FASTEST;
|
||||
CoverMarquee.speed = HUE_2_SPEED_NORMAL;
|
||||
CoverMarquee.direction = MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(CoverMarquee);
|
||||
|
||||
mode Alternating;
|
||||
Alternating.name = "Alternating";
|
||||
Alternating.value = HUE_2_MODE_ALTERNATING;
|
||||
Alternating.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Alternating.speed_min = HUE_2_SPEED_SLOWEST;
|
||||
Alternating.speed_max = HUE_2_SPEED_FASTEST;
|
||||
Alternating.speed = HUE_2_SPEED_NORMAL;
|
||||
Alternating.direction = MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(Alternating);
|
||||
|
||||
mode Pulsing;
|
||||
Pulsing.name = "Pulsing";
|
||||
Pulsing.value = HUE_2_MODE_PULSING;
|
||||
Pulsing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Pulsing.speed_min = HUE_2_SPEED_SLOWEST;
|
||||
Pulsing.speed_max = HUE_2_SPEED_FASTEST;
|
||||
Pulsing.speed = HUE_2_SPEED_NORMAL;
|
||||
modes.push_back(Pulsing);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = HUE_2_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Breathing.speed_min = HUE_2_SPEED_SLOWEST;
|
||||
Breathing.speed_max = HUE_2_SPEED_FASTEST;
|
||||
Breathing.speed = HUE_2_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set size of colors array |
|
||||
@@ -75,21 +144,6 @@ RGBController_Hue2::RGBController_Hue2(Hue2Controller* hue2_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
int RGBController_Hue2::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_Hue2::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Hue2::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Hue2::UpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
@@ -152,3 +206,39 @@ void RGBController_Hue2::UpdateSingleLED(int led)
|
||||
hue2->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Hue2::SetCustomMode()
|
||||
{
|
||||
SetMode(0);
|
||||
}
|
||||
|
||||
void RGBController_Hue2::UpdateMode()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone_idx];
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
bool direction = false;
|
||||
|
||||
if(modes[active_mode].direction == MODE_DIRECTION_LEFT)
|
||||
{
|
||||
direction = true;
|
||||
}
|
||||
|
||||
hue2->SetMode(modes[active_mode].value, modes[active_mode].speed, direction);
|
||||
hue2->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,13 +15,13 @@ class RGBController_Hue2 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Hue2(Hue2Controller* hue2_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
Hue2Controller* hue2;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
|
||||
@@ -17,11 +17,112 @@ RGBController_HuePlus::RGBController_HuePlus(HuePlusController* hueplus_ptr)
|
||||
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
|
||||
location = hueplus->GetLEDString();
|
||||
location = hueplus->GetLocation();
|
||||
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = HUE_PLUS_MODE_FIXED;
|
||||
Direct.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(Direct);
|
||||
|
||||
// Fading mode is currently disabled because it doesn't appear to work
|
||||
// mode Fading;
|
||||
// Fading.name = "Fading";
|
||||
// Fading.value = HUE_PLUS_MODE_FADING;
|
||||
// Fading.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
// Fading.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
// Fading.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
// Fading.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
// modes.push_back(Fading);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = HUE_PLUS_MODE_SPECTRUM;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
SpectrumCycle.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
SpectrumCycle.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
SpectrumCycle.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
SpectrumCycle.direction = MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Marquee;
|
||||
Marquee.name = "Marquee";
|
||||
Marquee.value = HUE_PLUS_MODE_MARQUEE;
|
||||
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Marquee.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
Marquee.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
Marquee.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
Marquee.direction = MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(Marquee);
|
||||
|
||||
mode CoverMarquee;
|
||||
CoverMarquee.name = "Cover Marquee";
|
||||
CoverMarquee.value = HUE_PLUS_MODE_COVER_MARQUEE;
|
||||
CoverMarquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
CoverMarquee.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
CoverMarquee.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
CoverMarquee.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
CoverMarquee.direction = MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(CoverMarquee);
|
||||
|
||||
mode Alternating;
|
||||
Alternating.name = "Alternating";
|
||||
Alternating.value = HUE_PLUS_MODE_ALTERNATING;
|
||||
Alternating.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Alternating.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
Alternating.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
Alternating.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
Alternating.direction = MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(Alternating);
|
||||
|
||||
mode Pulsing;
|
||||
Pulsing.name = "Pulsing";
|
||||
Pulsing.value = HUE_PLUS_MODE_PULSING;
|
||||
Pulsing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Pulsing.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
Pulsing.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
Pulsing.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
modes.push_back(Pulsing);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = HUE_PLUS_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Breathing.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
Breathing.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
Breathing.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Alert;
|
||||
Alert.name = "Alert";
|
||||
Alert.value = HUE_PLUS_MODE_ALERT;
|
||||
Alert.flags = 0;
|
||||
modes.push_back(Alert);
|
||||
|
||||
mode Candlelight;
|
||||
Candlelight.name = "Candlelight";
|
||||
Candlelight.value = HUE_PLUS_MODE_CANDLELIGHT;
|
||||
Candlelight.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(Candlelight);
|
||||
|
||||
mode Wings;
|
||||
Wings.name = "Wings";
|
||||
Wings.value = HUE_PLUS_MODE_WINGS;
|
||||
Wings.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Wings.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
Wings.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
Wings.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
modes.push_back(Wings);
|
||||
|
||||
// Wave mode is currently disabled because it doesn't appear to work
|
||||
// mode Wave;
|
||||
// Wave.name = "Wave";
|
||||
// Wave.value = HUE_PLUS_MODE_WAVE;
|
||||
// Wave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
// Wave.speed_min = HUE_PLUS_SPEED_SLOWEST;
|
||||
// Wave.speed_max = HUE_PLUS_SPEED_FASTEST;
|
||||
// Wave.speed = HUE_PLUS_SPEED_NORMAL;
|
||||
// modes.push_back(Wave);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set size of colors array |
|
||||
@@ -77,21 +178,6 @@ RGBController_HuePlus::RGBController_HuePlus(HuePlusController* hueplus_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
int RGBController_HuePlus::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::UpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
@@ -154,3 +240,39 @@ void RGBController_HuePlus::UpdateSingleLED(int led)
|
||||
hueplus->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetCustomMode()
|
||||
{
|
||||
SetMode(0);
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::UpdateMode()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone_idx];
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
bool direction = false;
|
||||
|
||||
if(modes[active_mode].direction == MODE_DIRECTION_LEFT)
|
||||
{
|
||||
direction = true;
|
||||
}
|
||||
|
||||
hueplus->SetMode(modes[active_mode].value, modes[active_mode].speed, direction);
|
||||
hueplus->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,13 +15,13 @@ class RGBController_HuePlus : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HuePlus(HuePlusController* hueplus_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
HuePlusController* hueplus;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
|
||||
@@ -9,20 +9,6 @@
|
||||
|
||||
#include "RGBController_HyperX.h"
|
||||
|
||||
int RGBController_HyperX::GetMode()
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void RGBController_HyperX::SetMode(int mode)
|
||||
{
|
||||
hyperx->SetMode(mode);
|
||||
}
|
||||
|
||||
void RGBController_HyperX::SetCustomMode()
|
||||
{
|
||||
hyperx->SetMode(HYPERX_MODE_DIRECT);
|
||||
}
|
||||
|
||||
void RGBController_HyperX::UpdateLEDs()
|
||||
{
|
||||
@@ -105,22 +91,85 @@ RGBController_HyperX::RGBController_HyperX(HyperXController* hyperx_ptr)
|
||||
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
|
||||
mode hyperx_modes[HYPERX_NUMBER_MODES];
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = HYPERX_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(Direct);
|
||||
|
||||
hyperx_modes[0].name = "Direct";
|
||||
hyperx_modes[1].name = "Static";
|
||||
hyperx_modes[2].name = "Rainbow";
|
||||
hyperx_modes[3].name = "Comet";
|
||||
hyperx_modes[4].name = "Heartbeat";
|
||||
hyperx_modes[5].name = "Spectrum Cycle";
|
||||
hyperx_modes[6].name = "Breathing";
|
||||
hyperx_modes[7].name = "Bounce";
|
||||
hyperx_modes[8].name = "Blink";
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = HYPERX_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_COLOR;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = HYPERX_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED;
|
||||
Rainbow.speed_min = HYPERX_SPEED_RAINBOW_SLOW;
|
||||
Rainbow.speed_max = HYPERX_SPEED_RAINBOW_FAST;
|
||||
Rainbow.speed = HYPERX_SPEED_RAINBOW_NORMAL;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode Comet;
|
||||
Comet.name = "Comet";
|
||||
Comet.value = HYPERX_MODE_COMET;
|
||||
Comet.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Comet.speed_min = HYPERX_SPEED_COMET_SLOW;
|
||||
Comet.speed_max = HYPERX_SPEED_COMET_FAST;
|
||||
Comet.random = false;
|
||||
Comet.speed = HYPERX_SPEED_COMET_NORMAL;
|
||||
modes.push_back(Comet);
|
||||
|
||||
mode Heartbeat;
|
||||
Heartbeat.name = "Heartbeat";
|
||||
Heartbeat.value = HYPERX_MODE_HEARTBEAT;
|
||||
Heartbeat.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Heartbeat.speed_min = HYPERX_SPEED_COMET_SLOW;
|
||||
Heartbeat.speed_max = HYPERX_SPEED_COMET_FAST;
|
||||
Heartbeat.random = false;
|
||||
Heartbeat.speed = HYPERX_SPEED_COMET_NORMAL;
|
||||
modes.push_back(Heartbeat);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = HYPERX_MODE_CYCLE;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
SpectrumCycle.speed_min = HYPERX_SPEED_CYCLE_SLOW;
|
||||
SpectrumCycle.speed_max = HYPERX_SPEED_CYCLE_FAST;
|
||||
SpectrumCycle.speed = HYPERX_SPEED_CYCLE_NORMAL;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
for (int i = 0; i < HYPERX_NUMBER_MODES; i++)
|
||||
{
|
||||
modes.push_back(hyperx_modes[i]);
|
||||
}
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = HYPERX_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Breathing.speed_min = HYPERX_SPEED_BREATHING_SLOW;
|
||||
Breathing.speed_max = HYPERX_SPEED_BREATHING_FAST;
|
||||
Breathing.random = false;
|
||||
Breathing.speed = HYPERX_SPEED_BREATHING_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Bounce;
|
||||
Bounce.name = "Bounce";
|
||||
Bounce.value = HYPERX_MODE_BOUNCE;
|
||||
Bounce.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Bounce.speed_min = HYPERX_SPEED_BOUNCE_SLOW;
|
||||
Bounce.speed_max = HYPERX_SPEED_BOUNCE_FAST;
|
||||
Bounce.random = false;
|
||||
Bounce.speed = HYPERX_SPEED_BOUNCE_NORMAL;
|
||||
modes.push_back(Bounce);
|
||||
|
||||
mode Blink;
|
||||
Blink.name = "Blink";
|
||||
Blink.value = HYPERX_MODE_BLINK;
|
||||
Blink.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
|
||||
Blink.speed_min = HYPERX_SPEED_BLINK_SLOW;
|
||||
Blink.speed_max = HYPERX_SPEED_BLINK_FAST;
|
||||
Blink.random = false;
|
||||
Blink.speed = HYPERX_SPEED_BLINK_NORMAL;
|
||||
modes.push_back(Blink);
|
||||
|
||||
colors.resize(hyperx->GetLEDCount());
|
||||
|
||||
@@ -160,3 +209,14 @@ RGBController_HyperX::RGBController_HyperX(HyperXController* hyperx_ptr)
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HyperX::SetCustomMode()
|
||||
{
|
||||
SetMode(0);
|
||||
}
|
||||
|
||||
void RGBController_HyperX::UpdateMode()
|
||||
{
|
||||
hyperx->SetMode(modes[active_mode].value, modes[active_mode].random, modes[active_mode].speed);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,13 +16,13 @@ class RGBController_HyperX : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HyperX(HyperXController* hyperx_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
HyperXController* hyperx;
|
||||
};
|
||||
|
||||
@@ -42,21 +42,6 @@ RGBController_LEDStrip::RGBController_LEDStrip(LEDStripController* ledstrip_ptr)
|
||||
zones.push_back(led_zone);
|
||||
}
|
||||
|
||||
int RGBController_LEDStrip::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::UpdateLEDs()
|
||||
{
|
||||
strip->SetLEDs(colors);
|
||||
@@ -71,3 +56,13 @@ void RGBController_LEDStrip::UpdateSingleLED(int led)
|
||||
{
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::UpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -16,13 +16,12 @@ class RGBController_LEDStrip : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LEDStrip(LEDStripController* ledstrip_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
LEDStripController* strip;
|
||||
|
||||
@@ -64,21 +64,6 @@ RGBController_MSI3Zone::~RGBController_MSI3Zone()
|
||||
|
||||
}
|
||||
|
||||
int RGBController_MSI3Zone::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_MSI3Zone::SetMode(int mode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_MSI3Zone::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_MSI3Zone::UpdateLEDs()
|
||||
{
|
||||
msi->SetLEDs(colors);
|
||||
@@ -92,4 +77,14 @@ void RGBController_MSI3Zone::UpdateZoneLEDs(int zone)
|
||||
void RGBController_MSI3Zone::UpdateSingleLED(int led)
|
||||
{
|
||||
msi->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_MSI3Zone::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_MSI3Zone::UpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -16,13 +16,13 @@ class RGBController_MSI3Zone : public RGBController
|
||||
public:
|
||||
RGBController_MSI3Zone(MSI3ZoneController* msi_ptr);
|
||||
~RGBController_MSI3Zone();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
MSI3ZoneController* msi;
|
||||
};
|
||||
@@ -11,84 +11,7 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <unistd.h>
|
||||
int RGBController_OpenRazer::GetMode()
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetMode(int mode)
|
||||
{
|
||||
char update_value = 1;
|
||||
|
||||
switch(matrix_type)
|
||||
{
|
||||
case RAZER_TYPE_MATRIX_FRAME:
|
||||
case RAZER_TYPE_MATRIX_NOFRAME:
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case RAZER_MODE_CUSTOM:
|
||||
matrix_effect_custom.write(&update_value, 1);
|
||||
matrix_effect_custom.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_OFF:
|
||||
matrix_effect_none.write(&update_value, 1);
|
||||
matrix_effect_none.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_STATIC:
|
||||
break;
|
||||
|
||||
case RAZER_MODE_BREATHING:
|
||||
break;
|
||||
|
||||
case RAZER_MODE_SPECTRUM_CYCLE:
|
||||
matrix_effect_spectrum.write(&update_value, 1);
|
||||
matrix_effect_spectrum.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_WAVE:
|
||||
matrix_effect_wave.write(&update_value, 1);
|
||||
matrix_effect_wave.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_REACTIVE:
|
||||
matrix_effect_reactive.write(&update_value, 1);
|
||||
matrix_effect_reactive.flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_TYPE_NOMATRIX:
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case RAZER_MODE_CUSTOM:
|
||||
update_value = 0;
|
||||
logo_led_effect.write(&update_value, 1);
|
||||
scroll_led_effect.write(&update_value, 1);
|
||||
logo_led_effect.flush();
|
||||
scroll_led_effect.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_SPECTRUM_CYCLE:
|
||||
update_value = '4';
|
||||
logo_led_effect.write(&update_value, 1);
|
||||
scroll_led_effect.write(&update_value, 1);
|
||||
logo_led_effect.flush();
|
||||
scroll_led_effect.flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetCustomMode()
|
||||
{
|
||||
SetMode(RAZER_MODE_CUSTOM);
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::UpdateLEDs()
|
||||
{
|
||||
@@ -401,3 +324,77 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetCustomMode()
|
||||
{
|
||||
SetMode(RAZER_MODE_CUSTOM);
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::UpdateMode()
|
||||
{
|
||||
char update_value = 1;
|
||||
|
||||
switch(matrix_type)
|
||||
{
|
||||
case RAZER_TYPE_MATRIX_FRAME:
|
||||
case RAZER_TYPE_MATRIX_NOFRAME:
|
||||
{
|
||||
switch(active_mode)
|
||||
{
|
||||
case RAZER_MODE_CUSTOM:
|
||||
matrix_effect_custom.write(&update_value, 1);
|
||||
matrix_effect_custom.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_OFF:
|
||||
matrix_effect_none.write(&update_value, 1);
|
||||
matrix_effect_none.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_STATIC:
|
||||
break;
|
||||
|
||||
case RAZER_MODE_BREATHING:
|
||||
break;
|
||||
|
||||
case RAZER_MODE_SPECTRUM_CYCLE:
|
||||
matrix_effect_spectrum.write(&update_value, 1);
|
||||
matrix_effect_spectrum.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_WAVE:
|
||||
matrix_effect_wave.write(&update_value, 1);
|
||||
matrix_effect_wave.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_REACTIVE:
|
||||
matrix_effect_reactive.write(&update_value, 1);
|
||||
matrix_effect_reactive.flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_TYPE_NOMATRIX:
|
||||
{
|
||||
switch(active_mode)
|
||||
{
|
||||
case RAZER_MODE_CUSTOM:
|
||||
update_value = 0;
|
||||
logo_led_effect.write(&update_value, 1);
|
||||
scroll_led_effect.write(&update_value, 1);
|
||||
logo_led_effect.flush();
|
||||
scroll_led_effect.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_SPECTRUM_CYCLE:
|
||||
update_value = '4';
|
||||
logo_led_effect.write(&update_value, 1);
|
||||
scroll_led_effect.write(&update_value, 1);
|
||||
logo_led_effect.flush();
|
||||
scroll_led_effect.flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -920,13 +920,13 @@ public:
|
||||
|
||||
public:
|
||||
RGBController_OpenRazer(std::string dev_path);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
int device;
|
||||
|
||||
private:
|
||||
|
||||
@@ -9,28 +9,6 @@
|
||||
|
||||
#include "RGBController_PatriotViper.h"
|
||||
|
||||
int RGBController_PatriotViper::GetMode()
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void RGBController_PatriotViper::SetMode(int mode)
|
||||
{
|
||||
if(mode == 0)
|
||||
{
|
||||
viper->SetDirect();
|
||||
}
|
||||
else
|
||||
{
|
||||
viper->SetMode(mode - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_PatriotViper::SetCustomMode()
|
||||
{
|
||||
viper->SetDirect();
|
||||
}
|
||||
|
||||
void RGBController_PatriotViper::UpdateLEDs()
|
||||
{
|
||||
if(viper->direct == true)
|
||||
@@ -88,23 +66,85 @@ RGBController_PatriotViper::RGBController_PatriotViper(PatriotViperController* v
|
||||
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
|
||||
mode viper_modes[10];
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Direct.speed_min = 0;
|
||||
Direct.speed_max = 0;
|
||||
Direct.random = false;
|
||||
Direct.speed = 0;
|
||||
modes.push_back(Direct);
|
||||
|
||||
viper_modes[0].name = "Direct";
|
||||
viper_modes[1].name = "Dark";
|
||||
viper_modes[2].name = "Breathing";
|
||||
viper_modes[3].name = "Viper";
|
||||
viper_modes[4].name = "Heartbeat";
|
||||
viper_modes[5].name = "Marquee";
|
||||
viper_modes[6].name = "Raindrop";
|
||||
viper_modes[7].name = "Aurora";
|
||||
viper_modes[8].name = "Unknown";
|
||||
viper_modes[9].name = "Neon";
|
||||
mode Dark;
|
||||
Dark.name = "Dark";
|
||||
Dark.value = VIPER_MODE_DARK;
|
||||
Dark.flags = 0;
|
||||
Dark.speed_min = 0;
|
||||
Dark.speed_max = 0;
|
||||
Dark.random = false;
|
||||
Dark.speed = 0;
|
||||
modes.push_back(Dark);
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
modes.push_back(viper_modes[i]);
|
||||
}
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = VIPER_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Breathing.speed_min = VIPER_SPEED_BREATHING_MIN;
|
||||
Breathing.speed_max = VIPER_SPEED_BREATHING_MAX;
|
||||
Breathing.random = false;
|
||||
Breathing.speed = VIPER_SPEED_BREATHING_DEFAULT;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Viper;
|
||||
Viper.name = "Viper";
|
||||
Viper.value = VIPER_MODE_VIPER;
|
||||
Viper.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Viper.speed_min = VIPER_SPEED_MIN;
|
||||
Viper.speed_max = VIPER_SPEED_MAX;
|
||||
Viper.random = false;
|
||||
Viper.speed = VIPER_SPEED_DEFAULT;
|
||||
modes.push_back(Viper);
|
||||
|
||||
mode Heartbeat;
|
||||
Heartbeat.name = "Heartbeat";
|
||||
Heartbeat.value = VIPER_MODE_HEARTBEAT;
|
||||
Heartbeat.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Heartbeat.speed_min = VIPER_SPEED_MIN;
|
||||
Heartbeat.speed_max = VIPER_SPEED_MAX;
|
||||
Heartbeat.random = false;
|
||||
Heartbeat.speed = VIPER_SPEED_DEFAULT;
|
||||
modes.push_back(Heartbeat);
|
||||
|
||||
mode Marquee;
|
||||
Marquee.name = "Marquee";
|
||||
Marquee.value = VIPER_MODE_MARQUEE;
|
||||
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Marquee.speed_min = VIPER_SPEED_MIN;
|
||||
Marquee.speed_max = VIPER_SPEED_MAX;
|
||||
Marquee.random = false;
|
||||
Marquee.speed = VIPER_SPEED_DEFAULT;
|
||||
modes.push_back(Marquee);
|
||||
|
||||
mode Raindrop;
|
||||
Raindrop.name = "Raindrop";
|
||||
Raindrop.value = VIPER_MODE_RAINDROP;
|
||||
Raindrop.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Raindrop.speed_min = VIPER_SPEED_MIN;
|
||||
Raindrop.speed_max = VIPER_SPEED_MAX;
|
||||
Raindrop.random = false;
|
||||
Raindrop.speed = VIPER_SPEED_DEFAULT;
|
||||
modes.push_back(Raindrop);
|
||||
|
||||
mode Aurora;
|
||||
Aurora.name = "Aurora";
|
||||
Aurora.value = VIPER_MODE_AURORA;
|
||||
Aurora.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Aurora.speed_min = VIPER_SPEED_MIN;
|
||||
Aurora.speed_max = VIPER_SPEED_MAX;
|
||||
Aurora.random = false;
|
||||
Aurora.speed = VIPER_SPEED_DEFAULT;
|
||||
modes.push_back(Aurora);
|
||||
|
||||
colors.resize(viper->GetLEDCount());
|
||||
|
||||
@@ -143,3 +183,20 @@ RGBController_PatriotViper::RGBController_PatriotViper(PatriotViperController* v
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_PatriotViper::SetCustomMode()
|
||||
{
|
||||
SetMode(0);
|
||||
}
|
||||
|
||||
void RGBController_PatriotViper::UpdateMode()
|
||||
{
|
||||
if(modes[active_mode].value == 0xFFFF)
|
||||
{
|
||||
viper->SetDirect();
|
||||
}
|
||||
else
|
||||
{
|
||||
viper->SetMode(modes[active_mode].value, modes[active_mode].speed);
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,13 @@ class RGBController_PatriotViper : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_PatriotViper(PatriotViperController* viper_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
PatriotViperController* viper;
|
||||
};
|
||||
|
||||
@@ -9,20 +9,6 @@
|
||||
|
||||
#include "RGBController_Polychrome.h"
|
||||
|
||||
int RGBController_Polychrome::GetMode()
|
||||
{
|
||||
return(polychrome->GetMode());
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::SetMode(int mode)
|
||||
{
|
||||
polychrome->SetMode(mode);
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::SetCustomMode()
|
||||
{
|
||||
polychrome->SetMode(POLYCHROME_MODE_STATIC);
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::UpdateLEDs()
|
||||
{
|
||||
@@ -95,3 +81,13 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::SetCustomMode()
|
||||
{
|
||||
SetMode(0);
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::UpdateMode()
|
||||
{
|
||||
polychrome->SetMode(active_mode);
|
||||
}
|
||||
@@ -16,13 +16,13 @@ class RGBController_Polychrome : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Polychrome(PolychromeController* polychrome_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
PolychromeController* polychrome;
|
||||
};
|
||||
|
||||
@@ -27,21 +27,6 @@ RGBController_PoseidonZRGB::~RGBController_PoseidonZRGB()
|
||||
|
||||
}
|
||||
|
||||
int RGBController_PoseidonZRGB::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_PoseidonZRGB::SetMode(int mode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_PoseidonZRGB::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_PoseidonZRGB::UpdateLEDs()
|
||||
{
|
||||
poseidon->SetLEDs(colors);
|
||||
@@ -55,4 +40,14 @@ void RGBController_PoseidonZRGB::UpdateZoneLEDs(int zone)
|
||||
void RGBController_PoseidonZRGB::UpdateSingleLED(int led)
|
||||
{
|
||||
poseidon->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_PoseidonZRGB::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_PoseidonZRGB::UpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -16,13 +16,13 @@ class RGBController_PoseidonZRGB : public RGBController
|
||||
public:
|
||||
RGBController_PoseidonZRGB(PoseidonZRGBController* poseidon_ptr);
|
||||
~RGBController_PoseidonZRGB();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
PoseidonZRGBController* poseidon;
|
||||
};
|
||||
@@ -9,20 +9,6 @@
|
||||
|
||||
#include "RGBController_RGBFusion.h"
|
||||
|
||||
int RGBController_RGBFusion::GetMode()
|
||||
{
|
||||
return(rgb_fusion->GetMode());
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::SetMode(int mode)
|
||||
{
|
||||
rgb_fusion->SetMode(mode);
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::SetCustomMode()
|
||||
{
|
||||
rgb_fusion->SetMode(RGB_FUSION_MODE_STATIC);
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::UpdateLEDs()
|
||||
{
|
||||
@@ -68,16 +54,29 @@ RGBController_RGBFusion::RGBController_RGBFusion(RGBFusionController* rgb_fusion
|
||||
|
||||
type = DEVICE_TYPE_MOTHERBOARD;
|
||||
|
||||
mode rgb_fusion_modes[RGB_FUSION_NUMBER_MODES];
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = RGB_FUSION_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(Static);
|
||||
|
||||
rgb_fusion_modes[0].name = "Static";
|
||||
rgb_fusion_modes[1].name = "Breathing";
|
||||
rgb_fusion_modes[2].name = "Flashing";
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = RGB_FUSION_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Breathing.speed_min = RGB_FUSION_SPEED_SLOW;
|
||||
Breathing.speed_max = RGB_FUSION_SPEED_FAST;
|
||||
Breathing.speed = RGB_FUSION_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
for (int i = 0; i < RGB_FUSION_NUMBER_MODES; i++)
|
||||
{
|
||||
modes.push_back(rgb_fusion_modes[i]);
|
||||
}
|
||||
mode Flashing;
|
||||
Flashing.name = "Flashing";
|
||||
Flashing.value = RGB_FUSION_MODE_FLASHING;
|
||||
Flashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
Flashing.speed_min = RGB_FUSION_SPEED_SLOW;
|
||||
Flashing.speed_max = RGB_FUSION_SPEED_FAST;
|
||||
Flashing.speed = RGB_FUSION_SPEED_NORMAL;
|
||||
modes.push_back(Flashing);
|
||||
|
||||
colors.resize(rgb_fusion->GetLEDCount());
|
||||
|
||||
@@ -105,4 +104,32 @@ RGBController_RGBFusion::RGBController_RGBFusion(RGBFusionController* rgb_fusion
|
||||
// Push new zone to zones vector
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
|
||||
// Initialize active mode
|
||||
active_mode = GetDeviceMode();
|
||||
}
|
||||
|
||||
int RGBController_RGBFusion::GetDeviceMode()
|
||||
{
|
||||
int dev_mode = rgb_fusion->GetMode();
|
||||
|
||||
for(int mode = 0; mode < modes.size(); mode++)
|
||||
{
|
||||
if(modes[mode].value == dev_mode)
|
||||
{
|
||||
return(mode);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::SetCustomMode()
|
||||
{
|
||||
rgb_fusion->SetMode(RGB_FUSION_MODE_STATIC, 0);
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::UpdateMode()
|
||||
{
|
||||
rgb_fusion->SetMode(modes[active_mode].value, modes[active_mode].speed);
|
||||
}
|
||||
@@ -16,13 +16,15 @@ class RGBController_RGBFusion : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_RGBFusion(RGBFusionController* rgb_fusion_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
RGBFusionController* rgb_fusion;
|
||||
|
||||
int GetDeviceMode();
|
||||
};
|
||||
|
||||
@@ -70,21 +70,6 @@ RGBController_RazerChromaSDK::RGBController_RazerChromaSDK(unsigned int device_t
|
||||
if(CreateChromaLinkEffect == NULL) CreateChromaLinkEffect = (CREATECHROMALINKEFFECT)GetProcAddress(*hModule, "CreateChromaLinkEffect");
|
||||
}
|
||||
|
||||
int RGBController_RazerChromaSDK::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::SetMode(int mode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::UpdateLEDs()
|
||||
{
|
||||
switch (device->razer_type)
|
||||
@@ -169,3 +154,13 @@ void RGBController_RazerChromaSDK::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::UpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -229,13 +229,13 @@ class RGBController_RazerChromaSDK : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_RazerChromaSDK(unsigned int device_type, HMODULE* hModule);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
const razer_device* device;
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
DetectRGBControllers();
|
||||
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication a(argc, argv);
|
||||
|
||||
Ui::OpenRGBDialog2 dlg(busses, rgb_controllers);
|
||||
|
||||
+246
-1
@@ -75,6 +75,11 @@ OpenRGBDevicePage::OpenRGBDevicePage(RGBController *dev, QWidget *parent) :
|
||||
ui->ModeBox->setCurrentIndex(device->GetMode());
|
||||
ui->ModeBox->blockSignals(false);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Update mode user interface elements |
|
||||
\*-----------------------------------------------------*/
|
||||
UpdateModeUi();
|
||||
|
||||
ui->ZoneBox->blockSignals(true);
|
||||
ui->ZoneBox->clear();
|
||||
|
||||
@@ -129,10 +134,243 @@ void Ui::OpenRGBDevicePage::on_LEDBox_currentIndexChanged(int index)
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_ModeBox_currentIndexChanged(int /*index*/)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Update mode user interface elements |
|
||||
\*-----------------------------------------------------*/
|
||||
UpdateModeUi();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Change device mode |
|
||||
\*-----------------------------------------------------*/
|
||||
device->SetMode(ui->ModeBox->currentIndex());
|
||||
UpdateMode();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_RandomCheck_clicked()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Change device mode |
|
||||
\*-----------------------------------------------------*/
|
||||
UpdateMode();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_SpeedSlider_valueChanged(int /*value*/)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Change device mode |
|
||||
\*-----------------------------------------------------*/
|
||||
UpdateMode();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_DirectionBox_currentIndexChanged(int /*index*/)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Change device mode |
|
||||
\*-----------------------------------------------------*/
|
||||
UpdateMode();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::UpdateModeUi()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Read new mode flags and settings |
|
||||
\*-----------------------------------------------------*/
|
||||
int selected_mode = ui->ModeBox->currentIndex();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Don't update the UI if the current mode is invalid |
|
||||
\*-----------------------------------------------------*/
|
||||
if(selected_mode < device->modes.size())
|
||||
{
|
||||
bool supports_random = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_COLOR )
|
||||
&& ( device->modes[selected_mode].flags & MODE_FLAG_RANDOM_COLOR );
|
||||
bool supports_speed = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_SPEED );
|
||||
bool supports_dir_lr = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_DIRECTION_LR );
|
||||
bool supports_dir_ud = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_DIRECTION_UD );
|
||||
bool supports_dir_hv = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_DIRECTION_HV );
|
||||
bool random = device->modes[selected_mode].random;
|
||||
unsigned int dir = device->modes[selected_mode].direction;
|
||||
|
||||
if(supports_speed)
|
||||
{
|
||||
if(device->modes[selected_mode].speed_min > device->modes[selected_mode].speed_max)
|
||||
{
|
||||
InvertedSpeed = true;
|
||||
ui->SpeedSlider->setMinimum(device->modes[selected_mode].speed_max);
|
||||
ui->SpeedSlider->setMaximum(device->modes[selected_mode].speed_min);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvertedSpeed = false;
|
||||
ui->SpeedSlider->setMinimum(device->modes[selected_mode].speed_min);
|
||||
ui->SpeedSlider->setMaximum(device->modes[selected_mode].speed_max);
|
||||
}
|
||||
|
||||
ui->SpeedSlider->setValue(device->modes[selected_mode].speed);
|
||||
ui->SpeedSlider->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->SpeedSlider->setEnabled(false);
|
||||
}
|
||||
|
||||
ui->DirectionBox->clear();
|
||||
|
||||
if(supports_dir_lr)
|
||||
{
|
||||
ui->DirectionBox->addItem("Left");
|
||||
ui->DirectionBox->addItem("Right");
|
||||
}
|
||||
|
||||
if(supports_dir_ud)
|
||||
{
|
||||
ui->DirectionBox->addItem("Up");
|
||||
ui->DirectionBox->addItem("Down");
|
||||
}
|
||||
|
||||
if(supports_dir_hv)
|
||||
{
|
||||
ui->DirectionBox->addItem("Horizontal");
|
||||
ui->DirectionBox->addItem("Vertical");
|
||||
}
|
||||
|
||||
if(supports_dir_lr || supports_dir_ud || supports_dir_hv)
|
||||
{
|
||||
if((supports_dir_lr)
|
||||
&&((dir == MODE_DIRECTION_LEFT)
|
||||
||(dir == MODE_DIRECTION_RIGHT)))
|
||||
{
|
||||
ui->DirectionBox->setCurrentIndex(dir);
|
||||
}
|
||||
|
||||
if((supports_dir_ud)
|
||||
&&((dir == MODE_DIRECTION_UP)
|
||||
||(dir == MODE_DIRECTION_DOWN)))
|
||||
{
|
||||
if(supports_dir_lr)
|
||||
{
|
||||
ui->DirectionBox->setCurrentIndex(dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->DirectionBox->setCurrentIndex(dir - 2);
|
||||
}
|
||||
}
|
||||
|
||||
if((supports_dir_hv)
|
||||
&&((dir == MODE_DIRECTION_HORIZONTAL)
|
||||
||(dir == MODE_DIRECTION_VERTICAL)))
|
||||
{
|
||||
if(supports_dir_lr && supports_dir_ud)
|
||||
{
|
||||
ui->DirectionBox->setCurrentIndex(dir);
|
||||
}
|
||||
else if(supports_dir_lr || supports_dir_ud)
|
||||
{
|
||||
ui->DirectionBox->setCurrentIndex(dir - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->DirectionBox->setCurrentIndex(dir - 4);
|
||||
}
|
||||
}
|
||||
|
||||
ui->DirectionBox->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->DirectionBox->setEnabled(false);
|
||||
}
|
||||
|
||||
if(supports_random)
|
||||
{
|
||||
ui->RandomCheck->setEnabled(true);
|
||||
ui->RandomCheck->setCheckState(random ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->RandomCheck->setEnabled(false);
|
||||
ui->RandomCheck->setCheckState(random ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::UpdateMode()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Read user interface |
|
||||
\*-----------------------------------------------------*/
|
||||
int current_mode = ui->ModeBox->currentIndex();
|
||||
int current_speed = ui->SpeedSlider->value();
|
||||
bool current_random = ui->RandomCheck->checkState();
|
||||
int current_dir_idx = ui->DirectionBox->currentIndex();
|
||||
int current_direction = 0;
|
||||
bool supports_dir_lr = ( device->modes[current_mode].flags & MODE_FLAG_HAS_DIRECTION_LR );
|
||||
bool supports_dir_ud = ( device->modes[current_mode].flags & MODE_FLAG_HAS_DIRECTION_UD );
|
||||
bool supports_dir_hv = ( device->modes[current_mode].flags & MODE_FLAG_HAS_DIRECTION_HV );
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set the direction value |
|
||||
\*-----------------------------------------------------*/
|
||||
if(supports_dir_hv)
|
||||
{
|
||||
if(supports_dir_lr && supports_dir_ud)
|
||||
{
|
||||
current_direction = current_dir_idx;
|
||||
}
|
||||
else if(supports_dir_lr || supports_dir_ud)
|
||||
{
|
||||
current_direction = current_dir_idx + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_direction = current_dir_idx + 4;
|
||||
}
|
||||
}
|
||||
|
||||
if(supports_dir_ud)
|
||||
{
|
||||
if(supports_dir_lr)
|
||||
{
|
||||
current_direction = current_dir_idx;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_direction = current_dir_idx + 2;
|
||||
}
|
||||
}
|
||||
|
||||
if((supports_dir_lr)
|
||||
&&(current_dir_idx < 2))
|
||||
{
|
||||
current_direction = current_dir_idx;
|
||||
}
|
||||
|
||||
device->modes[current_mode].direction = current_direction;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| If Speed Slider is inverted, invert value |
|
||||
\*-----------------------------------------------------*/
|
||||
if(InvertedSpeed)
|
||||
{
|
||||
current_speed = device->modes[current_mode].speed_min - current_speed + device->modes[current_mode].speed_max;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Don't set the mode if the current mode is invalid |
|
||||
\*-----------------------------------------------------*/
|
||||
if(current_mode < device->modes.size())
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Update mode parameters |
|
||||
\*-----------------------------------------------------*/
|
||||
device->modes[current_mode].speed = current_speed;
|
||||
device->modes[current_mode].random = current_random;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Change device mode |
|
||||
\*-----------------------------------------------------*/
|
||||
device->SetMode(current_mode);
|
||||
}
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::SetDevice(unsigned char red, unsigned char green, unsigned char blue)
|
||||
@@ -147,6 +385,13 @@ void Ui::OpenRGBDevicePage::SetDevice(unsigned char red, unsigned char green, un
|
||||
on_SetDeviceButton_clicked();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::SetCustomMode()
|
||||
{
|
||||
device->SetCustomMode();
|
||||
ui->ModeBox->setCurrentIndex(0);//device->active_mode);
|
||||
UpdateModeUi();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_SetDeviceButton_clicked()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
|
||||
@@ -19,6 +19,9 @@ public:
|
||||
~OpenRGBDevicePage();
|
||||
|
||||
void SetDevice(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
void UpdateModeUi();
|
||||
|
||||
private slots:
|
||||
void on_ButtonRed_clicked();
|
||||
@@ -42,11 +45,18 @@ private slots:
|
||||
|
||||
void on_SetAllButton_clicked();
|
||||
|
||||
void on_RandomCheck_clicked();
|
||||
|
||||
void on_SpeedSlider_valueChanged(int value);
|
||||
|
||||
void on_DirectionBox_currentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::OpenRGBDevicePageUi *ui;
|
||||
RGBController *device;
|
||||
|
||||
bool UpdatingColor = false;
|
||||
bool InvertedSpeed = false;
|
||||
|
||||
void updateRGB();
|
||||
|
||||
|
||||
+73
-11
@@ -17,7 +17,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>71</x>
|
||||
<y>50</y>
|
||||
<y>30</y>
|
||||
<width>160</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -27,7 +27,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>31</x>
|
||||
<y>50</y>
|
||||
<y>30</y>
|
||||
<width>40</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -40,7 +40,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>31</x>
|
||||
<y>90</y>
|
||||
<y>70</y>
|
||||
<width>40</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -53,7 +53,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>71</x>
|
||||
<y>90</y>
|
||||
<y>70</y>
|
||||
<width>160</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -63,7 +63,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>31</x>
|
||||
<y>210</y>
|
||||
<y>190</y>
|
||||
<width>40</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -76,7 +76,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>71</x>
|
||||
<y>210</y>
|
||||
<y>190</y>
|
||||
<width>160</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -86,7 +86,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>190</x>
|
||||
<y>140</y>
|
||||
<y>120</y>
|
||||
<width>41</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -99,7 +99,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>140</y>
|
||||
<y>120</y>
|
||||
<width>41</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -346,7 +346,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>140</y>
|
||||
<y>120</y>
|
||||
<width>41</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -359,7 +359,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>140</y>
|
||||
<y>120</y>
|
||||
<width>40</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -372,7 +372,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>170</y>
|
||||
<y>150</y>
|
||||
<width>80</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@@ -381,6 +381,68 @@
|
||||
<string>Set All Devices</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="RandomCheck">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>220</y>
|
||||
<width>100</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Random Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSlider" name="SpeedSlider">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>240</y>
|
||||
<width>160</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="SpeedLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>240</y>
|
||||
<width>40</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Speed:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="DirectionBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>270</y>
|
||||
<width>160</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="DirectionLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>270</y>
|
||||
<width>40</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dir:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -261,6 +261,7 @@ void OpenRGBDialog2::on_SetAllDevices(unsigned char red, unsigned char green, un
|
||||
{
|
||||
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
|
||||
{
|
||||
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->SetCustomMode();
|
||||
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->SetDevice(red, green, blue);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user