mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-04-27 09:23:57 -04:00
Colorful turing color modes support
This commit is contained in:
committed by
Adam Honse
parent
90db870161
commit
8202ef19e6
@@ -22,23 +22,123 @@ std::string ColorfulTuringGPUController::GetDeviceLocation()
|
||||
return("I2C: " + return_string);
|
||||
}
|
||||
|
||||
void ColorfulTuringGPUController::SetDirect(RGBColor color)
|
||||
int ColorfulTuringGPUController::GetMode()
|
||||
{
|
||||
uint8_t data_pkt[COLORFUL_MODE_PACKET_LENGTH];
|
||||
int size = COLORFUL_MODE_PACKET_LENGTH;
|
||||
bus->i2c_read_block(dev, &size, data_pkt);
|
||||
|
||||
int mode = data_pkt[2]<<16 | data_pkt[3]<<8 | data_pkt[4];
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
RGBColor ColorfulTuringGPUController::GetColor()
|
||||
{
|
||||
uint8_t data_pkt[COLORFUL_MODE_PACKET_LENGTH];
|
||||
int size = COLORFUL_MODE_PACKET_LENGTH;
|
||||
bus->i2c_read_block(dev, &size, data_pkt);
|
||||
|
||||
RGBColor color = ToRGBColor(data_pkt[5], data_pkt[6], data_pkt[7]);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
void ColorfulTuringGPUController::SetStateDisplay(RGBColor color)
|
||||
{
|
||||
uint8_t r = RGBGetRValue(color);
|
||||
uint8_t g = RGBGetGValue(color);
|
||||
uint8_t b = RGBGetBValue(color);
|
||||
uint8_t data_pkt[COLORFUL_PACKET_LENGTH] = { 0x88, 0x02, 0x32, 0x02, r, g, b};
|
||||
uint8_t data_pkt[COLORFUL_COLOR_PACKET_LENGTH] = { 0x08, 0x01, 0x32, 0x04, r, g, b};
|
||||
|
||||
int crc = 1;
|
||||
|
||||
for(int i = 0; i < COLORFUL_PACKET_LENGTH - 1; ++i)
|
||||
for(int i = 0; i < COLORFUL_COLOR_PACKET_LENGTH - 1; ++i)
|
||||
{
|
||||
crc += data_pkt[i];
|
||||
}
|
||||
crc &= 0xFF;
|
||||
crc = 256-crc;
|
||||
|
||||
data_pkt[COLORFUL_PACKET_LENGTH - 1] = crc & 0xFF;
|
||||
data_pkt[COLORFUL_COLOR_PACKET_LENGTH - 1] = crc & 0xFF;
|
||||
|
||||
bus->i2c_write_block(dev, COLORFUL_PACKET_LENGTH, data_pkt);
|
||||
bus->i2c_write_block(dev, COLORFUL_COLOR_PACKET_LENGTH, data_pkt);
|
||||
}
|
||||
|
||||
void ColorfulTuringGPUController::SetDirect(RGBColor color)
|
||||
{
|
||||
uint8_t r = RGBGetRValue(color);
|
||||
uint8_t g = RGBGetGValue(color);
|
||||
uint8_t b = RGBGetBValue(color);
|
||||
uint8_t data_pkt[COLORFUL_COLOR_PACKET_LENGTH] = { 0x88, 0x02, 0x32, 0x02, r, g, b};
|
||||
|
||||
int crc = 1;
|
||||
|
||||
for(int i = 0; i < COLORFUL_COLOR_PACKET_LENGTH - 1; ++i)
|
||||
{
|
||||
crc += data_pkt[i];
|
||||
}
|
||||
crc &= 0xFF;
|
||||
crc = 256-crc;
|
||||
|
||||
data_pkt[COLORFUL_COLOR_PACKET_LENGTH - 1] = crc & 0xFF;
|
||||
|
||||
bus->i2c_write_block(dev, COLORFUL_COLOR_PACKET_LENGTH, data_pkt);
|
||||
}
|
||||
|
||||
void ColorfulTuringGPUController::SetBreathing(RGBColor color)
|
||||
{
|
||||
uint8_t r = RGBGetRValue(color);
|
||||
uint8_t g = RGBGetGValue(color);
|
||||
uint8_t b = RGBGetBValue(color);
|
||||
uint8_t data_pkt[COLORFUL_COLOR_PACKET_LENGTH] = { 0x88, 0x01, 0x32, 0x02, r, g, b};
|
||||
|
||||
int crc = 1;
|
||||
|
||||
for(int i = 0; i < COLORFUL_COLOR_PACKET_LENGTH - 1; ++i)
|
||||
{
|
||||
crc += data_pkt[i];
|
||||
}
|
||||
crc &= 0xFF;
|
||||
crc = 256-crc;
|
||||
|
||||
data_pkt[COLORFUL_COLOR_PACKET_LENGTH - 1] = crc & 0xFF;
|
||||
|
||||
bus->i2c_write_block(dev, COLORFUL_COLOR_PACKET_LENGTH, data_pkt);
|
||||
}
|
||||
|
||||
void ColorfulTuringGPUController::SetOff()
|
||||
{
|
||||
uint8_t data_pkt[COLORFUL_NON_COLOR_PACKET_LENGTH] = { 0x85, 0x00, 0x00, 0x0A };
|
||||
|
||||
int crc = 1;
|
||||
|
||||
for(int i = 0; i < COLORFUL_NON_COLOR_PACKET_LENGTH - 1; ++i)
|
||||
{
|
||||
crc += data_pkt[i];
|
||||
}
|
||||
crc &= 0xFF;
|
||||
crc = 256-crc;
|
||||
|
||||
data_pkt[COLORFUL_NON_COLOR_PACKET_LENGTH - 1] = crc & 0xFF;
|
||||
|
||||
bus->i2c_write_block(dev, COLORFUL_NON_COLOR_PACKET_LENGTH, data_pkt);
|
||||
}
|
||||
|
||||
void ColorfulTuringGPUController::SetRainbow()
|
||||
{
|
||||
uint8_t data_pkt[COLORFUL_NON_COLOR_PACKET_LENGTH] = { 0x85, 0x04, 0x32, 0x02 };
|
||||
|
||||
int crc = 1;
|
||||
|
||||
for(int i = 0; i < COLORFUL_NON_COLOR_PACKET_LENGTH - 1; ++i)
|
||||
{
|
||||
crc += data_pkt[i];
|
||||
}
|
||||
crc &= 0xFF;
|
||||
crc = 256-crc;
|
||||
|
||||
data_pkt[COLORFUL_NON_COLOR_PACKET_LENGTH - 1] = crc & 0xFF;
|
||||
|
||||
bus->i2c_write_block(dev, COLORFUL_NON_COLOR_PACKET_LENGTH, data_pkt);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,18 @@
|
||||
|
||||
typedef unsigned char colorful_gpu_dev_id;
|
||||
|
||||
#define COLORFUL_PACKET_LENGTH 8
|
||||
#define COLORFUL_COLOR_PACKET_LENGTH 8
|
||||
#define COLORFUL_NON_COLOR_PACKET_LENGTH 5
|
||||
#define COLORFUL_MODE_PACKET_LENGTH 0x1B
|
||||
|
||||
enum
|
||||
{
|
||||
COLORFUL_TURING_GPU_RGB_MODE_STATE_DISPLAY = 0x013204,
|
||||
COLORFUL_TURING_GPU_RGB_MODE_OFF = 0x00000A,
|
||||
COLORFUL_TURING_GPU_RGB_MODE_STATIC = 0x023202,
|
||||
COLORFUL_TURING_GPU_RGB_MODE_RAINBOW = 0x043202,
|
||||
COLORFUL_TURING_GPU_RGB_MODE_BREATHING = 0x013202,
|
||||
};
|
||||
|
||||
class ColorfulTuringGPUController
|
||||
{
|
||||
@@ -14,8 +25,14 @@ public:
|
||||
ColorfulTuringGPUController(i2c_smbus_interface* bus, colorful_gpu_dev_id dev);
|
||||
~ColorfulTuringGPUController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
void SetDirect(RGBColor color);
|
||||
std::string GetDeviceLocation();
|
||||
int GetMode();
|
||||
RGBColor GetColor();
|
||||
void SetDirect(RGBColor color);
|
||||
void SetStateDisplay(RGBColor color);
|
||||
void SetBreathing(RGBColor color);
|
||||
void SetOff();
|
||||
void SetRainbow();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -12,9 +12,9 @@ void DetectColorfulTuringGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_ad
|
||||
{
|
||||
if(bus->port_id == 1)
|
||||
{
|
||||
ColorfulTuringGPUController* controller = new ColorfulTuringGPUController(bus, i2c_addr);
|
||||
ColorfulTuringGPUController* controller = new ColorfulTuringGPUController(bus, i2c_addr);
|
||||
RGBController_ColorfulTuringGPU* rgb_controller = new RGBController_ColorfulTuringGPU(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
|
||||
@@ -7,29 +7,60 @@
|
||||
@type I2C
|
||||
@save :x:
|
||||
@direct :white_check_mark:
|
||||
@effects :x:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectColorfulTuringGPUControllers
|
||||
@comment This card only supports direct mode
|
||||
@comment This card supports off, direct, rainbow and pulse mode.
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_ColorfulTuringGPU::RGBController_ColorfulTuringGPU(ColorfulTuringGPUController * colorful_gpu_ptr)
|
||||
{
|
||||
controller = colorful_gpu_ptr;
|
||||
name = "Colorful GPU Device";
|
||||
vendor = "Colorful";
|
||||
type = DEVICE_TYPE_GPU;
|
||||
description = name;
|
||||
location = controller->GetDeviceLocation();
|
||||
controller = colorful_gpu_ptr;
|
||||
name = "Colorful GPU Device";
|
||||
vendor = "Colorful";
|
||||
type = DEVICE_TYPE_GPU;
|
||||
description = name;
|
||||
location = controller->GetDeviceLocation();
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = COLORFUL_TURING_GPU_RGB_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = COLORFUL_TURING_GPU_RGB_MODE_STATIC;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode StateDisplay;
|
||||
StateDisplay.name = "State Display";
|
||||
StateDisplay.value = COLORFUL_TURING_GPU_RGB_MODE_STATE_DISPLAY;
|
||||
StateDisplay.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
StateDisplay.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(StateDisplay);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Spectrum Cycle";
|
||||
Rainbow.value = COLORFUL_TURING_GPU_RGB_MODE_RAINBOW;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = COLORFUL_TURING_GPU_RGB_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
SetupZones();
|
||||
|
||||
// Initialize active mode
|
||||
active_mode = getModeIndex(controller->GetMode());
|
||||
colors[0] = controller->GetColor();
|
||||
|
||||
}
|
||||
|
||||
RGBController_ColorfulTuringGPU::~RGBController_ColorfulTuringGPU()
|
||||
@@ -37,6 +68,19 @@ RGBController_ColorfulTuringGPU::~RGBController_ColorfulTuringGPU()
|
||||
delete controller;
|
||||
}
|
||||
|
||||
int RGBController_ColorfulTuringGPU::getModeIndex(int mode_value)
|
||||
{
|
||||
for(std::size_t mode_index = 0; mode_index < modes.size(); mode_index++)
|
||||
{
|
||||
if (modes[mode_index].value == mode_value)
|
||||
{
|
||||
return mode_index;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_ColorfulTuringGPU::SetupZones()
|
||||
{
|
||||
zone new_zone;
|
||||
@@ -63,7 +107,26 @@ void RGBController_ColorfulTuringGPU::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
|
||||
void RGBController_ColorfulTuringGPU::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SetDirect(colors[0]);
|
||||
switch(modes[active_mode].value)
|
||||
{
|
||||
case COLORFUL_TURING_GPU_RGB_MODE_BREATHING:
|
||||
controller->SetBreathing(colors[0]);
|
||||
break;
|
||||
case COLORFUL_TURING_GPU_RGB_MODE_OFF:
|
||||
controller->SetOff();
|
||||
break;
|
||||
case COLORFUL_TURING_GPU_RGB_MODE_RAINBOW:
|
||||
controller->SetRainbow();
|
||||
break;
|
||||
case COLORFUL_TURING_GPU_RGB_MODE_STATE_DISPLAY:
|
||||
controller->SetStateDisplay(colors[0]);
|
||||
break;
|
||||
case COLORFUL_TURING_GPU_RGB_MODE_STATIC:
|
||||
controller->SetDirect(colors[0]);
|
||||
break;
|
||||
default:
|
||||
controller->SetDirect(colors[0]);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_ColorfulTuringGPU::UpdateZoneLEDs(int /*zone*/)
|
||||
|
||||
@@ -9,17 +9,16 @@ public:
|
||||
RGBController_ColorfulTuringGPU(ColorfulTuringGPUController* colorful_gpu_ptr);
|
||||
~RGBController_ColorfulTuringGPU();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
ColorfulTuringGPUController* controller;
|
||||
int getModeIndex(int mode_value);
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user