Publish LumaOps source

This commit is contained in:
LumaOps release export
2026-09-03 01:18:36 +02:00
commit 7f1c0e5f71
2363 changed files with 501543 additions and 0 deletions
@@ -0,0 +1,340 @@
/*---------------------------------------------------------*\
| PatriotViperController.cpp |
| |
| Driver for Patriot Viper RAM |
| |
| Adam Honse (CalcProgrammer1) 01 Jan 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include "PatriotViperController.h"
PatriotViperController::PatriotViperController(i2c_smbus_interface* bus, viper_dev_id dev, unsigned char slots)
{
this->bus = bus;
this->dev = dev;
slots_valid = slots;
strcpy(device_name, "Patriot Viper RGB");
led_count = 0;
for(int i = 0; i < 8; i++)
{
if((slots_valid & (1 << i)) != 0)
{
led_count += 5;
}
}
keepalive_thread = NULL;
keepalive_thread_run = 1;
}
PatriotViperController::~PatriotViperController()
{
StopKeepaliveThread();
}
std::string PatriotViperController::GetDeviceName()
{
return(device_name);
}
std::string PatriotViperController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return("I2C: " + return_string);
}
unsigned int PatriotViperController::GetLEDCount()
{
return(led_count);
}
unsigned int PatriotViperController::GetSlotCount()
{
unsigned int slot_count = 0;
for(int slot = 0; slot < 4; slot++)
{
if((slots_valid & (1 << slot)) != 0)
{
slot_count++;
}
}
return(slot_count);
}
unsigned int PatriotViperController::GetMode()
{
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, speed);
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)
{
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);
}
void PatriotViperController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
ViperRegisterWrite(VIPER_REG_LED0_EFFECT_COLOR + led, red, blue, green);
}
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, speed);
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)
{
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_LED0_DIRECT_COLOR + led, red, blue, green);
ViperRegisterWrite(VIPER_REG_APPLY, 0x01, 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, speed);
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
}
void PatriotViperController::SetMode(unsigned char new_mode, unsigned char new_speed, unsigned int color_mode)
{
StopKeepaliveThread();
direct = false;
mode = new_mode;
if(mode_speed[mode] == -1)
{
speed = new_speed;
}
else
{
speed = mode_speed[mode];
}
if(color_mode == 3)
{
/*--------------------------------------------------------------------------------------------------*\
| Reset previously set mode color, because we want RAM sticks to fall-back to automatic viper colors |
| These are not just rainbowey, but they are affected differently with modes. |
\*--------------------------------------------------------------------------------------------------*/
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_MODE, VIPER_MODE_DARK, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
}
if(mode_steps[mode] == -1)
{
/*--------------------------------------------------------------------------------------------------*\
| Based on a header file, if number of steps in mode is -1 it means mode is not synced, |
| doesn't have steps and the Keepalive thread is not needed. Set the mode directly and leave it. |
\*--------------------------------------------------------------------------------------------------*/
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, speed);
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
}
else
{
/*----------------------------------------------------------------*\
| Reset step counters and fire up Keepalive thread. |
| Thread will deal with changing the mode and everything else. |
\*----------------------------------------------------------------*/
step = 0;
sub_step = 0;
keepalive_thread = new std::thread(&PatriotViperController::KeepaliveThread, this);
}
}
void PatriotViperController::SetDirect()
{
StopKeepaliveThread();
direct = true;
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_MODE, VIPER_MODE_DIRECT, 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);
}
void PatriotViperController::KeepaliveThread()
{
while(keepalive_thread_run.load())
{
int cur_step = step.load();
int cur_sub_step = sub_step.load();
if(cur_sub_step == 0)
{
ViperRegisterWrite(VIPER_REG_MODE, mode, cur_step, speed);
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, cur_sub_step);
}
else
{
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, cur_sub_step);
}
if(cur_sub_step == mode_sub_steps[mode])
{
sub_step.store(0);
if(cur_step == mode_steps[mode])
{
step.store(0);
}
else
{
step.store(cur_step+1);
}
}
else
{
sub_step.store(cur_sub_step+1);
}
/*---------------------------------------------------------------------------------------------------------*\
| We have to use wait_for with condition_variable since some of the modes will keep the thread waiting for |
| long time and we don't want to make user wait for mode change when in middle of waiting period. |
\*---------------------------------------------------------------------------------------------------------*/
int delay = GetDelay(mode, cur_step, cur_sub_step, cur_sub_step == mode_sub_steps[mode]);
std::unique_lock<std::mutex> l(thread_ctrl_m);
thread_ctrl.wait_for(l, std::chrono::milliseconds(delay));
}
}
void PatriotViperController::StopKeepaliveThread()
{
if(keepalive_thread != NULL)
{
keepalive_thread_run = 0;
thread_ctrl.notify_one();
keepalive_thread->join();
keepalive_thread = NULL;
keepalive_thread_run = 1;
}
}
unsigned int PatriotViperController::GetDelay(unsigned char mode, unsigned int /*step*/, unsigned int sub_step, bool loop_end)
{
if(loop_end)
{
if(mode == VIPER_MODE_VIPER)
{
return 7000;
}
else if(mode == VIPER_MODE_BREATHING)
{
return 3000;
}
else if(mode == VIPER_MODE_NEON)
{
return 600;
}
else if(mode == VIPER_MODE_AURORA)
{
return 300;
}
else
{
return 0;
}
}
if(sub_step == 0)
{
if(mode == VIPER_MODE_VIPER)
{
return 3000;
}
else if(mode == VIPER_MODE_BREATHING)
{
return 3000;
}
else
{
return 0;
}
}
else
{
if(sub_step == 4 && mode == VIPER_MODE_VIPER)
{
return 1000;
}
else if(sub_step == 5 && mode == VIPER_MODE_VIPER)
{
return 590;
}
else if(mode == VIPER_MODE_NEON)
{
return 600;
}
else if(mode == VIPER_MODE_HEARTBEAT)
{
return 100;
}
else if(mode == VIPER_MODE_MARQUEE)
{
return 300;
}
else
{
return 0;
}
}
}
@@ -0,0 +1,148 @@
/*---------------------------------------------------------*\
| PatriotViperController.h |
| |
| Driver for Patriot Viper RAM |
| |
| Adam Honse (CalcProgrammer1) 01 Jan 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <map>
#include <string>
#include "i2c_smbus.h"
typedef unsigned char viper_dev_id;
typedef unsigned char 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_DIRECT = 0x07, /* Direct mode */
VIPER_MODE_NEON = 0x08, /* Color cycle 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:
PatriotViperController(i2c_smbus_interface* bus, viper_dev_id dev, unsigned char slots);
~PatriotViperController();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetLEDCount();
unsigned int GetSlotCount();
unsigned int GetMode();
void SetMode(unsigned char new_mode, unsigned char new_speed, unsigned int color_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 KeepaliveThread();
void StopKeepaliveThread();
unsigned int GetDelay(unsigned char mode, unsigned int step, unsigned int sub_step, bool loop_end);
void ViperRegisterWrite(viper_register reg, unsigned char val0, unsigned char val1, unsigned char val2);
bool direct;
private:
char device_name[32];
unsigned int led_count;
unsigned char slots_valid;
i2c_smbus_interface* bus;
viper_dev_id dev;
unsigned char mode;
unsigned char speed;
std::thread* keepalive_thread;
std::atomic<bool> keepalive_thread_run;
std::atomic<int> step;
std::atomic<int> sub_step;
std::condition_variable thread_ctrl;
std::mutex thread_ctrl_m;
/*-------------------------------------------------------*\
| Value -1 means mode is not synced, doesn't have steps |
| and the Keepalive thread is not needed |
\*-------------------------------------------------------*/
std::map <int, int> mode_steps =
{
{VIPER_MODE_DARK, -1},
{VIPER_MODE_BREATHING, 4},
{VIPER_MODE_VIPER, 4},
{VIPER_MODE_HEARTBEAT, 6},
{VIPER_MODE_MARQUEE, 3},
{VIPER_MODE_RAINDROP, -1},
{VIPER_MODE_AURORA, 4},
{VIPER_MODE_NEON, 0},
};
std::map <int, int> mode_sub_steps =
{
{VIPER_MODE_DARK, -1},
{VIPER_MODE_BREATHING, 1},
{VIPER_MODE_VIPER, 6},
{VIPER_MODE_HEARTBEAT, 59},
{VIPER_MODE_MARQUEE, 30},
{VIPER_MODE_RAINDROP, -1},
{VIPER_MODE_AURORA, 0},
{VIPER_MODE_NEON, 5},
};
std::map <int, int> mode_speed =
{
{VIPER_MODE_DARK, -1},
{VIPER_MODE_BREATHING, 0x06},
{VIPER_MODE_VIPER, 0x3C},
{VIPER_MODE_HEARTBEAT, 0x3C},
{VIPER_MODE_MARQUEE, 0x3C},
{VIPER_MODE_RAINDROP, -1},
{VIPER_MODE_AURORA, 0x3C},
{VIPER_MODE_NEON, 0x3C},
};
};
@@ -0,0 +1,96 @@
/*---------------------------------------------------------*\
| PatriotViperControllerDetect.cpp |
| |
| Detector for Patriot Viper RAM |
| |
| Adam Honse (CalcProgrammer1) 01 Jan 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <vector>
#include "Detector.h"
#include "PatriotViperController.h"
#include "LogManager.h"
#include "RGBController_PatriotViper.h"
#include "i2c_smbus.h"
#include "pci_ids.h"
using namespace std::chrono_literals;
#define PATRIOT_CONTROLLER_NAME "Patriot Viper"
/******************************************************************************************\
* *
* TestForPatriotViperController *
* *
* Tests the given address to see if a Patriot Viper controller exists there. *
* *
\******************************************************************************************/
bool TestForPatriotViperController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
LOG_DEBUG("[%s] Writing at address %02X, res=%02X", PATRIOT_CONTROLLER_NAME, address, res);
if (res >= 0)
{
pass = true;
}
return(pass);
} /* TestForPatriotViperController() */
/******************************************************************************************\
* *
* DetectPatriotViperControllers *
* *
* Detect Patriot Viper RGB controllers on the enumerated I2C busses. *
* *
* bus - pointer to i2c_smbus_interface where Aura device is connected *
* dev - I2C address of Aura device *
* *
\******************************************************************************************/
void DetectPatriotViperControllers(i2c_smbus_interface* bus, std::vector<SPDWrapper*> &slots, const std::string &/*name*/)
{
unsigned char slots_valid = 0x00;
// Check for Patriot Viper controller at 0x77
LOG_DEBUG("[%s] Testing bus %d at address 0x77", PATRIOT_CONTROLLER_NAME, bus->port_id);
if(TestForPatriotViperController(bus, 0x77))
{
for(SPDWrapper *slot : slots)
{
if((slot->manufacturer_data(0x00) == 0x4D)
&&(slot->manufacturer_data(0x01) == 0x49)
&&(slot->manufacturer_data(0x02) == 0x43)
&&(slot->manufacturer_data(0x03) == 0x53)
&&(slot->manufacturer_data(0x04) == 0x59)
&&(slot->manufacturer_data(0x05) == 0x53)
&&(slot->manufacturer_data(0x06) == 0x5f)
&&(slot->manufacturer_data(0x07) == 0x44))
{
LOG_DEBUG("[%s] The RAM module detected in slot %d", PATRIOT_CONTROLLER_NAME, slot->index());
slots_valid |= (1 << (slot->index()));
}
}
if(slots_valid != 0)
{
PatriotViperController* controller = new PatriotViperController(bus, 0x77, slots_valid);
RGBController_PatriotViper* rgb_controller = new RGBController_PatriotViper(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
} /* DetectPatriotViperControllers() */
REGISTER_I2C_DIMM_DETECTOR(PATRIOT_CONTROLLER_NAME, DetectPatriotViperControllers, JEDEC_PATRIOT, SPD_DDR4_SDRAM);
@@ -0,0 +1,227 @@
/*---------------------------------------------------------*\
| RGBController_PatriotViper.cpp |
| |
| RGBController for Patriot Viper RAM |
| |
| Adam Honse (CalcProgrammer1) 01 Jan 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_PatriotViper.h"
/**------------------------------------------------------------------*\
@name Patriot Viper
@category RAM
@type I2C
@save :x:
@direct :white_check_mark:
@effects :white_check_mark:
@detectors DetectPatriotViperControllers
@comment
\*-------------------------------------------------------------------*/
RGBController_PatriotViper::RGBController_PatriotViper(PatriotViperController* viper_ptr)
{
viper = viper_ptr;
name = viper->GetDeviceName();
vendor = "Patriot";
type = DEVICE_TYPE_DRAM;
description = "Patriot Viper Device";
location = viper->GetDeviceLocation();
mode Direct;
Direct.name = "Direct";
Direct.value = 0xFFFF;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.speed_min = 0;
Direct.speed_max = 0;
Direct.speed = 0;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
mode Dark;
Dark.name = "Dark";
Dark.value = VIPER_MODE_DARK;
Dark.flags = 0;
Dark.speed_min = 0;
Dark.speed_max = 0;
Dark.speed = 0;
Dark.color_mode = MODE_COLORS_NONE;
modes.push_back(Dark);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = VIPER_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Breathing.speed_min = 0x06;
Breathing.speed_max = 0x06;
Breathing.speed = 0x06;
Breathing.color_mode = MODE_COLORS_RANDOM;
modes.push_back(Breathing);
mode Viper;
Viper.name = "Viper";
Viper.value = VIPER_MODE_VIPER;
Viper.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Viper.speed_min = 0x3C;
Viper.speed_max = 0x3C;
Viper.speed = 0x3C;
Viper.color_mode = MODE_COLORS_RANDOM;
modes.push_back(Viper);
mode Heartbeat;
Heartbeat.name = "Heartbeat";
Heartbeat.value = VIPER_MODE_HEARTBEAT;
Heartbeat.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Heartbeat.speed_min = 0x3C;
Heartbeat.speed_max = 0x3C;
Heartbeat.speed = 0x3C;
Heartbeat.color_mode = MODE_COLORS_RANDOM;
modes.push_back(Heartbeat);
mode Marquee;
Marquee.name = "Marquee";
Marquee.value = VIPER_MODE_MARQUEE;
Marquee.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Marquee.speed_min = 0x3C;
Marquee.speed_max = 0x3C;
Marquee.speed = 0x3C;
Marquee.color_mode = MODE_COLORS_RANDOM;
modes.push_back(Marquee);
mode Raindrop;
Raindrop.name = "Raindrop";
Raindrop.value = VIPER_MODE_RAINDROP;
Raindrop.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Raindrop.speed_min = VIPER_SPEED_MIN;
Raindrop.speed_max = VIPER_SPEED_MAX;
Raindrop.speed = VIPER_SPEED_DEFAULT;
Raindrop.color_mode = MODE_COLORS_RANDOM;
modes.push_back(Raindrop);
mode Aurora;
Aurora.name = "Aurora";
Aurora.value = VIPER_MODE_AURORA;
Aurora.flags = MODE_FLAG_HAS_RANDOM_COLOR;
Aurora.speed_min = 0x3C;
Aurora.speed_max = 0x3C;
Aurora.speed = 0x3C;
Aurora.color_mode = MODE_COLORS_RANDOM;
modes.push_back(Aurora);
mode Neon;
Neon.name = "Neon";
Neon.value = VIPER_MODE_NEON;
Neon.flags = MODE_FLAG_HAS_RANDOM_COLOR;
Neon.speed_min = 0x3C;
Neon.speed_max = 0x3C;
Neon.speed = 0x3C;
Neon.color_mode = MODE_COLORS_RANDOM;
modes.push_back(Neon);
SetupZones();
}
RGBController_PatriotViper::~RGBController_PatriotViper()
{
delete viper;
}
void RGBController_PatriotViper::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zones |
\*---------------------------------------------------------*/
zone* new_zone = new zone;
new_zone->name = "Patriot Viper RGB";
new_zone->type = ZONE_TYPE_LINEAR;
new_zone->leds_min = 5;
new_zone->leds_max = 5;
new_zone->leds_count = 5;
new_zone->matrix_map = NULL;
zones.push_back(*new_zone);
/*---------------------------------------------------------*\
| Set up LEDs |
\*---------------------------------------------------------*/
for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++)
{
led* new_led = new led();
new_led->name = "Patriot Viper RGB LED ";
new_led->name.append(std::to_string(led_idx + 1));
leds.push_back(*new_led);
}
SetupColors();
}
void RGBController_PatriotViper::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_PatriotViper::DeviceUpdateLEDs()
{
if(viper->direct == true)
{
for(int led = 0; led < 5; led++)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
viper->SetLEDColor(led, red, grn, blu);
}
}
else
{
for(int led = 0; led < 5; led++)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
viper->SetLEDEffectColor(led, red, grn, blu);
}
}
}
void RGBController_PatriotViper::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_PatriotViper::UpdateSingleLED(int led)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
if(viper->direct == true)
{
viper->SetLEDColor(led, red, grn, blu);
}
else
{
viper->SetLEDEffectColor(led, red, grn, blu);
}
}
void RGBController_PatriotViper::DeviceUpdateMode()
{
if(modes[active_mode].value == 0xFFFF)
{
viper->SetDirect();
}
else
{
viper->SetMode(modes[active_mode].value, modes[active_mode].speed, modes[active_mode].color_mode);
}
}
@@ -0,0 +1,34 @@
/*---------------------------------------------------------*\
| RGBController_PatriotViper.h |
| |
| RGBController for Patriot Viper RAM |
| |
| Adam Honse (CalcProgrammer1) 01 Jan 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "PatriotViperController.h"
class RGBController_PatriotViper : public RGBController
{
public:
RGBController_PatriotViper(PatriotViperController* viper_ptr);
~RGBController_PatriotViper();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
PatriotViperController* viper;
};