Add effect mode and effect color controls to Patriot Viper RGB driver
This commit is contained in:
parent
6fdf34e16f
commit
3de7150408
3 changed files with 140 additions and 50 deletions
|
|
@ -71,73 +71,105 @@ unsigned int PatriotViperController::GetSlotCount()
|
|||
|
||||
unsigned int PatriotViperController::GetMode()
|
||||
{
|
||||
return(0);
|
||||
return(mode);
|
||||
}
|
||||
|
||||
void PatriotViperController::SetEffectColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_LED0_EFFECT_COLOR, red, blue, green);
|
||||
ViperRegisterWrite(VIPER_REG_LED1_EFFECT_COLOR, red, blue, green);
|
||||
ViperRegisterWrite(VIPER_REG_LED2_EFFECT_COLOR, red, blue, green);
|
||||
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, 0xAA, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
|
||||
}
|
||||
|
||||
void PatriotViperController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, 0xFF, 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x01, 0x04);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x00, 0x00);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x30, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, green, blue);
|
||||
ViperRegisterWrite(VIPER_REG_LED0_DIRECT_COLOR, red, blue, green);
|
||||
ViperRegisterWrite(VIPER_REG_LED1_DIRECT_COLOR, red, blue, green);
|
||||
ViperRegisterWrite(VIPER_REG_LED2_DIRECT_COLOR, red, blue, green);
|
||||
ViperRegisterWrite(VIPER_REG_LED3_DIRECT_COLOR, red, blue, green);
|
||||
ViperRegisterWrite(VIPER_REG_LED4_DIRECT_COLOR, red, blue, green);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x31, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, green, blue);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x32, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, green, blue);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x33, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, green, blue);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x34, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, green, blue);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x35, 0x01);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_APPLY, 0x01, 0x00, 0x00);
|
||||
}
|
||||
|
||||
void PatriotViperController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, 0xFF, 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x01, 0x04);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_LED0_DIRECT_COLOR + led, red, blue, green);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x30 + led, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, green, blue);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x35, 0x01);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_APPLY, 0x01, 0x00, 0x00);
|
||||
}
|
||||
|
||||
void PatriotViperController::SetLEDEffectColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_LED0_EFFECT_COLOR + led, red, blue, green);
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, 0x0C);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
|
||||
}
|
||||
|
||||
void PatriotViperController::SetLEDColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, 0xFF, 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x01, 0x04);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_LED0_DIRECT_COLOR + led, red, blue, green);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x30 + led, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, green, blue);
|
||||
ViperRegisterWrite(VIPER_REG_APPLY, 0x01, 0x00, 0x00);
|
||||
}
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x35, 0x01);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x00, 0x00);
|
||||
void PatriotViperController::SetLEDEffectColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_LED0_EFFECT_COLOR + led, red, blue, green);
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, 0x0C);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
|
||||
}
|
||||
|
||||
void PatriotViperController::SetMode(unsigned char new_mode)
|
||||
{
|
||||
direct = false;
|
||||
mode = new_mode;
|
||||
|
||||
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, 0xAA, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
|
||||
}
|
||||
|
||||
void PatriotViperController::SetDirect()
|
||||
{
|
||||
direct = true;
|
||||
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_APPLY, 0x01, 0x00, 0x00);
|
||||
}
|
||||
|
||||
void PatriotViperController::ViperRegisterWrite(viper_register reg, unsigned char val0, unsigned char val1, unsigned char val2)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, reg, val0);
|
||||
bus->i2c_smbus_write_byte_data(dev, val2, val1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,36 @@
|
|||
typedef unsigned char viper_dev_id;
|
||||
typedef unsigned short viper_register;
|
||||
|
||||
enum
|
||||
{
|
||||
VIPER_REG_STATIC = 0x01, /* Set static mode */
|
||||
VIPER_REG_MODE = 0x03, /* Mode register */
|
||||
VIPER_REG_LED0_DIRECT_COLOR = 0x30, /* LED 0 Color (R, B, G) */
|
||||
VIPER_REG_LED1_DIRECT_COLOR = 0x31, /* LED 1 Color (R, B, G) */
|
||||
VIPER_REG_LED2_DIRECT_COLOR = 0x32, /* LED 2 Color (R, B, G) */
|
||||
VIPER_REG_LED3_DIRECT_COLOR = 0x33, /* LED 3 Color (R, B, G) */
|
||||
VIPER_REG_LED4_DIRECT_COLOR = 0x34, /* LED 4 Color (R, B, G) */
|
||||
VIPER_REG_APPLY = 0x35, /* Apply Changes (0x01, 0x00, 0x00) */
|
||||
VIPER_REG_LED0_EFFECT_COLOR = 0x3B, /* LED 0 Color (R, B, G) */
|
||||
VIPER_REG_LED1_EFFECT_COLOR = 0x3C, /* LED 1 Color (R, B, G) */
|
||||
VIPER_REG_LED2_EFFECT_COLOR = 0x3D, /* LED 2 Color (R, B, G) */
|
||||
VIPER_REG_LED3_EFFECT_COLOR = 0x3E, /* LED 3 Color (R, B, G) */
|
||||
VIPER_REG_LED4_EFFECT_COLOR = 0x3F, /* LED 4 Color (R, B, G) */
|
||||
VIPER_REG_START = 0xFF, /* Start Frame (0xFF, 0xFF, 0xFF) */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
VIPER_MODE_DARK = 0x00, /* Dark mode */
|
||||
VIPER_MODE_BREATHING = 0x01, /* Breathing mode */
|
||||
VIPER_MODE_VIPER = 0x02, /* Viper mode */
|
||||
VIPER_MODE_HEARTBEAT = 0x03, /* Heartbeat mode */
|
||||
VIPER_MODE_MARQUEE = 0x04, /* Marquee mode */
|
||||
VIPER_MODE_RAINDROP = 0x05, /* Raindrop mode */
|
||||
VIPER_MODE_AURORA = 0x06, /* Aurora mode */
|
||||
VIPER_MODE_NEON = 0x08, /* Neon mode */
|
||||
};
|
||||
|
||||
class PatriotViperController
|
||||
{
|
||||
public:
|
||||
|
|
@ -27,11 +57,17 @@ public:
|
|||
unsigned int GetSlotCount();
|
||||
unsigned int GetMode();
|
||||
void SetMode(unsigned char new_mode);
|
||||
void SetDirect();
|
||||
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetEffectColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDEffectColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDEffectColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
void ViperRegisterWrite(viper_register reg, unsigned char val0, unsigned char val1, unsigned char val2);
|
||||
bool direct;
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
|
|
@ -40,4 +76,4 @@ private:
|
|||
i2c_smbus_interface* bus;
|
||||
viper_dev_id dev;
|
||||
unsigned int mode;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,12 +16,19 @@ int RGBController_PatriotViper::GetMode()
|
|||
|
||||
void RGBController_PatriotViper::SetMode(int mode)
|
||||
{
|
||||
viper->SetMode(mode);
|
||||
if(mode == 0)
|
||||
{
|
||||
viper->SetDirect();
|
||||
}
|
||||
else
|
||||
{
|
||||
viper->SetMode(mode - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_PatriotViper::SetCustomMode()
|
||||
{
|
||||
viper->SetMode(0);
|
||||
viper->SetDirect();
|
||||
}
|
||||
|
||||
void RGBController_PatriotViper::SetAllLEDs(RGBColor color)
|
||||
|
|
@ -30,7 +37,7 @@ void RGBController_PatriotViper::SetAllLEDs(RGBColor color)
|
|||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if(viper->GetMode() == 0)
|
||||
if(viper->direct == true)
|
||||
{
|
||||
viper->SetAllColors(red, grn, blu);
|
||||
}
|
||||
|
|
@ -47,7 +54,7 @@ void RGBController_PatriotViper::SetAllZoneLEDs(int zone, RGBColor color)
|
|||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if(viper->GetMode() == 0)
|
||||
if(viper->direct == true)
|
||||
{
|
||||
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
|
|
@ -59,7 +66,13 @@ void RGBController_PatriotViper::SetAllZoneLEDs(int zone, RGBColor color)
|
|||
}
|
||||
else
|
||||
{
|
||||
viper->SetEffectColor(red, grn, blu);
|
||||
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
viper->SetLEDEffectColor(zones[zone].map[x][y], red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -69,13 +82,13 @@ void RGBController_PatriotViper::SetLED(int led, RGBColor color)
|
|||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if(viper->GetMode() == 0)
|
||||
if(viper->direct == true)
|
||||
{
|
||||
viper->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
viper->SetEffectColor(red, grn, blu);
|
||||
viper->SetLEDEffectColor(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -93,11 +106,20 @@ RGBController_PatriotViper::RGBController_PatriotViper(PatriotViperController* v
|
|||
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
|
||||
mode viper_modes[1];
|
||||
mode viper_modes[10];
|
||||
|
||||
viper_modes[0].name = "Direct";
|
||||
|
||||
for (int i = 0; i < 1; i++)
|
||||
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";
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
modes.push_back(viper_modes[i]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue