mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-05-18 11:35:21 -04:00
Update EVGA Turing controller to expose HW modes
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
| Driver for EVGA GPU RGB V2 (Turing) |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 9/13/2020 |
|
||||
| TheRogueZeta 4/15/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "EVGAGPUv2Controller.h"
|
||||
@@ -23,46 +23,256 @@ EVGAGPUv2Controller::~EVGAGPUv2Controller()
|
||||
std::string EVGAGPUv2Controller::GetDeviceLocation()
|
||||
{
|
||||
std::string return_string(bus->device_name);
|
||||
char addr[5];
|
||||
char addr[5];
|
||||
|
||||
snprintf(addr, 5, "0x%02X", dev);
|
||||
return_string.append(", address ");
|
||||
return_string.append(addr);
|
||||
return("I2C: " + return_string);
|
||||
}
|
||||
|
||||
unsigned char EVGAGPUv2Controller::GetRed()
|
||||
unsigned char EVGAGPUv2Controller::GetBrightnessA()
|
||||
{
|
||||
return(bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V2_REG_COLOR_A_RED));
|
||||
return(bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V2_REG_COLOR_A_BRIGHTNESS));
|
||||
}
|
||||
|
||||
unsigned char EVGAGPUv2Controller::GetGreen()
|
||||
RGBColor EVGAGPUv2Controller::GetColorA()
|
||||
{
|
||||
return(bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V2_REG_COLOR_A_GREEN));
|
||||
int red = bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V2_REG_COLOR_A_RED);
|
||||
int green = bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V2_REG_COLOR_A_GREEN);
|
||||
int blue = bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V2_REG_COLOR_A_BLUE);
|
||||
return(ToRGBColor(red, green, blue));
|
||||
}
|
||||
|
||||
unsigned char EVGAGPUv2Controller::GetBlue()
|
||||
RGBColor EVGAGPUv2Controller::GetColorB()
|
||||
{
|
||||
return(bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V2_REG_COLOR_A_BLUE));
|
||||
int red = bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V2_REG_COLOR_B_RED);
|
||||
int green = bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V2_REG_COLOR_B_GREEN);
|
||||
int blue = bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V2_REG_COLOR_B_BLUE);
|
||||
return(ToRGBColor(red, green, blue));
|
||||
}
|
||||
|
||||
void EVGAGPUv2Controller::SetColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
unsigned char EVGAGPUv2Controller::GetMode()
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xE5);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xE9);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xF5);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xF9);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_V2_REG_COLOR_A_RED, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_V2_REG_COLOR_A_GREEN, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_V2_REG_COLOR_A_BLUE, blue);
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_V2_REG_COLOR_A_BRIGHTNESS, 0x64);
|
||||
unsigned char return_mode = 0;
|
||||
unsigned char mode = bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V2_REG_MODE);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x08, 0x01);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xF0);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xE0);
|
||||
if(mode == 0xFF)
|
||||
{
|
||||
//Registers may not ready after saving config. Read again if 0xFF.
|
||||
mode = bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V2_REG_MODE);
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case EVGA_GPU_V2_MODE_OFF:
|
||||
{
|
||||
return_mode = EVGA_GPU_V2_RGB_MODE_OFF;
|
||||
}
|
||||
break;
|
||||
|
||||
case EVGA_GPU_V2_MODE_DIRECT:
|
||||
{
|
||||
//No way to detect static so just return direct.
|
||||
return_mode = EVGA_GPU_V2_RGB_MODE_DIRECT;
|
||||
}
|
||||
break;
|
||||
|
||||
case EVGA_GPU_V2_MODE_RAINBOW:
|
||||
{
|
||||
return_mode = EVGA_GPU_V2_RGB_MODE_RAINBOW;
|
||||
}
|
||||
break;
|
||||
|
||||
case EVGA_GPU_V2_MODE_BREATHING:
|
||||
{
|
||||
u16_to_u8 speed_16 = { (uint16_t) 0 };
|
||||
|
||||
speed_16.LSB = bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V2_REG_B_TO_A_SPEED_LSB);
|
||||
speed_16.MSB = bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V2_REG_B_TO_A_SPEED_MSB);
|
||||
|
||||
if (speed_16.u16 == 0)
|
||||
{
|
||||
return_mode = EVGA_GPU_V2_RGB_MODE_PULSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return_mode = EVGA_GPU_V2_RGB_MODE_BREATHING;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return(return_mode);
|
||||
}
|
||||
|
||||
void EVGAGPUv2Controller::SetMode(unsigned char mode)
|
||||
unsigned char EVGAGPUv2Controller::GetSpeed()
|
||||
{
|
||||
u16_to_u8 speed_16 = { (uint16_t) 0 };
|
||||
|
||||
speed_16.LSB = bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V2_REG_COLOR_A_ONTIME_LSB);
|
||||
speed_16.MSB = bus->i2c_smbus_read_byte_data(dev, EVGA_GPU_V2_REG_COLOR_A_ONTIME_MSB);
|
||||
|
||||
speed_16.u16 /= SPEED_MULTIPLIER;
|
||||
|
||||
return (unsigned char) speed_16.u16;
|
||||
}
|
||||
|
||||
void EVGAGPUv2Controller::SetMode(unsigned char mode, RGBColor color1, RGBColor color2, unsigned int speed)
|
||||
{
|
||||
bool boolSave = false;
|
||||
|
||||
EnableWrite(true);
|
||||
switch (mode)
|
||||
{
|
||||
case EVGA_GPU_V2_RGB_MODE_OFF:
|
||||
{
|
||||
SendMode(EVGA_GPU_V2_MODE_OFF);
|
||||
boolSave = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case EVGA_GPU_V2_RGB_MODE_DIRECT:
|
||||
case EVGA_GPU_V2_RGB_MODE_STATIC:
|
||||
{
|
||||
SendMode(EVGA_GPU_V2_MODE_DIRECT);
|
||||
//Static is mode 0x01 but with SaveSettings()
|
||||
boolSave = (mode == EVGA_GPU_V2_RGB_MODE_STATIC);
|
||||
|
||||
SendColor(EVGA_GPU_V2_REG_COLOR_A_RED, RGBGetRValue(color1), RGBGetGValue(color1), RGBGetBValue(color1));
|
||||
}
|
||||
break;
|
||||
|
||||
case EVGA_GPU_V2_RGB_MODE_RAINBOW:
|
||||
{
|
||||
SendMode(EVGA_GPU_V2_MODE_RAINBOW);
|
||||
//OpenRGB does not do brightness yet
|
||||
SendBrightness(0x64); //Default = 0x64
|
||||
// Set Rainbow speed? No control in the GUI but this register is only set in Ranbow mode.
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x19, 0x11);
|
||||
|
||||
boolSave = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case EVGA_GPU_V2_RGB_MODE_BREATHING:
|
||||
case EVGA_GPU_V2_RGB_MODE_PULSE:
|
||||
{
|
||||
SendMode(EVGA_GPU_V2_MODE_BREATHING);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| It is expected that color2 will be 0x000000 (black) for |
|
||||
| 1 color mode otherwise set correctly therfore no further |
|
||||
| inspection is required. |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
SendColor(EVGA_GPU_V2_REG_COLOR_A_RED, RGBGetRValue(color1), RGBGetGValue(color1), RGBGetBValue(color1));
|
||||
SendColor(EVGA_GPU_V2_REG_COLOR_B_RED, RGBGetRValue(color2), RGBGetGValue(color2), RGBGetBValue(color2));
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Breathing mode speeds are consistent for B_TO_A and A_TO_B |
|
||||
| Pulse (Blink) mode is on/off ergo B_TO_A and A_TO_B = 0 (instant) |
|
||||
\*-----------------------------------------------------------------*/
|
||||
u16_to_u8 speed_16 = { (uint16_t) (speed * SPEED_MULTIPLIER) };
|
||||
u16_to_u8 rise_fall_un_16 = { (mode == EVGA_GPU_V2_RGB_MODE_PULSE) ? (uint16_t) 0 : speed_16.u16 };
|
||||
SendSpeed(speed_16, speed_16, rise_fall_un_16, rise_fall_un_16, rise_fall_un_16);
|
||||
|
||||
// 0x61 = 0x01
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x61, 0x01);
|
||||
// 0x6A and 0x6B = 0x00
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x6A, 0x00);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x6B, 0x00);
|
||||
|
||||
boolSave = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//Disable writes and Save (if applicable)
|
||||
EnableWrite(false);
|
||||
|
||||
if(boolSave)
|
||||
{
|
||||
SaveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
void EVGAGPUv2Controller::EnableWrite(bool boolEnable)
|
||||
{
|
||||
if(boolEnable)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xE5);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xE9);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xF5);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xF9);
|
||||
}
|
||||
else
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x08, 0x01);
|
||||
//Dissable commands
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xF0);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xE0);
|
||||
}
|
||||
}
|
||||
|
||||
void EVGAGPUv2Controller::SaveSettings()
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xE5);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xE9);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xF0);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x1F, 0xE5);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x23, 0xE5);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xE0);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0E, 0xE0);
|
||||
}
|
||||
|
||||
void EVGAGPUv2Controller::SendBrightness(unsigned char brightness)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_V2_REG_COLOR_A_BRIGHTNESS, brightness);
|
||||
}
|
||||
|
||||
void EVGAGPUv2Controller::SendColor(unsigned char start_register, unsigned char red, unsigned char green, unsigned char blue, unsigned char brightness)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, start_register, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, (start_register + 1), green);
|
||||
bus->i2c_smbus_write_byte_data(dev, (start_register + 2), blue);
|
||||
bus->i2c_smbus_write_byte_data(dev, (start_register + 3), brightness);
|
||||
}
|
||||
|
||||
void EVGAGPUv2Controller::SendMode(unsigned char mode)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_V2_REG_MODE, mode);
|
||||
}
|
||||
|
||||
void EVGAGPUv2Controller::SendSpeed(u16_to_u8 aOnTime, u16_to_u8 bOnTime, u16_to_u8 b2a, u16_to_u8 a2b, u16_to_u8 speed_un)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_V2_REG_COLOR_B_UN_LSB, (unsigned char) speed_un.LSB );
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_V2_REG_COLOR_B_UN_MSB, (unsigned char) speed_un.MSB );
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_V2_REG_B_TO_A_SPEED_LSB, (unsigned char) b2a.LSB );
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_V2_REG_B_TO_A_SPEED_MSB, (unsigned char) b2a.MSB );
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_V2_REG_COLOR_B_ONTIME_LSB, (unsigned char) bOnTime.LSB );
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_V2_REG_COLOR_B_ONTIME_MSB, (unsigned char) bOnTime.MSB );
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_V2_REG_A_TO_B_SPEED_LSB, (unsigned char) a2b.LSB );
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_V2_REG_A_TO_B_SPEED_MSB, (unsigned char) a2b.MSB );
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_V2_REG_COLOR_A_ONTIME_LSB, (unsigned char) aOnTime.LSB );
|
||||
bus->i2c_smbus_write_byte_data(dev, EVGA_GPU_V2_REG_COLOR_A_ONTIME_MSB, (unsigned char) aOnTime.MSB );
|
||||
}
|
||||
|
||||
void EVGAGPUv2Controller::SetColor(RGBColor colorA, RGBColor colorB, bool boolSave)
|
||||
{
|
||||
EnableWrite(true);
|
||||
SendColor(EVGA_GPU_V2_REG_COLOR_A_RED, RGBGetRValue(colorA), RGBGetGValue(colorA), RGBGetBValue(colorA), 0x64);
|
||||
SendColor(EVGA_GPU_V2_REG_COLOR_B_RED, RGBGetRValue(colorB), RGBGetGValue(colorB), RGBGetBValue(colorB), 0x64);
|
||||
EnableWrite(false);
|
||||
|
||||
if(boolSave)
|
||||
{
|
||||
SaveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,37 +4,80 @@
|
||||
| Definitions and types for EVGA GPU RGB |
|
||||
| V2 (Turing) lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 9/13/2020 |
|
||||
| TheRogueZeta 4/15/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
#include "RGBController.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char evga_dev_id;
|
||||
|
||||
#define SPEED_MULTIPLIER 10
|
||||
|
||||
enum
|
||||
{
|
||||
EVGA_GPU_V2_REG_MODE = 0x60,
|
||||
EVGA_GPU_V2_REG_COLOR_A_RED = 0x6C,
|
||||
EVGA_GPU_V2_REG_COLOR_A_GREEN = 0x6D,
|
||||
EVGA_GPU_V2_REG_COLOR_A_BLUE = 0x6E,
|
||||
EVGA_GPU_V2_REG_COLOR_A_BRIGHTNESS = 0x6F,
|
||||
EVGA_GPU_V2_REG_COLOR_B_RED = 0x70,
|
||||
EVGA_GPU_V2_REG_COLOR_B_GREEN = 0x71,
|
||||
EVGA_GPU_V2_REG_COLOR_B_BLUE = 0x72,
|
||||
EVGA_GPU_V2_REG_COLOR_B_BRIGHTNESS = 0x73,
|
||||
EVGA_GPU_V2_REG_MODE = 0x60,
|
||||
EVGA_GPU_V2_REG_A_TO_B_SPEED_LSB = 0x62,
|
||||
EVGA_GPU_V2_REG_A_TO_B_SPEED_MSB = 0x63,
|
||||
EVGA_GPU_V2_REG_B_TO_A_SPEED_LSB = 0x64,
|
||||
EVGA_GPU_V2_REG_B_TO_A_SPEED_MSB = 0x65,
|
||||
EVGA_GPU_V2_REG_COLOR_A_ONTIME_LSB = 0x66,
|
||||
EVGA_GPU_V2_REG_COLOR_A_ONTIME_MSB = 0x67,
|
||||
EVGA_GPU_V2_REG_COLOR_B_ONTIME_LSB = 0x68,
|
||||
EVGA_GPU_V2_REG_COLOR_B_ONTIME_MSB = 0x69,
|
||||
EVGA_GPU_V2_REG_COLOR_A_RED = 0x6C,
|
||||
EVGA_GPU_V2_REG_COLOR_A_GREEN = 0x6D,
|
||||
EVGA_GPU_V2_REG_COLOR_A_BLUE = 0x6E,
|
||||
EVGA_GPU_V2_REG_COLOR_A_BRIGHTNESS = 0x6F,
|
||||
EVGA_GPU_V2_REG_COLOR_B_RED = 0x70,
|
||||
EVGA_GPU_V2_REG_COLOR_B_GREEN = 0x71,
|
||||
EVGA_GPU_V2_REG_COLOR_B_BLUE = 0x72,
|
||||
EVGA_GPU_V2_REG_COLOR_B_BRIGHTNESS = 0x73,
|
||||
EVGA_GPU_V2_REG_COLOR_B_UN_LSB = 0x74,
|
||||
EVGA_GPU_V2_REG_COLOR_B_UN_MSB = 0x75,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EVGA_GPU_V2_MODE_OFF = 0x00,
|
||||
EVGA_GPU_V2_MODE_CUSTOM = 0x01,
|
||||
EVGA_GPU_V2_MODE_RAINBOW = 0x0F,
|
||||
EVGA_GPU_V2_MODE_BREATHING = 0x22,
|
||||
EVGA_GPU_V2_RGB_MODE_OFF = 0x00,
|
||||
EVGA_GPU_V2_RGB_MODE_DIRECT = 0x01,
|
||||
EVGA_GPU_V2_RGB_MODE_STATIC = 0x02,
|
||||
EVGA_GPU_V2_RGB_MODE_RAINBOW = 0x03,
|
||||
EVGA_GPU_V2_RGB_MODE_BREATHING = 0x04,
|
||||
EVGA_GPU_V2_RGB_MODE_PULSE = 0x05,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EVGA_GPU_V2_MODE_OFF = 0x00,
|
||||
EVGA_GPU_V2_MODE_DIRECT = 0x01,
|
||||
EVGA_GPU_V2_MODE_RAINBOW = 0x0F,
|
||||
EVGA_GPU_V2_MODE_BREATHING = 0x22,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EVGA_GPU_V2_SPEED_BREATHING_SLOWEST = 0x7D,
|
||||
EVGA_GPU_V2_SPEED_BREATHING_NORMAL = 0x4B,
|
||||
EVGA_GPU_V2_SPEED_BREATHING_FASTEST = 0x19,
|
||||
EVGA_GPU_V2_SPEED_PULSE_SLOWEST = 0xFA,
|
||||
EVGA_GPU_V2_SPEED_PULSE_NORMAL = 0x96,
|
||||
EVGA_GPU_V2_SPEED_PULSE_FASTEST = 0x32,
|
||||
};
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint16_t u16;
|
||||
struct
|
||||
{
|
||||
uint8_t LSB;
|
||||
uint8_t MSB;
|
||||
};
|
||||
} u16_to_u8;
|
||||
|
||||
class EVGAGPUv2Controller
|
||||
{
|
||||
public:
|
||||
@@ -43,15 +86,23 @@ public:
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
|
||||
unsigned char GetRed();
|
||||
unsigned char GetGreen();
|
||||
unsigned char GetBlue();
|
||||
unsigned char GetBrightnessA();
|
||||
RGBColor GetColorA();
|
||||
RGBColor GetColorB();
|
||||
unsigned char GetMode();
|
||||
unsigned char GetSpeed();
|
||||
|
||||
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetMode(unsigned char mode);
|
||||
void SetColor(RGBColor colorA, RGBColor colorB, bool boolSave);
|
||||
void SetMode(unsigned char mode, RGBColor color1, RGBColor color2, unsigned int speed);
|
||||
|
||||
private:
|
||||
void EnableWrite(bool enable);
|
||||
void SaveSettings();
|
||||
void SendBrightness(unsigned char brightness = 0x64);
|
||||
void SendColor(unsigned char start_register, unsigned char red, unsigned char green, unsigned char blue, unsigned char brightness = 0x64);
|
||||
void SendMode(unsigned char mode);
|
||||
void SendSpeed(u16_to_u8 aOnTime, u16_to_u8 bOnTime, u16_to_u8 b2a, u16_to_u8 a2b, u16_to_u8 speed_un);
|
||||
|
||||
i2c_smbus_interface* bus;
|
||||
evga_dev_id dev;
|
||||
|
||||
};
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
| RGBController_EVGAGPUv2.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB EVGA |
|
||||
| GPU V2 (Pascal) Driver |
|
||||
| GPU V2 (Turing) Driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 9/13/2020 |
|
||||
| TheRogueZeta 4/15/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_EVGAGPUv2.h"
|
||||
@@ -13,45 +13,101 @@ RGBController_EVGAGPUv2::RGBController_EVGAGPUv2(EVGAGPUv2Controller* evga_ptr)
|
||||
{
|
||||
evga = evga_ptr;
|
||||
|
||||
name = "EVGA GPU";
|
||||
vendor = "EVGA";
|
||||
description = "EVGA RGB v2 GPU Device";
|
||||
location = evga->GetDeviceLocation();
|
||||
name = "EVGA GPU";
|
||||
vendor = "EVGA";
|
||||
description = "EVGA Turing RGB GPU Device";
|
||||
location = evga->GetDeviceLocation();
|
||||
|
||||
type = DEVICE_TYPE_GPU;
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = EVGA_GPU_V2_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
Off.name = "Off";
|
||||
Off.value = EVGA_GPU_V2_RGB_MODE_OFF;
|
||||
Off.flags = 0; //pretty sure not needed
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = EVGA_GPU_V2_MODE_CUSTOM;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = EVGA_GPU_V2_RGB_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
Direct.colors_min = 1;
|
||||
Direct.colors_max = 1;
|
||||
modes.push_back(Direct);
|
||||
|
||||
// mode Rainbow;
|
||||
// Rainbow.name = "Rainbow";
|
||||
// Rainbow.value = EVGA_GPU_V2_MODE_RAINBOW;
|
||||
// Rainbow.flags = 0;
|
||||
// Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
// modes.push_back(Rainbow);
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = EVGA_GPU_V2_RGB_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Spectrum Cycle";
|
||||
Rainbow.value = EVGA_GPU_V2_RGB_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = EVGA_GPU_V2_RGB_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Breathing.speed_min = EVGA_GPU_V2_SPEED_BREATHING_SLOWEST;
|
||||
Breathing.speed = EVGA_GPU_V2_SPEED_BREATHING_NORMAL;
|
||||
Breathing.speed_max = EVGA_GPU_V2_SPEED_BREATHING_FASTEST;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 2;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Pulse;
|
||||
Pulse.name = "Flashing";
|
||||
Pulse.value = EVGA_GPU_V2_RGB_MODE_PULSE;
|
||||
Pulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Pulse.speed_min = EVGA_GPU_V2_SPEED_PULSE_SLOWEST;
|
||||
Pulse.speed = EVGA_GPU_V2_SPEED_PULSE_NORMAL;
|
||||
Pulse.speed_max = EVGA_GPU_V2_SPEED_PULSE_FASTEST;
|
||||
Pulse.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Pulse.colors_min = 1;
|
||||
Pulse.colors_max = 2;
|
||||
Pulse.colors.resize(1);
|
||||
modes.push_back(Pulse);
|
||||
|
||||
// mode Breathing;
|
||||
// Breathing.name = "Breathing";
|
||||
// Breathing.value = EVGA_GPU_V2_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 = 0;
|
||||
active_mode = getModeIndex(evga->GetMode());
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| The LED color (color[0]) will always be set. Mode colors |
|
||||
| are only set for the MODE_COLORS_MODE_SPECIFIC modes and |
|
||||
| by extension colorB is only necessary if its not black |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
colors[0] = evga->GetColorA();
|
||||
RGBColor colorB = evga->GetColorB();
|
||||
|
||||
int breathing_mode_index = getModeIndex(EVGA_GPU_V2_RGB_MODE_BREATHING);
|
||||
int pulse_mode_index = getModeIndex(EVGA_GPU_V2_RGB_MODE_PULSE);
|
||||
|
||||
// Pre fill in colors for mode specific colors
|
||||
modes[breathing_mode_index].colors[0] = colors[0];
|
||||
modes[pulse_mode_index].colors[0] = colors[0];
|
||||
// Add colors if colorB is not equal to 0.
|
||||
if(colorB != 0)
|
||||
{
|
||||
modes[breathing_mode_index].colors.push_back(colorB);
|
||||
modes[pulse_mode_index].colors.push_back(colorB);
|
||||
}
|
||||
|
||||
// Load speed settings from the card:
|
||||
modes[active_mode].speed = evga->GetSpeed();
|
||||
}
|
||||
|
||||
RGBController_EVGAGPUv2::~RGBController_EVGAGPUv2()
|
||||
@@ -59,6 +115,17 @@ RGBController_EVGAGPUv2::~RGBController_EVGAGPUv2()
|
||||
delete evga;
|
||||
}
|
||||
|
||||
int RGBController_EVGAGPUv2::getModeIndex(unsigned char 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_EVGAGPUv2::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
@@ -95,12 +162,12 @@ void RGBController_EVGAGPUv2::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
|
||||
void RGBController_EVGAGPUv2::DeviceUpdateLEDs()
|
||||
{
|
||||
RGBColor color = colors[0];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
/*---------------------------------------------------------*\
|
||||
| DeviceUpdateLEDs() is only used in MODE_COLORS_PER_LED |
|
||||
| modes and as such colorB will always be black (0x000000) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
evga->SetColor(red, grn, blu);
|
||||
evga->SetColor(colors[0], 0, (modes[active_mode].value != EVGA_GPU_V2_RGB_MODE_DIRECT) );
|
||||
}
|
||||
|
||||
void RGBController_EVGAGPUv2::UpdateZoneLEDs(int /*zone*/)
|
||||
@@ -115,10 +182,25 @@ void RGBController_EVGAGPUv2::UpdateSingleLED(int /*led*/)
|
||||
|
||||
void RGBController_EVGAGPUv2::SetCustomMode()
|
||||
{
|
||||
active_mode = 1;
|
||||
active_mode = getModeIndex(EVGA_GPU_V2_MODE_DIRECT);
|
||||
}
|
||||
|
||||
void RGBController_EVGAGPUv2::DeviceUpdateMode()
|
||||
{
|
||||
evga->SetMode((unsigned char)modes[(unsigned int)active_mode].value);
|
||||
/*---------------------------------------------------------*\
|
||||
| Modes with MODE_COLORS_MODE_SPECIFIC may have either |
|
||||
| 1 or 2 colors associated with it. The device controller |
|
||||
| expects colorB as black (0x000000) in 1 color scenarios |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
RGBColor colorA = colors[0];
|
||||
RGBColor colorB = 0;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
colorA = modes[active_mode].colors[0];
|
||||
colorB = (modes[active_mode].colors.size() == 2) ? modes[active_mode].colors[1] : 0 ;
|
||||
}
|
||||
|
||||
evga->SetMode( modes[active_mode].value, colorA, colorB, modes[active_mode].speed);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| EVGA GPU RGB V2 (Turing) Driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 9/13/2020 |
|
||||
| TheRogueZeta 4/15/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
@@ -30,5 +30,6 @@ public:
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
int getModeIndex(unsigned char mode_value);
|
||||
EVGAGPUv2Controller* evga;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user