diff --git a/.gitlab/CODEOWNERS b/.gitlab/CODEOWNERS index 80cf0f32..35ebbe7b 100644 --- a/.gitlab/CODEOWNERS +++ b/.gitlab/CODEOWNERS @@ -22,13 +22,12 @@ CODEOWNERS @Calcprogrammer1 /Controllers/BlinkyTapeController/ /Controllers/CoolerMasterController/ @Dr_No /Controllers/CorsairCommanderCoreController/ -/Controllers/CorsairDominatorPlatinumController/ +/Controllers/CorsairDRAMController/ /Controllers/CorsairHydroController/ /Controllers/CorsairHydroPlatinumController/ /Controllers/CorsairLightingNodeController/ /Controllers/CorsairPeripheralController/ /Controllers/CorsairVengeanceController/ -/Controllers/CorsairVengeanceProController/ /Controllers/CorsairWirelessController/ /Controllers/CreativeController/ /Controllers/CrucialController/ diff --git a/Controllers/CorsairDRAMController/CorsairDRAMController.cpp b/Controllers/CorsairDRAMController/CorsairDRAMController.cpp new file mode 100644 index 00000000..831f49e6 --- /dev/null +++ b/Controllers/CorsairDRAMController/CorsairDRAMController.cpp @@ -0,0 +1,422 @@ +/*---------------------------------------------------------*\ +| CorsairDRAMController.cpp | +| | +| Driver for Corsair DRAM RGB controllers | +| | +| Adam Honse (CalcProgrammer1) 30 Jun 2019 | +| Erik Gilling (konkers) 25 Sep 2020 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#include "CRC.h" +#include "CorsairDRAMController.h" +#include "LogManager.h" + +#define CORSAIR_DRAM_NAME "Corsair DRAM" + +using namespace std::chrono_literals; + +CorsairDRAMController::CorsairDRAMController(i2c_smbus_interface *bus, corsair_dev_id dev) +{ + /*-----------------------------------------------------*\ + | Initialize class variables | + \*-----------------------------------------------------*/ + this->bus = bus; + this->dev = dev; + device_index = 0; + pid = 0; + vid = 0; + protocol_version = 0; + + /*-----------------------------------------------------*\ + | Read device information | + \*-----------------------------------------------------*/ + ReadDeviceInfo(); +} + +CorsairDRAMController::~CorsairDRAMController() +{ +} + +unsigned int CorsairDRAMController::GetLEDCount() +{ + return(corsair_dram_device_list[device_index]->led_count); +} + +unsigned char CorsairDRAMController::GetProtocolVersion() +{ + return(protocol_version); +} + +std::string CorsairDRAMController::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); +} + +std::string CorsairDRAMController::GetDeviceName() +{ + return(corsair_dram_device_list[device_index]->name); +} + +std::string CorsairDRAMController::GetDeviceVersion() +{ + return(firmware_version); +} + +void CorsairDRAMController::SetColorsPerLED(RGBColor* colors) +{ + /*-----------------------------------------------------*\ + | Get LED count from device list | + \*-----------------------------------------------------*/ + unsigned int led_count = corsair_dram_device_list[device_index]->led_count; + + if(direct_mode) + { + /*-------------------------------------------------*\ + | Sanity check - Direct mode can only be used on | + | protocol 4+ | + \*-------------------------------------------------*/ + if(protocol_version < 4) + { + LOG_ERROR("[%s] Protocol version %d tried to use direct mode, ignoring", CORSAIR_DRAM_NAME, protocol_version); + return; + } + + /*-------------------------------------------------*\ + | Packet format: | + | Size n is (LED count * 3) + 2 | + | 0: Command byte (0x0A or 0x0C) | + | 1 to (n-2): LED color data in R/G/B order | + | (n-1): CRC8 of bytes 0 to (n-2) | + \*-------------------------------------------------*/ + unsigned int direct_packet_size = (led_count * 3) + 2; + unsigned char* direct_packet = new unsigned char[direct_packet_size]; + + /*-------------------------------------------------*\ + | First byte in packet is LED count | + \*-------------------------------------------------*/ + direct_packet[0] = led_count; + + /*-------------------------------------------------*\ + | Fill in LED data | + \*-------------------------------------------------*/ + for(unsigned int led_idx = 0; led_idx < led_count; led_idx++) + { + unsigned int color_index = led_idx; + unsigned int offset = (led_idx * 3) + 1; + + if(corsair_dram_device_list[device_index]->reverse) + { + color_index = led_count - led_idx; + } + + direct_packet[offset + 0] = RGBGetRValue(colors[color_index]); + direct_packet[offset + 1] = RGBGetGValue(colors[color_index]); + direct_packet[offset + 2] = RGBGetBValue(colors[color_index]); + } + + /*-------------------------------------------------*\ + | Last byte in packet is CRC of all data up to it | + \*-------------------------------------------------*/ + direct_packet[direct_packet_size - 1] = CRCPP::CRC::Calculate(direct_packet, (direct_packet_size - 1), CRCPP::CRC::CRC_8()); + + /*-------------------------------------------------*\ + | Write using block writes, if packet exceeds 32 | + | bytes, use a second block write to the second | + | block write address for the remaining data | + \*-------------------------------------------------*/ + bus->i2c_smbus_write_block_data(dev, CORSAIR_DRAM_REG_COLOR_BUFFER_BLOCK_1, 32, direct_packet); + + if(direct_packet_size > 32) + { + bus->i2c_smbus_write_block_data(dev, CORSAIR_DRAM_REG_COLOR_BUFFER_BLOCK_2, direct_packet_size - 32, direct_packet + 32); + } + + /*-------------------------------------------------*\ + | Remember to delete the data buffer | + \*-------------------------------------------------*/ + delete[] direct_packet; + } + else + { + /*-------------------------------------------------*\ + | Local variables | + \*-------------------------------------------------*/ + unsigned char device_crc; + unsigned char calc_crc; + + /*-------------------------------------------------*\ + | Packet format: | + | Size n is (LED count * 4) | + | Format is 0xRR, 0xGG, 0xBB, 0xFF for each LED | + \*-------------------------------------------------*/ + unsigned int color_data_size = (led_count * 4); + unsigned char* color_data_packet = new unsigned char[color_data_size]; + + for(unsigned int led_idx = 0; led_idx < led_count; led_idx++) + { + unsigned int color_index = led_idx; + + if(corsair_dram_device_list[device_index]->reverse) + { + color_index = led_count - led_idx; + } + + color_data_packet[(led_idx * 4) + 0] = RGBGetRValue(colors[color_index]); + color_data_packet[(led_idx * 4) + 1] = RGBGetGValue(colors[color_index]); + color_data_packet[(led_idx * 4) + 2] = RGBGetBValue(colors[color_index]); + color_data_packet[(led_idx * 4) + 3] = 0xFF; + } + + /*-------------------------------------------------*\ + | Write LED color data packet | + \*-------------------------------------------------*/ + bus->i2c_smbus_write_byte_data(dev, CORSAIR_DRAM_REG_RESET_BUFFER, 0x00); + bus->i2c_smbus_write_byte_data(dev, CORSAIR_DRAM_REG_BINARY_START, 0x00); + + for(unsigned int i = 0; i < color_data_size; i++) + { + bus->i2c_smbus_write_byte_data(dev, CORSAIR_DRAM_REG_SET_BINARY_DATA, color_data_packet[i]); + } + + /*-------------------------------------------------*\ + | Calculate CRC and read CRC reported by device | + \*-------------------------------------------------*/ + calc_crc = CRCPP::CRC::Calculate(color_data_packet, color_data_size, CRCPP::CRC::CRC_8()); + device_crc = bus->i2c_smbus_read_byte_data(dev, CORSAIR_DRAM_REG_GET_CHECKSUM); + + /*-------------------------------------------------*\ + | Write effect configuration only if CRCs match | + \*-------------------------------------------------*/ + if(calc_crc == device_crc) + { + bus->i2c_smbus_write_byte_data(dev, CORSAIR_DRAM_REG_WRITE_CONFIGURATION, CORSAIR_DRAM_ID_COLOR_DATA); + WaitReady(); + } + + /*-------------------------------------------------*\ + | Remember to delete the data buffer | + \*-------------------------------------------------*/ + delete[] color_data_packet; + } +} + +void CorsairDRAMController::SetDirect(bool direct) +{ + direct_mode = direct; +} + +void CorsairDRAMController::SetEffect + ( + unsigned char mode, + unsigned char speed, + unsigned char direction, + bool random, + unsigned char brightness, + unsigned char red1, + unsigned char grn1, + unsigned char blu1, + unsigned char red2, + unsigned char grn2, + unsigned char blu2 + ) +{ + /*-----------------------------------------------------*\ + | Local variables | + \*-----------------------------------------------------*/ + unsigned char effect_data[20]; + unsigned char device_crc; + unsigned char calc_crc; + unsigned char random_byte; + + /*-----------------------------------------------------*\ + | If mode is direct (which is a dummy value not | + | understood by the hardware), return. Direct mode is | + | not set in the effect configuration. | + \*-----------------------------------------------------*/ + direct_mode = (mode == CORSAIR_DRAM_MODE_DIRECT); + + if(direct_mode) + { + return; + } + + /*-----------------------------------------------------*\ + | Determine random byte | + \*-----------------------------------------------------*/ + if(random) + { + random_byte = CORSAIR_DRAM_EFFECT_RANDOM_COLORS; + } + else + { + random_byte = CORSAIR_DRAM_EFFECT_CUSTOM_COLORS; + } + + /*-----------------------------------------------------*\ + | Fill in effect packet | + \*-----------------------------------------------------*/ + effect_data[0] = mode; // Mode + effect_data[1] = speed; // Speed + effect_data[2] = random_byte; // Custom color + effect_data[3] = direction; // Direction + effect_data[4] = red1; // Custom color 1 red + effect_data[5] = grn1; // Custom color 1 green + effect_data[6] = blu1; // Custom color 1 blue + effect_data[7] = brightness; + effect_data[8] = red2; // Custom color 2 red + effect_data[9] = grn2; // Custom color 2 green + effect_data[10] = blu2; // Custom color 2 blue + effect_data[11] = brightness; + effect_data[12] = 0x00; + effect_data[13] = 0x00; + effect_data[14] = 0x00; + effect_data[15] = 0x00; + effect_data[16] = 0x00; + effect_data[17] = 0x00; + effect_data[18] = 0x00; + effect_data[19] = 0x00; + + /*-----------------------------------------------------*\ + | Write effect packet | + \*-----------------------------------------------------*/ + bus->i2c_smbus_write_byte_data(dev, CORSAIR_DRAM_REG_RESET_BUFFER, 0x00); + bus->i2c_smbus_write_byte_data(dev, CORSAIR_DRAM_REG_BINARY_START, 0x00); + + for(unsigned int i = 0; i < 20; i++) + { + bus->i2c_smbus_write_byte_data(dev, CORSAIR_DRAM_REG_SET_BINARY_DATA, effect_data[i]); + } + + /*-----------------------------------------------------*\ + | Calculate CRC and read CRC reported by device | + \*-----------------------------------------------------*/ + calc_crc = CRCPP::CRC::Calculate(effect_data, sizeof(effect_data), CRCPP::CRC::CRC_8()); + device_crc = bus->i2c_smbus_read_byte_data(dev, CORSAIR_DRAM_REG_GET_CHECKSUM); + + /*-----------------------------------------------------*\ + | Write effect configuration only if CRCs match | + \*-----------------------------------------------------*/ + if(calc_crc == device_crc) + { + bus->i2c_smbus_write_byte_data(dev, CORSAIR_DRAM_REG_WRITE_CONFIGURATION, CORSAIR_DRAM_ID_EFFECT_CONFIGURATION); + WaitReady(); + } +} + +bool CorsairDRAMController::WaitReady() +{ + /*-----------------------------------------------------*\ + | Poll status register 0x30; bit 3 (0x08) = busy. | + | Device is ready when bit 3 is clear. | + \*-----------------------------------------------------*/ + for(int retry = 0; retry < 5; retry++) + { + int status = bus->i2c_smbus_read_byte_data(dev, CORSAIR_DRAM_REG_STATUS); + + if(status >= 0 && (status & 0x08) == 0) + { + return true; + } + + std::this_thread::sleep_for(10ms); + } + + return false; +} + +void CorsairDRAMController::ReadDeviceInfo() +{ + unsigned char device_information_data[32]; + unsigned char device_crc; + unsigned char calc_crc; + + /*-----------------------------------------------------*\ + | Request Device Information Data | + \*-----------------------------------------------------*/ + bus->i2c_smbus_write_byte_data(dev, CORSAIR_DRAM_REG_GET_DEVICE_INFO, 0x00); + bus->i2c_smbus_write_byte_data(dev, CORSAIR_DRAM_REG_BINARY_START, 0x00); + + /*-----------------------------------------------------*\ + | Read Device Information Data | + \*-----------------------------------------------------*/ + for(unsigned int i = 0; i < 32; i++) + { + device_information_data[i] = bus->i2c_smbus_read_byte_data(dev, CORSAIR_DRAM_REG_GET_BINARY_DATA); + } + + /*-----------------------------------------------------*\ + | Compare CRC | + \*-----------------------------------------------------*/ + calc_crc = CRCPP::CRC::Calculate(device_information_data, sizeof(device_information_data), CRCPP::CRC::CRC_8()); + device_crc = bus->i2c_smbus_read_byte_data(dev, CORSAIR_DRAM_REG_GET_CHECKSUM); + + if(calc_crc != device_crc) + { + LOG_ERROR("[%s] ReadDeviceInfo CRC Mismatch", CORSAIR_DRAM_NAME); + } + + /*-----------------------------------------------------*\ + | Log Device Information Data | + \*-----------------------------------------------------*/ + if(LogManager::get()->getLoglevel() >= LL_TRACE) + { + char device_info_buf[256]; + unsigned int pos; + + pos = snprintf(device_info_buf, sizeof(device_info_buf), "%02X: ", dev); + + for(unsigned int i = 0; i < 32; i++) + { + pos += snprintf(&device_info_buf[pos], sizeof(device_info_buf) - pos, "%02X ", device_information_data[i]); + } + + LOG_TRACE("[%s] Device Info: %s", CORSAIR_DRAM_NAME, device_info_buf); + } + + /*-----------------------------------------------------*\ + | Read VID | + \*-----------------------------------------------------*/ + vid = (device_information_data[1] << 8) | device_information_data[0]; + + /*-----------------------------------------------------*\ + | Read PID | + \*-----------------------------------------------------*/ + pid = (device_information_data[3] << 8) | device_information_data[2]; + + /*-----------------------------------------------------*\ + | Format Firwmare Version | + \*-----------------------------------------------------*/ + firmware_version = std::to_string(device_information_data[9]) + "." + std::to_string(device_information_data[8]) + "." + std::to_string((device_information_data[11] << 8) | device_information_data[10]); + + /*-----------------------------------------------------*\ + | Read Protocol Version | + \*-----------------------------------------------------*/ + protocol_version = device_information_data[28]; + + /*-----------------------------------------------------*\ + | Loop through all known devices to look for a PID | + | match | + \*-----------------------------------------------------*/ + for(unsigned int i = 0; i < CORSAIR_DRAM_NUM_DEVICES; i++) + { + for(unsigned int j = 0; j < CORSAIR_DRAM_MAX_PIDS; j++) + { + if(corsair_dram_device_list[i]->pids[j] == pid) + { + /*-----------------------------------------*\ + | Set device ID | + \*-----------------------------------------*/ + device_index = i; + break; + } + } + } +} diff --git a/Controllers/CorsairDRAMController/CorsairDRAMController.h b/Controllers/CorsairDRAMController/CorsairDRAMController.h new file mode 100644 index 00000000..1711361b --- /dev/null +++ b/Controllers/CorsairDRAMController/CorsairDRAMController.h @@ -0,0 +1,149 @@ +/*---------------------------------------------------------*\ +| CorsairDRAMController.h | +| | +| Driver for Corsair DRAM RGB controllers | +| | +| Adam Honse (CalcProgrammer1) 30 Jun 2019 | +| Erik Gilling (konkers) 25 Sep 2020 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#pragma once + +#include +#include "i2c_smbus.h" +#include "CorsairDRAMDevices.h" +#include "RGBController.h" + +typedef unsigned char corsair_dev_id; + +enum +{ /* (*) indicates deprecated registers no longer used by iCue */ + CORSAIR_DRAM_REG_RESET_BUFFER = 0x0B, /* Reset buffer by writing 0x00 */ + CORSAIR_DRAM_REG_SET_BINARY_DATA = 0x20, /* Write byte to active binary data buffer */ + CORSAIR_DRAM_REG_BINARY_START = 0x21, /* Start binary data transfer by writing 0x00 */ + CORSAIR_DRAM_REG_SWITCH_MODE = 0x23, /* Switch between Bootloader(0x00) and Normal(0x01) */ + CORSAIR_DRAM_REG_SET_BUFFER = 0x26, /* Select configuration buffer to write by ID (*) */ + CORSAIR_DRAM_REG_STATUS = 0x30, /* Status register */ + CORSAIR_DRAM_REG_COLOR_BUFFER_BLOCK_1 = 0x31, /* Direct color buffer block register 1 */ + CORSAIR_DRAM_REG_COLOR_BUFFER_BLOCK_2 = 0x32, /* Direct color buffer block register 2 */ + CORSAIR_DRAM_REG_GET_BINARY_DATA = 0x40, /* Read byte from active binary data buffer */ + CORSAIR_DRAM_REG_BUSY_STATUS = 0x41, /* Reads nonzero while busy, zero when ready(*) */ + CORSAIR_DRAM_REG_GET_CHECKSUM = 0x42, /* Get checksum (CRC8) of active binary data buffer */ + CORSAIR_DRAM_REG_GET_DEVICE_INFO = 0x61, /* Select device info buffer */ + CORSAIR_DRAM_REG_GET_CONFIGURATION = 0x63, /* Select configuration buffer to read by ID */ + CORSAIR_DRAM_REG_WRITE_CONFIGURATION = 0x82, /* Write/Apply configuration by writing buffer ID */ +}; + +enum +{ + CORSAIR_DRAM_ID_COMMAND_LIST = 0, /* Command list */ + CORSAIR_DRAM_ID_EFFECT_CONFIGURATION = 1, /* Effect configuration */ + CORSAIR_DRAM_ID_COLOR_DATA = 2, /* Color data */ +}; + +enum +{ + CORSAIR_DRAM_MODE_DIRECT = 0xDD, /* Arbitrary value to compare against later. Not the actual packet */ + CORSAIR_DRAM_MODE_COLOR_SHIFT = 0x00, /* Color Shift mode */ + CORSAIR_DRAM_MODE_COLOR_PULSE = 0x01, /* Color Pulse mode */ + CORSAIR_DRAM_MODE_RAINBOW_WAVE = 0x03, /* Rainbow Wave mode */ + CORSAIR_DRAM_MODE_COLOR_WAVE = 0x04, /* Color Wave mode */ + CORSAIR_DRAM_MODE_VISOR = 0x05, /* Visor mode */ + CORSAIR_DRAM_MODE_RAIN = 0x06, /* Rain mode */ + CORSAIR_DRAM_MODE_MARQUEE = 0x07, /* Marquee mode */ + CORSAIR_DRAM_MODE_RAINBOW = 0x08, /* Rainbow mode */ + CORSAIR_DRAM_MODE_SEQUENTIAL = 0x09, /* Sequential mode */ + CORSAIR_DRAM_MODE_STATIC = 0x10, /* Static mode */ + + CORSAIR_DRAM_NUMBER_MODES = 10, /* Number of Corsair Pro modes */ +}; + +enum +{ + CORSAIR_DRAM_SPEED_SLOW = 0x00, /* Slow speed */ + CORSAIR_DRAM_SPEED_MEDIUM = 0x01, /* Medium speed */ + CORSAIR_DRAM_SPEED_FAST = 0x02, /* Fast speed */ +}; + +enum +{ + CORSAIR_DRAM_EFFECT_RANDOM_COLORS = 0x00, /* Random colors */ + CORSAIR_DRAM_EFFECT_CUSTOM_COLORS = 0x01, /* Custom colors */ +}; + +enum +{ + CORSAIR_DRAM_DIRECTION_UP = 0x00, /* Up direction */ + CORSAIR_DRAM_DIRECTION_DOWN = 0x01, /* Down direction */ + CORSAIR_DRAM_DIRECTION_LEFT = 0x02, /* Left direction */ + CORSAIR_DRAM_DIRECTION_RIGHT = 0x03, /* Right direction */ + CORSAIR_DRAM_DIRECTION_VERTICAL = 0x01, /* Vertical direction */ + CORSAIR_DRAM_DIRECTION_HORIZONTAL = 0x03, /* Horizontal direction */ +}; + +enum +{ + CORSAIR_DRAM_BRIGHTNESS_MIN = 0, /* Minimum brightness */ + CORSAIR_DRAM_BRIGHTNESS_MAX = 255, /* Maximum brightness */ + CORSAIR_DRAM_BRIGHTNESS_DEFAULT = 255, /* Default brightness */ +}; + +class CorsairDRAMController +{ +public: + CorsairDRAMController(i2c_smbus_interface *bus, corsair_dev_id dev); + ~CorsairDRAMController(); + + std::string GetDeviceLocation(); + std::string GetDeviceName(); + std::string GetDeviceVersion(); + + unsigned int GetLEDCount(); + unsigned char GetProtocolVersion(); + + void SetColorsPerLED(RGBColor* colors); + void SetDirect(bool direct); + void SetEffect(unsigned char mode, + unsigned char speed, + unsigned char direction, + bool random, + unsigned char brightness, + unsigned char red1, + unsigned char grn1, + unsigned char blu1, + unsigned char red2, + unsigned char grn2, + unsigned char blu2); + + bool WaitReady(); + +private: + /*-----------------------------------------------------*\ + | I2C | + \*-----------------------------------------------------*/ + i2c_smbus_interface* bus; + corsair_dev_id dev; + + /*-----------------------------------------------------*\ + | State tracking | + \*-----------------------------------------------------*/ + bool direct_mode; + + /*-----------------------------------------------------*\ + | Corsair DRAM information | + \*-----------------------------------------------------*/ + unsigned short vid; + unsigned short pid; + std::string firmware_version; + unsigned char protocol_version; + + unsigned int device_index; + + /*-----------------------------------------------------*\ + | Private functions | + \*-----------------------------------------------------*/ + void ReadDeviceInfo(); +}; diff --git a/Controllers/CorsairDRAMController/CorsairDRAMControllerDetect.cpp b/Controllers/CorsairDRAMController/CorsairDRAMControllerDetect.cpp new file mode 100644 index 00000000..0bf54ddc --- /dev/null +++ b/Controllers/CorsairDRAMController/CorsairDRAMControllerDetect.cpp @@ -0,0 +1,92 @@ +/*---------------------------------------------------------*\ +| CorsairDRAMControllerDetect.cpp | +| | +| Detector for Corsair DRAM RGB controllers | +| | +| Adam Honse (CalcProgrammer1) 30 Jun 2019 | +| Erik Gilling (konkers) 25 Sep 2020 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#include +#include "Detector.h" +#include "CorsairDRAMController.h" +#include "RGBController_CorsairDRAM.h" +#include "LogManager.h" +#include "i2c_smbus.h" +#include "pci_ids.h" + +using namespace std::chrono_literals; + +#define CORSAIR_DRAM_NAME "Corsair DRAM" + +bool TestForCorsairDRAMController(i2c_smbus_interface *bus, unsigned char address) +{ + int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE); + + LOG_DEBUG("[%s] Trying address %02X", CORSAIR_DRAM_NAME, address); + + if(res < 0) + { + LOG_DEBUG("[%s] Failed: res was %04X", CORSAIR_DRAM_NAME, res); + return false; + } + + res = bus->i2c_smbus_read_byte_data(address, 0x43); + + if(!(res == 0x1A || res == 0x1B || res == 0x1C)) + { + LOG_DEBUG("[%s] Failed: expected 0x1A, 0x1B, or 0x1C, got %04X", CORSAIR_DRAM_NAME, res); + return false; + } + + res = bus->i2c_smbus_read_byte_data(address, 0x44); + + if(!(res == 0x03 || res == 0x04)) + { + LOG_DEBUG("[%s] Failed: expected 0x03 or 0x04, got %04X", CORSAIR_DRAM_NAME, res); + return false; + } + + return true; +} + +void DetectCorsairDRAMControllers(std::vector &busses) +{ + for(unsigned int bus = 0; bus < busses.size(); bus++) + { + IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device) + { + LOG_DEBUG("[%s] Testing bus %d", CORSAIR_DRAM_NAME, bus); + + std::vector addresses; + + for(unsigned char addr = 0x58; addr <= 0x5F; addr++) + { + addresses.push_back(addr); + } + + for(unsigned char addr = 0x18; addr <= 0x1F; addr++) + { + addresses.push_back(addr); + } + + for(unsigned char addr : addresses) + { + if(TestForCorsairDRAMController(busses[bus], addr)) + { + CorsairDRAMController* controller = new CorsairDRAMController(busses[bus], addr); + RGBController_CorsairDRAM* rgb_controller = new RGBController_CorsairDRAM(controller); + + ResourceManager::get()->RegisterRGBController(rgb_controller); + } + + std::this_thread::sleep_for(10ms); + } + } + } +} + +REGISTER_I2C_DETECTOR(CORSAIR_DRAM_NAME, DetectCorsairDRAMControllers); diff --git a/Controllers/CorsairDRAMController/CorsairDRAMDevices.cpp b/Controllers/CorsairDRAMController/CorsairDRAMDevices.cpp new file mode 100644 index 00000000..6a686353 --- /dev/null +++ b/Controllers/CorsairDRAMController/CorsairDRAMDevices.cpp @@ -0,0 +1,163 @@ +/*---------------------------------------------------------*\ +| CorsairDRAMDevices.cpp | +| | +| Device list for Corsair DRAM RGB controllers | +| | +| Adam Honse (CalcProgrammer1) 07 Apr 2026 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#include "CorsairDRAMDevices.h" + +static const corsair_dram_device corsair_vengeance_pro_ddr4_device = +{ + "Corsair Vengeance RGB Pro DDR4", + { + CORSAIR_VENGEANCE_PRO_DDR4_PID_1, + CORSAIR_VENGEANCE_PRO_DDR4_PID_2, + 0, + 0, + 0, + 0, + }, + 10, + false +}; + +static const corsair_dram_device corsair_dominator_platinum_ddr4_device = +{ + "Corsair Dominator Platinum RGB DDR4", + { + CORSAIR_DOMINATOR_PLATINUM_DDR4_PID_1, + CORSAIR_DOMINATOR_PLATINUM_DDR4_PID_2, + 0, + 0, + 0, + 0, + }, + 12, + true +}; + +static const corsair_dram_device corsair_vengeance_pro_sl_ddr4_device = +{ + "Corsair Vengeance RGB Pro SL DDR4", + { + CORSAIR_VENGEANCE_PRO_SL_DDR4_PID_1, + CORSAIR_VENGEANCE_PRO_SL_DDR4_PID_2, + 0, + 0, + 0, + 0, + }, + 10, + false +}; + +static const corsair_dram_device corsair_vengeance_rs_ddr4_device = +{ + "Corsair Vengeance RGB RS DDR4", + { + CORSAIR_VENGEANCE_RS_DDR4_PID_1, + CORSAIR_VENGEANCE_RS_DDR4_PID_2, + 0, + 0, + 0, + 0, + }, + 6, + false +}; + +static const corsair_dram_device corsair_dominator_platinum_ddr5_device = +{ + "Corsair Dominator Platinum RGB DDR5", + { + CORSAIR_DOMINATOR_PLATINUM_DDR5_PID_1, + CORSAIR_DOMINATOR_PLATINUM_DDR5_PID_2, + 0, + 0, + 0, + 0, + }, + 12, + true +}; + +static const corsair_dram_device corsair_dominator_titanium_ddr5_device = +{ + "Corsair Dominator Titanium RGB DDR5", + { + CORSAIR_DOMINATOR_TITANIUM_DDR5_PID_1, + CORSAIR_DOMINATOR_TITANIUM_DDR5_PID_2, + CORSAIR_DOMINATOR_TITANIUM_DDR5_PID_3, + CORSAIR_DOMINATOR_TITANIUM_DDR5_PID_4, + 0, + 0, + }, + 12, + true +}; + +static const corsair_dram_device corsair_vengeance_ddr5_device = +{ + "Corsair Vengeance RGB DDR5", + { + CORSAIR_VENGEANCE_DDR5_PID_1, + CORSAIR_VENGEANCE_DDR5_PID_2, + CORSAIR_VENGEANCE_DDR5_PID_3, + CORSAIR_VENGEANCE_DDR5_PID_4, + CORSAIR_VENGEANCE_DDR5_PID_5, + CORSAIR_VENGEANCE_DDR5_PID_6, + }, + 10, + false +}; + +static const corsair_dram_device corsair_vengeance_shugo_series_ddr5_device = +{ + "Corsair Vengeance Shugo Series DDR5", + { + CORSAIR_VENGEANCE_SHUGO_SERIES_DDR5_PID_1, + CORSAIR_VENGEANCE_SHUGO_SERIES_DDR5_PID_2, + CORSAIR_VENGEANCE_SHUGO_SERIES_DDR5_PID_3, + CORSAIR_VENGEANCE_SHUGO_SERIES_DDR5_PID_4, + 0, + 0, + }, + 10, + false +}; + +static const corsair_dram_device corsair_vengeance_rs_ddr5_device = +{ + "Corsair Vengeance RGB RS DDR5", + { + CORSAIR_VENGEANCE_RS_DDR5_PID_1, + CORSAIR_VENGEANCE_RS_DDR5_PID_2, + 0, + 0, + 0, + 0, + }, + 6, + false +}; + +static const corsair_dram_device* device_list[] = +{ + &corsair_vengeance_pro_ddr4_device, + &corsair_dominator_platinum_ddr4_device, + &corsair_vengeance_pro_sl_ddr4_device, + &corsair_vengeance_rs_ddr4_device, + &corsair_dominator_platinum_ddr5_device, + &corsair_dominator_titanium_ddr5_device, + &corsair_vengeance_ddr5_device, + &corsair_vengeance_shugo_series_ddr5_device, + &corsair_vengeance_rs_ddr5_device, +}; + +const unsigned int CORSAIR_DRAM_NUM_DEVICES = (sizeof(device_list) / sizeof(device_list[ 0 ])); +const corsair_dram_device** corsair_dram_device_list = device_list; diff --git a/Controllers/CorsairDRAMController/CorsairDRAMDevices.h b/Controllers/CorsairDRAMController/CorsairDRAMDevices.h new file mode 100644 index 00000000..229012af --- /dev/null +++ b/Controllers/CorsairDRAMController/CorsairDRAMDevices.h @@ -0,0 +1,68 @@ +/*---------------------------------------------------------*\ +| CorsairDRAMDevices.h | +| | +| Device list for Corsair DRAM RGB controllers | +| | +| Adam Honse (CalcProgrammer1) 07 Apr 2026 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#pragma once + +#include + +/*---------------------------------------------------------*\ +| Maximum number of PIDs for a given DRAM model | +\*---------------------------------------------------------*/ +#define CORSAIR_DRAM_MAX_PIDS 6 + +/*---------------------------------------------------------*\ +| Corsair DRAM vendor ID | +\*---------------------------------------------------------*/ +#define CORSAIR_DRAM_VID 0x1B1C + +/*---------------------------------------------------------*\ +| Corsair DRAM product IDs | +\*---------------------------------------------------------*/ +#define CORSAIR_VENGEANCE_PRO_DDR4_PID_1 0x0100 +#define CORSAIR_VENGEANCE_PRO_DDR4_PID_2 0x0101 +#define CORSAIR_DOMINATOR_PLATINUM_DDR4_PID_1 0x0200 +#define CORSAIR_DOMINATOR_PLATINUM_DDR4_PID_2 0x0201 +#define CORSAIR_VENGEANCE_PRO_SL_DDR4_PID_1 0x0300 +#define CORSAIR_VENGEANCE_PRO_SL_DDR4_PID_2 0x0301 +#define CORSAIR_VENGEANCE_RS_DDR4_PID_1 0x0400 +#define CORSAIR_VENGEANCE_RS_DDR4_PID_2 0x0401 +#define CORSAIR_DOMINATOR_PLATINUM_DDR5_PID_1 0x0600 +#define CORSAIR_DOMINATOR_PLATINUM_DDR5_PID_2 0x0601 +#define CORSAIR_DOMINATOR_TITANIUM_DDR5_PID_1 0x0800 +#define CORSAIR_DOMINATOR_TITANIUM_DDR5_PID_2 0x0801 +#define CORSAIR_DOMINATOR_TITANIUM_DDR5_PID_3 0x0810 +#define CORSAIR_DOMINATOR_TITANIUM_DDR5_PID_4 0x0811 +#define CORSAIR_VENGEANCE_DDR5_PID_1 0x0700 +#define CORSAIR_VENGEANCE_DDR5_PID_2 0x0701 +#define CORSAIR_VENGEANCE_DDR5_PID_3 0x0900 +#define CORSAIR_VENGEANCE_DDR5_PID_4 0x0901 +#define CORSAIR_VENGEANCE_DDR5_PID_5 0x0910 +#define CORSAIR_VENGEANCE_DDR5_PID_6 0x0911 +#define CORSAIR_VENGEANCE_SHUGO_SERIES_DDR5_PID_1 0x0A00 +#define CORSAIR_VENGEANCE_SHUGO_SERIES_DDR5_PID_2 0x0A01 +#define CORSAIR_VENGEANCE_SHUGO_SERIES_DDR5_PID_3 0x0A10 +#define CORSAIR_VENGEANCE_SHUGO_SERIES_DDR5_PID_4 0x0A11 +#define CORSAIR_VENGEANCE_RS_DDR5_PID_1 0x0B00 +#define CORSAIR_VENGEANCE_RS_DDR5_PID_2 0x0B01 + +typedef struct +{ + std::string name; + unsigned short pids[CORSAIR_DRAM_MAX_PIDS]; + unsigned int led_count; + bool reverse; +} corsair_dram_device; + +/*-----------------------------------------------------*\ +| These constant values are defined in RazerDevices.cpp | +\*-----------------------------------------------------*/ +extern const unsigned int CORSAIR_DRAM_NUM_DEVICES; +extern const corsair_dram_device** corsair_dram_device_list; diff --git a/Controllers/CorsairDRAMController/RGBController_CorsairDRAM.cpp b/Controllers/CorsairDRAMController/RGBController_CorsairDRAM.cpp new file mode 100644 index 00000000..c0904b26 --- /dev/null +++ b/Controllers/CorsairDRAMController/RGBController_CorsairDRAM.cpp @@ -0,0 +1,330 @@ +/*---------------------------------------------------------*\ +| RGBController_CorsairDRAM.cpp | +| | +| RGBController for Corsair DRAM RGB controllers | +| | +| Adam Honse (CalcProgrammer1) 30 Jun 2019 | +| Erik Gilling (konkers) 25 Sep 2020 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#include "RGBController_CorsairDRAM.h" + +/**------------------------------------------------------------------*\ + @name Corsair DRAM + @category RAM + @type SMBus + @save :x: + @direct :white_check_mark: + @effects :x: + @detectors DetectCorsairDRAMControllers + @comment + The Corsair DRAM RGB controller chip can be found on several + Corsair memory sticks which have different LED counts. This can be controlled + by editing the Part Number in OpenRGB.json with values in the below table. + + | Part Number | LED Count | + | :---------: | --------: | + | CMG | 6 | + | CMH | 10 | + | CMN | 10 | + | CMT | 12 | +\*-------------------------------------------------------------------*/ + +RGBController_CorsairDRAM::RGBController_CorsairDRAM(CorsairDRAMController* controller_ptr) +{ + controller = controller_ptr; + + name = controller->GetDeviceName(); + vendor = "Corsair"; + type = DEVICE_TYPE_DRAM; + description = "Corsair DRAM RGB Device"; + location = controller->GetDeviceLocation(); + version = controller->GetDeviceVersion(); + + if(controller->GetProtocolVersion() >= 4) + { + mode Direct; + Direct.name = "Direct"; + Direct.value = CORSAIR_DRAM_MODE_DIRECT; + Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Direct.color_mode = MODE_COLORS_PER_LED; + modes.push_back(Direct); + } + + mode Custom; + Custom.name = "Custom"; + Custom.value = CORSAIR_DRAM_MODE_STATIC; + Custom.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_AUTOMATIC_SAVE; + Custom.color_mode = MODE_COLORS_PER_LED; + modes.push_back(Custom); + + mode ColorShift; + ColorShift.name = "Color Shift"; + ColorShift.value = CORSAIR_DRAM_MODE_COLOR_SHIFT; + ColorShift.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE; + ColorShift.color_mode = MODE_COLORS_MODE_SPECIFIC; + ColorShift.speed_min = CORSAIR_DRAM_SPEED_SLOW; + ColorShift.speed_max = CORSAIR_DRAM_SPEED_FAST; + ColorShift.speed = CORSAIR_DRAM_SPEED_SLOW; + ColorShift.brightness_min = CORSAIR_DRAM_BRIGHTNESS_MIN; + ColorShift.brightness_max = CORSAIR_DRAM_BRIGHTNESS_MAX; + ColorShift.brightness = CORSAIR_DRAM_BRIGHTNESS_DEFAULT; + ColorShift.colors_min = 2; + ColorShift.colors_max = 2; + ColorShift.colors.resize(2); + modes.push_back(ColorShift); + + mode ColorPulse; + ColorPulse.name = "Color Pulse"; + ColorPulse.value = CORSAIR_DRAM_MODE_COLOR_PULSE; + ColorPulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE; + ColorPulse.color_mode = MODE_COLORS_MODE_SPECIFIC; + ColorPulse.speed_min = CORSAIR_DRAM_SPEED_SLOW; + ColorPulse.speed_max = CORSAIR_DRAM_SPEED_FAST; + ColorPulse.speed = CORSAIR_DRAM_SPEED_SLOW; + ColorPulse.brightness_min = CORSAIR_DRAM_BRIGHTNESS_MIN; + ColorPulse.brightness_max = CORSAIR_DRAM_BRIGHTNESS_MAX; + ColorPulse.brightness = CORSAIR_DRAM_BRIGHTNESS_DEFAULT; + ColorPulse.colors_min = 2; + ColorPulse.colors_max = 2; + ColorPulse.colors.resize(2); + modes.push_back(ColorPulse); + + mode RainbowWave; + RainbowWave.name = "Rainbow Wave"; + RainbowWave.value = CORSAIR_DRAM_MODE_RAINBOW_WAVE; + RainbowWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_AUTOMATIC_SAVE; + RainbowWave.color_mode = MODE_COLORS_NONE; + RainbowWave.speed_min = CORSAIR_DRAM_SPEED_SLOW; + RainbowWave.speed_max = CORSAIR_DRAM_SPEED_FAST; + RainbowWave.speed = CORSAIR_DRAM_SPEED_SLOW; + RainbowWave.direction = MODE_DIRECTION_DOWN; + modes.push_back(RainbowWave); + + mode ColorWave; + ColorWave.name = "Color Wave"; + ColorWave.value = CORSAIR_DRAM_MODE_COLOR_WAVE; + ColorWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE; + ColorWave.color_mode = MODE_COLORS_MODE_SPECIFIC; + ColorWave.speed_min = CORSAIR_DRAM_SPEED_SLOW; + ColorWave.speed_max = CORSAIR_DRAM_SPEED_FAST; + ColorWave.speed = CORSAIR_DRAM_SPEED_SLOW; + ColorWave.direction = MODE_DIRECTION_DOWN; + ColorWave.brightness_min = CORSAIR_DRAM_BRIGHTNESS_MIN; + ColorWave.brightness_max = CORSAIR_DRAM_BRIGHTNESS_MAX; + ColorWave.brightness = CORSAIR_DRAM_BRIGHTNESS_DEFAULT; + ColorWave.colors_min = 2; + ColorWave.colors_max = 2; + ColorWave.colors.resize(2); + modes.push_back(ColorWave); + + mode Visor; + Visor.name = "Visor"; + Visor.value = CORSAIR_DRAM_MODE_VISOR; + Visor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_HV | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE; + Visor.color_mode = MODE_COLORS_MODE_SPECIFIC; + Visor.speed_min = CORSAIR_DRAM_SPEED_SLOW; + Visor.speed_max = CORSAIR_DRAM_SPEED_FAST; + Visor.speed = CORSAIR_DRAM_SPEED_SLOW; + Visor.direction = MODE_DIRECTION_VERTICAL; + Visor.brightness_min = CORSAIR_DRAM_BRIGHTNESS_MIN; + Visor.brightness_max = CORSAIR_DRAM_BRIGHTNESS_MAX; + Visor.brightness = CORSAIR_DRAM_BRIGHTNESS_DEFAULT; + Visor.colors_min = 2; + Visor.colors_max = 2; + Visor.colors.resize(2); + modes.push_back(Visor); + + mode Rain; + Rain.name = "Rain"; + Rain.value = CORSAIR_DRAM_MODE_RAIN; + Rain.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE; + Rain.color_mode = MODE_COLORS_MODE_SPECIFIC; + Rain.speed_min = CORSAIR_DRAM_SPEED_SLOW; + Rain.speed_max = CORSAIR_DRAM_SPEED_FAST; + Rain.speed = CORSAIR_DRAM_SPEED_SLOW; + Rain.direction = MODE_DIRECTION_DOWN; + Rain.brightness_min = CORSAIR_DRAM_BRIGHTNESS_MIN; + Rain.brightness_max = CORSAIR_DRAM_BRIGHTNESS_MAX; + Rain.brightness = CORSAIR_DRAM_BRIGHTNESS_DEFAULT; + Rain.colors_min = 2; + Rain.colors_max = 2; + Rain.colors.resize(2); + modes.push_back(Rain); + + mode Marquee; + Marquee.name = "Marquee"; + Marquee.value = CORSAIR_DRAM_MODE_MARQUEE; + Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE; + Marquee.color_mode = MODE_COLORS_MODE_SPECIFIC; + Marquee.speed_min = CORSAIR_DRAM_SPEED_SLOW; + Marquee.speed_max = CORSAIR_DRAM_SPEED_FAST; + Marquee.speed = CORSAIR_DRAM_SPEED_SLOW; + Marquee.brightness_min = CORSAIR_DRAM_BRIGHTNESS_MIN; + Marquee.brightness_max = CORSAIR_DRAM_BRIGHTNESS_MAX; + Marquee.brightness = CORSAIR_DRAM_BRIGHTNESS_DEFAULT; + Marquee.colors_min = 1; + Marquee.colors_max = 1; + Marquee.colors.resize(1); + modes.push_back(Marquee); + + mode Rainbow; + Rainbow.name = "Rainbow"; + Rainbow.value = CORSAIR_DRAM_MODE_RAINBOW; + Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_AUTOMATIC_SAVE; + Rainbow.color_mode = MODE_COLORS_NONE; + Rainbow.speed_min = CORSAIR_DRAM_SPEED_SLOW; + Rainbow.speed_max = CORSAIR_DRAM_SPEED_FAST; + Rainbow.speed = CORSAIR_DRAM_SPEED_SLOW; + modes.push_back(Rainbow); + + mode Sequential; + Sequential.name = "Sequential"; + Sequential.value = CORSAIR_DRAM_MODE_SEQUENTIAL; + Sequential.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE; + Sequential.color_mode = MODE_COLORS_MODE_SPECIFIC; + Sequential.speed_min = CORSAIR_DRAM_SPEED_SLOW; + Sequential.speed_max = CORSAIR_DRAM_SPEED_FAST; + Sequential.speed = CORSAIR_DRAM_SPEED_SLOW; + Sequential.direction = MODE_DIRECTION_DOWN; + Sequential.brightness_min = CORSAIR_DRAM_BRIGHTNESS_MIN; + Sequential.brightness_max = CORSAIR_DRAM_BRIGHTNESS_MAX; + Sequential.brightness = CORSAIR_DRAM_BRIGHTNESS_DEFAULT; + Sequential.colors_min = 1; + Sequential.colors_max = 1; + Sequential.colors.resize(1); + modes.push_back(Sequential); + + SetupZones(); +} + +RGBController_CorsairDRAM::~RGBController_CorsairDRAM() +{ + delete controller; +} + +void RGBController_CorsairDRAM::SetupZones() +{ + /*-----------------------------------------------------*\ + | Set up zone | + \*-----------------------------------------------------*/ + zone new_zone; + new_zone.name = "Corsair DRAM"; + new_zone.type = ZONE_TYPE_LINEAR; + new_zone.leds_min = controller->GetLEDCount(); + new_zone.leds_max = controller->GetLEDCount(); + new_zone.leds_count = controller->GetLEDCount(); + 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.name = "Corsair DRAM LED "; + new_led.name.append(std::to_string(led_idx)); + leds.push_back(new_led); + } + + SetupColors(); +} + +void RGBController_CorsairDRAM::ResizeZone(int /*zone*/, int /*new_size*/) +{ + /*-----------------------------------------------------*\ + | This device does not support resizing zones | + \*-----------------------------------------------------*/ +} + +void RGBController_CorsairDRAM::DeviceUpdateLEDs() +{ + controller->SetColorsPerLED(colors.data()); +} + +void RGBController_CorsairDRAM::UpdateZoneLEDs(int /*zone*/) +{ + DeviceUpdateLEDs(); +} + +void RGBController_CorsairDRAM::UpdateSingleLED(int /*led*/) +{ + DeviceUpdateLEDs(); +} + +void RGBController_CorsairDRAM::DeviceUpdateMode() +{ + unsigned int corsair_direction = 0; + bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM); + unsigned char mode_colors[6]; + + switch(modes[active_mode].direction) + { + case MODE_DIRECTION_LEFT: + corsair_direction = CORSAIR_DRAM_DIRECTION_LEFT; + break; + case MODE_DIRECTION_RIGHT: + corsair_direction = CORSAIR_DRAM_DIRECTION_RIGHT; + break; + case MODE_DIRECTION_UP: + corsair_direction = CORSAIR_DRAM_DIRECTION_UP; + break; + case MODE_DIRECTION_DOWN: + corsair_direction = CORSAIR_DRAM_DIRECTION_DOWN; + break; + case MODE_DIRECTION_HORIZONTAL: + corsair_direction = CORSAIR_DRAM_DIRECTION_HORIZONTAL; + break; + case MODE_DIRECTION_VERTICAL: + corsair_direction = CORSAIR_DRAM_DIRECTION_VERTICAL; + break; + } + + mode_colors[0] = 0; + mode_colors[1] = 0; + mode_colors[2] = 0; + mode_colors[3] = 0; + mode_colors[4] = 0; + mode_colors[5] = 0; + + if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC) + { + mode_colors[0] = RGBGetRValue(modes[active_mode].colors[0]); + mode_colors[1] = RGBGetGValue(modes[active_mode].colors[0]); + mode_colors[2] = RGBGetBValue(modes[active_mode].colors[0]); + + if(modes[active_mode].colors.size() == 2) + { + mode_colors[3] = RGBGetRValue(modes[active_mode].colors[1]); + mode_colors[4] = RGBGetGValue(modes[active_mode].colors[1]); + mode_colors[5] = RGBGetBValue(modes[active_mode].colors[1]); + } + } + + if(modes[active_mode].name == "Direct") + { + controller->SetDirect(true); + } + else + { + controller->SetDirect(false); + } + + controller->SetEffect(modes[active_mode].value, + modes[active_mode].speed, + corsair_direction, + random, + (unsigned char)modes[active_mode].brightness, + mode_colors[0], + mode_colors[1], + mode_colors[2], + mode_colors[3], + mode_colors[4], + mode_colors[5]); + + std::this_thread::sleep_for(std::chrono::milliseconds(15)); +} diff --git a/Controllers/CorsairDominatorPlatinumController/RGBController_CorsairDominatorPlatinum.h b/Controllers/CorsairDRAMController/RGBController_CorsairDRAM.h similarity index 61% rename from Controllers/CorsairDominatorPlatinumController/RGBController_CorsairDominatorPlatinum.h rename to Controllers/CorsairDRAMController/RGBController_CorsairDRAM.h index 56c96f28..56b3ea2f 100644 --- a/Controllers/CorsairDominatorPlatinumController/RGBController_CorsairDominatorPlatinum.h +++ b/Controllers/CorsairDRAMController/RGBController_CorsairDRAM.h @@ -1,8 +1,9 @@ /*---------------------------------------------------------*\ -| RGBController_CorsairDominatorPlatinum.h | +| RGBController_CorsairDRAM.h | | | -| RGBController for Corsair Dominator Platinum RAM | +| RGBController for Corsair DRAM RGB controllers | | | +| Adam Honse (CalcProgrammer1) 30 Jun 2019 | | Erik Gilling (konkers) 25 Sep 2020 | | | | This file is part of the OpenRGB project | @@ -12,13 +13,13 @@ #pragma once #include "RGBController.h" -#include "CorsairDominatorPlatinumController.h" +#include "CorsairDRAMController.h" -class RGBController_CorsairDominatorPlatinum : public RGBController +class RGBController_CorsairDRAM : public RGBController { public: - RGBController_CorsairDominatorPlatinum(CorsairDominatorPlatinumController* controller_ptr); - ~RGBController_CorsairDominatorPlatinum(); + RGBController_CorsairDRAM(CorsairDRAMController* controller_ptr); + ~RGBController_CorsairDRAM(); void SetupZones(); @@ -31,5 +32,5 @@ public: void DeviceUpdateMode(); private: - CorsairDominatorPlatinumController* controller; + CorsairDRAMController* controller; }; diff --git a/Controllers/CorsairDominatorPlatinumController/CorsairDominatorPlatinumController.cpp b/Controllers/CorsairDominatorPlatinumController/CorsairDominatorPlatinumController.cpp deleted file mode 100644 index ac967313..00000000 --- a/Controllers/CorsairDominatorPlatinumController/CorsairDominatorPlatinumController.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/*---------------------------------------------------------*\ -| CorsairDominatorPlatinumController.cpp | -| | -| Driver for Corsair Dominator Platinum RAM | -| | -| Erik Gilling (konkers) 25 Sep 2020 | -| | -| This file is part of the OpenRGB project | -| SPDX-License-Identifier: GPL-2.0-or-later | -\*---------------------------------------------------------*/ - -#include -#include -#include "CorsairDominatorPlatinumController.h" - -using namespace std::chrono_literals; - -CorsairDominatorPlatinumController::CorsairDominatorPlatinumController(i2c_smbus_interface *bus, corsair_dev_id dev, unsigned int leds_count, std::string dev_name) -{ - this->bus = bus; - this->dev = dev; - this->leds_count = leds_count; - this->name = dev_name; - - led_data[0] = 0xc; -} - -CorsairDominatorPlatinumController::~CorsairDominatorPlatinumController() -{ -} - -unsigned int CorsairDominatorPlatinumController::GetLEDCount() -{ - return leds_count; -} - -std::string CorsairDominatorPlatinumController::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); -} - -std::string CorsairDominatorPlatinumController::GetDeviceName() -{ - return(name); -} - -void CorsairDominatorPlatinumController::SetAllColors - ( - unsigned char red, - unsigned char green, - unsigned char blue - ) -{ - for(unsigned int led = 0; led < leds_count; led++) - { - SetLEDColor(led, red, green, blue); - } -} - -void CorsairDominatorPlatinumController::SetLEDColor - ( - unsigned int led, - unsigned char red, - unsigned char green, - unsigned char blue - ) -{ - if(led >= leds_count) - { - return; - } - - unsigned int offset = (led * 3) + 1; - led_data[offset] = red; - led_data[offset + 1] = green; - led_data[offset + 2] = blue; -} - -unsigned char CorsairDominatorPlatinumController::crc8 - ( - unsigned char init, - unsigned char poly, - unsigned char* data, - unsigned char len - ) -{ - unsigned char crc = init; - - for(unsigned int i = 0; i < len; i++) - { - unsigned char val = data[i]; - for(unsigned char mask = 0x80; mask != 0; mask >>= 1) - { - unsigned char bit; - if ((val & mask) != 0) - { - bit = (crc & 0x80) ^ 0x80; - } - else - { - bit = crc & 0x80; - } - - if (bit == 0) - { - crc <<= 1; - } - else - { - crc = (crc << 1) ^ poly; - } - } - } - - return crc; -} - -void CorsairDominatorPlatinumController::ApplyColors() -{ - unsigned char data[sizeof(led_data)]; - memcpy(data, led_data, sizeof(led_data)); - unsigned char crc = crc8(0x0, 0x7, data, sizeof(data) - 1); - data[sizeof(data) - 1] = crc; - - bus->i2c_smbus_write_block_data(dev, 0x31, 0x20, data); - std::this_thread::sleep_for(800us); - bus->i2c_smbus_write_block_data(dev, 0x32, sizeof(data) - 0x20, data + 0x20); - std::this_thread::sleep_for(200us); -} diff --git a/Controllers/CorsairDominatorPlatinumController/CorsairDominatorPlatinumController.h b/Controllers/CorsairDominatorPlatinumController/CorsairDominatorPlatinumController.h deleted file mode 100644 index 51e18968..00000000 --- a/Controllers/CorsairDominatorPlatinumController/CorsairDominatorPlatinumController.h +++ /dev/null @@ -1,44 +0,0 @@ -/*---------------------------------------------------------*\ -| CorsairDominatorPlatinumController.h | -| | -| Driver for Corsair Dominator Platinum RAM | -| | -| Erik Gilling (konkers) 25 Sep 2020 | -| | -| This file is part of the OpenRGB project | -| SPDX-License-Identifier: GPL-2.0-or-later | -\*---------------------------------------------------------*/ - -#pragma once - -#include -#include "i2c_smbus.h" - -#define CORSAIR_DOMINATOR_PLATINUM_DATA_SIZE 38 - -typedef unsigned char corsair_dev_id; - -class CorsairDominatorPlatinumController -{ -public: - CorsairDominatorPlatinumController(i2c_smbus_interface *bus, corsair_dev_id dev, unsigned int leds_count, std::string dev_name); - ~CorsairDominatorPlatinumController(); - - std::string GetDeviceLocation(); - std::string GetDeviceName(); - unsigned int GetLEDCount(); - - 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 ApplyColors(); - bool WaitReady(); - -private: - unsigned char led_data[CORSAIR_DOMINATOR_PLATINUM_DATA_SIZE]; - i2c_smbus_interface* bus; - corsair_dev_id dev; - unsigned int leds_count; - std::string name; - - static unsigned char crc8(unsigned char init, unsigned char poly, unsigned char *data, unsigned char len); -}; diff --git a/Controllers/CorsairDominatorPlatinumController/CorsairDominatorPlatinumControllerDetect.cpp b/Controllers/CorsairDominatorPlatinumController/CorsairDominatorPlatinumControllerDetect.cpp deleted file mode 100644 index 48d0fddb..00000000 --- a/Controllers/CorsairDominatorPlatinumController/CorsairDominatorPlatinumControllerDetect.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/*---------------------------------------------------------*\ -| CorsairDominatorPlatinumControllerDetect.cpp | -| | -| Detector for Corsair Dominator Platinum RAM | -| | -| Erik Gilling (konkers) 25 Sep 2020 | -| | -| This file is part of the OpenRGB project | -| SPDX-License-Identifier: GPL-2.0-or-later | -\*---------------------------------------------------------*/ - -#include -#include "Detector.h" -#include "CorsairDominatorPlatinumController.h" -#include "RGBController_CorsairDominatorPlatinum.h" -#include "SettingsManager.h" -#include "LogManager.h" -#include "i2c_smbus.h" -#include "pci_ids.h" - -using namespace std::chrono_literals; - -json corsair_dominator_models = -{ - { - "CMT", - { - {"name", "Corsair Dominator Platinum"}, - {"leds", 12} - } - }, - { - "CMH", - { - {"name", "Corsair Vengeance Pro SL"}, - {"leds", 10} - } - }, - { - "CMN", - { - {"name", "Corsair Vengeance RGB RT"}, - {"leds", 10} - } - }, - { - "CMG", - { - {"name", "Corsair Vengeance RGB RS"}, - {"leds", 6} - } - }, - { - "CMP", - { - {"name", "Corsair Dominator Titanium"}, - {"leds", 11} - } - } -}; - -#define CORSAIR_DOMINATOR_PLATINUM_NAME "Corsair Dominator Platinum" - -bool TestForCorsairDominatorPlatinumController(i2c_smbus_interface *bus, unsigned char address) -{ - int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE); - - LOG_DEBUG("[%s] Trying address %02X", CORSAIR_DOMINATOR_PLATINUM_NAME, address); - - if(res < 0) - { - LOG_DEBUG("[%s] Failed: res was %04X", CORSAIR_DOMINATOR_PLATINUM_NAME, res); - return false; - } - - res = bus->i2c_smbus_read_byte_data(address, 0x43); - - if(!(res == 0x1A || res == 0x1B)) - { - LOG_DEBUG("[%s] Failed: expected 0x1a or 0x1b, got %04X", CORSAIR_DOMINATOR_PLATINUM_NAME, res); - return false; - } - - res = bus->i2c_smbus_read_byte_data(address, 0x44); - - if(res != 0x04) - { - LOG_DEBUG("[%s] Failed: expected 0x04, got %04X", CORSAIR_DOMINATOR_PLATINUM_NAME, res); - return false; - } - - return true; -} - -/******************************************************************************************\ -* * -* DetectCorsairDominatorPlatinumControllers * -* * -* Detect Corsair Dominator Platinum controllers on the enumerated I2C busses. * -* * -* bus - pointer to i2c_smbus_interface where Aura device is connected * -* dev - I2C address of Aura device * -* * -\******************************************************************************************/ - -void DetectCorsairDominatorPlatinumControllers(std::vector &busses) -{ - SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager(); - - json corsair_dominator_settings = settings_manager->GetSettings("CorsairDominatorSettings"); - - if(!corsair_dominator_settings.contains("model")) - { - // Set default value - corsair_dominator_settings["model"] = "CMT"; - settings_manager->SetSettings("CorsairDominatorSettings", corsair_dominator_settings); - settings_manager->SaveSettings(); - } - - std::string model = corsair_dominator_settings["model"]; - - for(unsigned int bus = 0; bus < busses.size(); bus++) - { - IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device) - { - LOG_DEBUG("[%s] Testing bus %d", CORSAIR_DOMINATOR_PLATINUM_NAME, bus); - - std::vector addresses; - - for(unsigned char addr = 0x58; addr <= 0x5F; addr++) - { - addresses.push_back(addr); - } - - for(unsigned char addr = 0x18; addr <= 0x1F; addr++) - { - addresses.push_back(addr); - } - - for(unsigned char addr : addresses) - { - if(TestForCorsairDominatorPlatinumController(busses[bus], addr)) - { - unsigned int leds; - std::string name; - - if(corsair_dominator_models.contains(model)) - { - leds = corsair_dominator_models[model]["leds"]; - name = corsair_dominator_models[model]["name"]; - } - else - { - leds = corsair_dominator_models["CMT"]["leds"]; - name = corsair_dominator_models["CMT"]["name"]; - } - - LOG_DEBUG("[%s] Model: %s, Leds: %d", CORSAIR_DOMINATOR_PLATINUM_NAME, name.c_str(), leds); - - CorsairDominatorPlatinumController* controller = new CorsairDominatorPlatinumController(busses[bus], addr, leds, name); - RGBController_CorsairDominatorPlatinum* rgbcontroller = new RGBController_CorsairDominatorPlatinum(controller); - - ResourceManager::get()->RegisterRGBController(rgbcontroller); - } - - std::this_thread::sleep_for(10ms); - } - } - else - { - LOG_DEBUG("[%s] Bus %d is not a DRAM bus", CORSAIR_DOMINATOR_PLATINUM_NAME, bus); - } - } -} /* DetectCorsairDominatorPlatinumControllers() */ - -REGISTER_I2C_DETECTOR(CORSAIR_DOMINATOR_PLATINUM_NAME, DetectCorsairDominatorPlatinumControllers); diff --git a/Controllers/CorsairDominatorPlatinumController/RGBController_CorsairDominatorPlatinum.cpp b/Controllers/CorsairDominatorPlatinumController/RGBController_CorsairDominatorPlatinum.cpp deleted file mode 100644 index afd7e782..00000000 --- a/Controllers/CorsairDominatorPlatinumController/RGBController_CorsairDominatorPlatinum.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/*---------------------------------------------------------*\ -| RGBController_CorsairDominatorPlatinum.cpp | -| | -| RGBController for Corsair Dominator Platinum RAM | -| | -| Erik Gilling (konkers) 25 Sep 2020 | -| | -| This file is part of the OpenRGB project | -| SPDX-License-Identifier: GPL-2.0-or-later | -\*---------------------------------------------------------*/ - -#include "RGBController_CorsairDominatorPlatinum.h" - -/**------------------------------------------------------------------*\ - @name Corsair Dominator Platinum - @category RAM - @type SMBus - @save :x: - @direct :white_check_mark: - @effects :x: - @detectors DetectCorsairDominatorPlatinumControllers - @comment - The Corsair Dominator controller chip can be found on several - Corsair memory sticks which have different LED counts. This can be controlled - by editing the Part Number in OpenRGB.json with values in the below table. - - | Part Number | LED Count | - | :---------: | --------: | - | CMG | 6 | - | CMH | 10 | - | CMN | 10 | - | CMT | 12 | -\*-------------------------------------------------------------------*/ - -RGBController_CorsairDominatorPlatinum::RGBController_CorsairDominatorPlatinum(CorsairDominatorPlatinumController* controller_ptr) -{ - controller = controller_ptr; - - name = controller->GetDeviceName(); - vendor = "Corsair"; - type = DEVICE_TYPE_DRAM; - description = "Corsair RAM RGB Device"; - location = controller->GetDeviceLocation(); - - mode Direct; - Direct.name = "Direct"; - Direct.value = 0; - 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); - - SetupZones(); - - active_mode = 0; -} - -RGBController_CorsairDominatorPlatinum::~RGBController_CorsairDominatorPlatinum() -{ - delete controller; -} - -void RGBController_CorsairDominatorPlatinum::SetupZones() -{ - /*---------------------------------------------------------*\ - | Set up zone | - \*---------------------------------------------------------*/ - zone new_zone; - new_zone.name = "Corsair RAM Zone"; - new_zone.type = ZONE_TYPE_LINEAR; - new_zone.leds_min = controller->GetLEDCount(); - new_zone.leds_max = controller->GetLEDCount(); - new_zone.leds_count = controller->GetLEDCount(); - 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.name = "Corsair RAM LED "; - new_led.name.append(std::to_string(led_idx)); - leds.push_back(new_led); - } - - SetupColors(); -} - -void RGBController_CorsairDominatorPlatinum::ResizeZone(int /*zone*/, int /*new_size*/) -{ - /*---------------------------------------------------------*\ - | This device does not support resizing zones | - \*---------------------------------------------------------*/ -} - -void RGBController_CorsairDominatorPlatinum::DeviceUpdateLEDs() -{ - for(unsigned int led = 0; led < (unsigned int)colors.size(); led++) - { - RGBColor color = colors[led]; - unsigned char red = RGBGetRValue(color); - unsigned char grn = RGBGetGValue(color); - unsigned char blu = RGBGetBValue(color); - - controller->SetLEDColor(led, red, grn, blu); - } - - controller->ApplyColors(); -} - -void RGBController_CorsairDominatorPlatinum::UpdateZoneLEDs(int /*zone*/) -{ - DeviceUpdateLEDs(); -} - -void RGBController_CorsairDominatorPlatinum::UpdateSingleLED(int led) -{ - RGBColor color = colors[led]; - unsigned char red = RGBGetRValue(color); - unsigned char grn = RGBGetGValue(color); - unsigned char blu = RGBGetBValue(color); - - controller->SetLEDColor(led, red, grn, blu); - controller->ApplyColors(); -} - -void RGBController_CorsairDominatorPlatinum::DeviceUpdateMode() -{ - -} diff --git a/Controllers/CorsairVengeanceProController/CorsairVengeanceProController.cpp b/Controllers/CorsairVengeanceProController/CorsairVengeanceProController.cpp deleted file mode 100644 index a3740823..00000000 --- a/Controllers/CorsairVengeanceProController/CorsairVengeanceProController.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/*---------------------------------------------------------*\ -| CorsairVengeanceProController.cpp | -| | -| Driver for Corsair Vengeance Pro RGB RAM | -| | -| Adam Honse (CalcProgrammer1) 30 Jun 2019 | -| | -| This file is part of the OpenRGB project | -| SPDX-License-Identifier: GPL-2.0-or-later | -\*---------------------------------------------------------*/ - -#include -#include -#include "CorsairVengeanceProController.h" - -using namespace std::chrono_literals; - -CorsairVengeanceProController::CorsairVengeanceProController(i2c_smbus_interface* bus, corsair_dev_id dev) -{ - this->bus = bus; - this->dev = dev; - - strcpy(device_name, "Corsair Vengeance Pro RGB"); - led_count = CORSAIR_PRO_LED_COUNT; - - direct_mode = false; - effect_mode = CORSAIR_PRO_MODE_STATIC; - - for (unsigned int i = 0; i < led_count; i++) - { - led_red[i] = 0; - led_green[i] = 0; - led_blue[i] = 0; - } -} - -CorsairVengeanceProController::~CorsairVengeanceProController() -{ - -} - -std::string CorsairVengeanceProController::GetDeviceName() -{ - return(device_name); -} - -std::string CorsairVengeanceProController::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 CorsairVengeanceProController::GetLEDCount() -{ - return(led_count); -} - -unsigned char CorsairVengeanceProController::GetEffect() -{ - return(effect_mode); -} - -void CorsairVengeanceProController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue) -{ - for (unsigned int i = 0; i < led_count; i++) - { - led_red[i] = red; - led_green[i] = green; - led_blue[i] = blue; - } -} - -void CorsairVengeanceProController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue) -{ - led_red[led] = red; - led_green[led] = green; - led_blue[led] = blue; -} - -void CorsairVengeanceProController::ApplyColors() -{ - if(direct_mode) - { - unsigned char full_packet[32]; - unsigned char crc_packet[31]; - - full_packet[0] = 0x0A; - crc_packet[0] = 0x0A; - - for (int i = 0; i < 10; i++) - { - crc_packet[(i * 3) + 1] = led_red[i]; - full_packet[(i * 3) + 1] = led_red[i]; - - crc_packet[(i * 3) + 2] = led_green[i]; - full_packet[(i * 3) + 2] = led_green[i]; - - crc_packet[(i * 3) + 3] = led_blue[i]; - full_packet[(i * 3) + 3] = led_blue[i]; - } - - uint8_t footer = CRCPP::CRC::Calculate(crc_packet, 31, CRCPP::CRC::CRC_8()); - - full_packet[31] = footer; - - bus->i2c_smbus_write_block_data(dev, CORSAIR_PRO_DIRECT_COMMAND, 32, full_packet); - } - else - { - bus->i2c_smbus_write_byte_data(dev, 0x26, 0x02); - std::this_thread::sleep_for(1ms); - bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00); - std::this_thread::sleep_for(1ms); - - for (int i = 0; i < 10; i++) - { - bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, led_red[i]); - bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, led_green[i]); - bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, led_blue[i]); - bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0xFF); - } - - bus->i2c_smbus_write_byte_data(dev, 0x82, 0x02); - } -} - -void CorsairVengeanceProController::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 - ) -{ - if(mode == effect_mode) - { - return; - } - - effect_mode = mode; - - direct_mode = (effect_mode == CORSAIR_PRO_MODE_DIRECT); - - if(direct_mode) - { - return; - } - - bus->i2c_smbus_write_byte_data(dev, 0x26, 0x01); - std::this_thread::sleep_for(1ms); - bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00); - std::this_thread::sleep_for(1ms); - - 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, 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); - bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); - bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); - bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); - bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); - bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); - bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); - - bus->i2c_smbus_write_byte_data(dev, 0x82, 0x01); - WaitReady(); -} - -bool CorsairVengeanceProController::WaitReady() -{ - int i = 0; - while (bus->i2c_smbus_read_byte_data(dev, 0x41) != 0x00) - { - i++; - std::this_thread::sleep_for(1ms); - } - - return false; -} - -void CorsairVengeanceProController::SetDirect(bool direct) -{ - direct_mode = direct; -} diff --git a/Controllers/CorsairVengeanceProController/CorsairVengeanceProController.h b/Controllers/CorsairVengeanceProController/CorsairVengeanceProController.h deleted file mode 100644 index afc1b800..00000000 --- a/Controllers/CorsairVengeanceProController/CorsairVengeanceProController.h +++ /dev/null @@ -1,109 +0,0 @@ -/*---------------------------------------------------------*\ -| CorsairVengeanceProController.h | -| | -| Driver for Corsair Vengeance Pro RGB RAM | -| | -| Adam Honse (CalcProgrammer1) 30 Jun 2019 | -| | -| This file is part of the OpenRGB project | -| SPDX-License-Identifier: GPL-2.0-or-later | -\*---------------------------------------------------------*/ - -#pragma once - -#include -#include "i2c_smbus.h" -#include "CRC.h" - -typedef unsigned char corsair_dev_id; - -#define CORSAIR_PRO_LED_COUNT ( 10 ) -#define CORSAIR_VENGEANCE_RGB_PRO_NAME "Corsair Vengeance RGB PRO" - -enum -{ - CORSAIR_PRO_REG_COMMAND = 0x20, /* Command write register */ - CORSAIR_PRO_DIRECT_COMMAND = 0x31, /* Where it writes direct mode colors */ -}; - -enum -{ - CORSAIR_PRO_MODE_DIRECT = 0xDD, /* Arbitrary value to compare against later. Not the actual packet */ - CORSAIR_PRO_MODE_COLOR_SHIFT = 0x00, /* Color Shift mode */ - CORSAIR_PRO_MODE_COLOR_PULSE = 0x01, /* Color Pulse mode */ - CORSAIR_PRO_MODE_RAINBOW_WAVE = 0x03, /* Rainbow Wave mode */ - CORSAIR_PRO_MODE_COLOR_WAVE = 0x04, /* Color Wave mode */ - CORSAIR_PRO_MODE_VISOR = 0x05, /* Visor mode */ - CORSAIR_PRO_MODE_RAIN = 0x06, /* Rain mode */ - CORSAIR_PRO_MODE_MARQUEE = 0x07, /* Marquee mode */ - CORSAIR_PRO_MODE_RAINBOW = 0x08, /* Rainbow mode */ - CORSAIR_PRO_MODE_SEQUENTIAL = 0x09, /* Sequential mode */ - CORSAIR_PRO_MODE_STATIC = 0x10, /* Static mode */ - - CORSAIR_PRO_NUMBER_MODES = 10, /* Number of Corsair Pro modes */ -}; - -enum -{ - CORSAIR_PRO_SPEED_SLOW = 0x00, /* Slow speed */ - CORSAIR_PRO_SPEED_MEDIUM = 0x01, /* Medium speed */ - CORSAIR_PRO_SPEED_FAST = 0x02, /* Fast speed */ -}; - -enum -{ - CORSAIR_PRO_EFFECT_RANDOM_COLORS = 0x00, /* Random colors */ - CORSAIR_PRO_EFFECT_CUSTOM_COLORS = 0x01, /* Custom colors */ -}; - -enum -{ - CORSAIR_PRO_DIRECTION_UP = 0x00, /* Up direction */ - CORSAIR_PRO_DIRECTION_DOWN = 0x01, /* Down direction */ - CORSAIR_PRO_DIRECTION_LEFT = 0x02, /* Left direction */ - CORSAIR_PRO_DIRECTION_RIGHT = 0x03, /* Right direction */ - CORSAIR_PRO_DIRECTION_VERTICAL = 0x01, /* Vertical direction */ - CORSAIR_PRO_DIRECTION_HORIZONTAL = 0x03, /* Horizontal direction */ -}; - -class CorsairVengeanceProController -{ -public: - CorsairVengeanceProController(i2c_smbus_interface* bus, corsair_dev_id dev); - ~CorsairVengeanceProController(); - - std::string GetDeviceName(); - std::string GetDeviceLocation(); - unsigned int GetLEDCount(); - unsigned char GetEffect(); - 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); - void ApplyColors(); - bool WaitReady(); - - void SetDirect(bool direct); - -private: - char device_name[32]; - unsigned int led_count; - bool direct_mode; - unsigned char effect_mode; - unsigned char led_red[CORSAIR_PRO_LED_COUNT]; - unsigned char led_green[CORSAIR_PRO_LED_COUNT]; - unsigned char led_blue[CORSAIR_PRO_LED_COUNT]; - - i2c_smbus_interface* bus; - corsair_dev_id dev; -}; diff --git a/Controllers/CorsairVengeanceProController/CorsairVengeanceProControllerDetect.cpp b/Controllers/CorsairVengeanceProController/CorsairVengeanceProControllerDetect.cpp deleted file mode 100644 index bced901d..00000000 --- a/Controllers/CorsairVengeanceProController/CorsairVengeanceProControllerDetect.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/*---------------------------------------------------------*\ -| CorsairVengeanceProControllerDetect.cpp | -| | -| Detector for Corsair Vengeance Pro RGB RAM | -| | -| Adam Honse (CalcProgrammer1) 30 Jun 2019 | -| | -| This file is part of the OpenRGB project | -| SPDX-License-Identifier: GPL-2.0-or-later | -\*---------------------------------------------------------*/ - -#include -#include "Detector.h" -#include "CorsairVengeanceProController.h" -#include "RGBController_CorsairVengeancePro.h" -#include "i2c_smbus.h" -#include "pci_ids.h" -#include "LogManager.h" - -using namespace std::chrono_literals; - -/******************************************************************************************\ -* * -* TestForCorsairVengeanceProController * -* * -* Tests the given address to see if a Corsair Pro controller exists there. * -* * -\******************************************************************************************/ - -bool TestForCorsairVengeanceProController(i2c_smbus_interface* bus, unsigned char address) -{ - bool pass = false; - - int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE); - - LOG_DEBUG("[%s] Trying address %02X", CORSAIR_VENGEANCE_RGB_PRO_NAME, address); - - if(res >= 0) - { - pass = true; - - res = bus->i2c_smbus_read_byte_data(address, 0x43); - - if (res != 0x1C) - { - pass = false; - LOG_DEBUG("[%s] Failed: was expecting 0x1C got %02X", CORSAIR_VENGEANCE_RGB_PRO_NAME, res); - } - - res = bus->i2c_smbus_read_byte_data(address, 0x44); - - if(!((res == 0x03) || (res == 0x04))) - { - pass = false; - LOG_DEBUG("[%s] Failed: was expecting 0x03 or 0x04 got %02X", CORSAIR_VENGEANCE_RGB_PRO_NAME, res); - } - } - else - { - LOG_DEBUG("[%s] Failed: res was %04X", CORSAIR_VENGEANCE_RGB_PRO_NAME, res); - } - - std::this_thread::sleep_for(10ms); - - return(pass); - -} /* TestForCorsairVengeanceProController() */ - -/******************************************************************************************\ -* * -* DetectCorsairVengeanceProControllers * -* * -* Detect Corsair Vengeance Pro controllers on the enumerated I2C busses. * -* * -* bus - pointer to i2c_smbus_interface where Aura device is connected * -* dev - I2C address of Aura device * -* * -\******************************************************************************************/ - -void DetectCorsairVengeanceProControllers(std::vector &busses) -{ - for(unsigned int bus = 0; bus < busses.size(); bus++) - { - LOG_DEBUG("[%s] Testing bus %d", CORSAIR_VENGEANCE_RGB_PRO_NAME, bus); - - IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device) - { - for(unsigned char addr = 0x58; addr <= 0x5F; addr++) - { - if(TestForCorsairVengeanceProController(busses[bus], addr)) - { - CorsairVengeanceProController* new_controller = new CorsairVengeanceProController(busses[bus], addr); - RGBController_CorsairVengeancePro* new_rgbcontroller = new RGBController_CorsairVengeancePro(new_controller); - - ResourceManager::get()->RegisterRGBController(new_rgbcontroller); - } - } - } - else - { - LOG_DEBUG("[%s] Bus %d is not a DRAM bus", CORSAIR_VENGEANCE_RGB_PRO_NAME, bus); - } - } - -} /* DetectCorsairVengeanceProControllers() */ - -REGISTER_I2C_DETECTOR("Corsair Vengeance Pro", DetectCorsairVengeanceProControllers); diff --git a/Controllers/CorsairVengeanceProController/RGBController_CorsairVengeancePro.cpp b/Controllers/CorsairVengeanceProController/RGBController_CorsairVengeancePro.cpp deleted file mode 100644 index 625289d7..00000000 --- a/Controllers/CorsairVengeanceProController/RGBController_CorsairVengeancePro.cpp +++ /dev/null @@ -1,316 +0,0 @@ -/*---------------------------------------------------------*\ -| RGBController_CorsairVengeancePro.cpp | -| | -| RGBController for Corsair Vengeance Pro RGB RAM | -| | -| Adam Honse (CalcProgrammer1) 30 Jun 2019 | -| | -| This file is part of the OpenRGB project | -| SPDX-License-Identifier: GPL-2.0-or-later | -\*---------------------------------------------------------*/ - -#include "RGBController_CorsairVengeancePro.h" - -/**------------------------------------------------------------------*\ - @name Corsair Vengeance Pro - @category RAM - @type SMBus - @save :robot: - @direct :white_check_mark: - @effects :white_check_mark: - @detectors DetectCorsairVengeanceProControllers - @comment -\*-------------------------------------------------------------------*/ - -RGBController_CorsairVengeancePro::RGBController_CorsairVengeancePro(CorsairVengeanceProController* controller_ptr) -{ - controller = controller_ptr; - - name = controller->GetDeviceName(); - vendor = "Corsair"; - type = DEVICE_TYPE_DRAM; - description = "Corsair Vengeance Pro RGB Device"; - location = controller->GetDeviceLocation(); - - mode Direct; - Direct.name = "Direct"; - Direct.value = CORSAIR_PRO_MODE_DIRECT; - 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 Static; - Static.name = "Static"; - Static.value = CORSAIR_PRO_MODE_STATIC; - Static.flags = MODE_FLAG_HAS_PER_LED_COLOR; - Static.speed_min = 0; - Static.speed_max = 0; - Static.speed = 0; - Static.color_mode = MODE_COLORS_PER_LED; - modes.push_back(Static); - - mode ColorShift; - ColorShift.name = "Color Shift"; - ColorShift.value = CORSAIR_PRO_MODE_COLOR_SHIFT; - ColorShift.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; - ColorShift.speed_min = CORSAIR_PRO_SPEED_SLOW; - ColorShift.speed_max = CORSAIR_PRO_SPEED_FAST; - ColorShift.colors_min = 2; - ColorShift.colors_max = 2; - ColorShift.speed = CORSAIR_PRO_SPEED_SLOW; - ColorShift.color_mode = MODE_COLORS_MODE_SPECIFIC; - ColorShift.colors.resize(2); - modes.push_back(ColorShift); - - mode ColorPulse; - ColorPulse.name = "Color Pulse"; - ColorPulse.value = CORSAIR_PRO_MODE_COLOR_PULSE; - ColorPulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; - ColorPulse.speed_min = CORSAIR_PRO_SPEED_SLOW; - ColorPulse.speed_max = CORSAIR_PRO_SPEED_FAST; - ColorPulse.colors_min = 2; - ColorPulse.colors_max = 2; - ColorPulse.speed = CORSAIR_PRO_SPEED_SLOW; - ColorPulse.color_mode = MODE_COLORS_MODE_SPECIFIC; - ColorPulse.colors.resize(2); - modes.push_back(ColorPulse); - - 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.speed = CORSAIR_PRO_SPEED_SLOW; - RainbowWave.direction = MODE_DIRECTION_DOWN; - RainbowWave.color_mode = MODE_COLORS_NONE; - 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_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; - ColorWave.speed_min = CORSAIR_PRO_SPEED_SLOW; - ColorWave.speed_max = CORSAIR_PRO_SPEED_FAST; - ColorWave.colors_min = 2; - ColorWave.colors_max = 2; - ColorWave.speed = CORSAIR_PRO_SPEED_SLOW; - ColorWave.direction = MODE_DIRECTION_DOWN; - ColorWave.color_mode = MODE_COLORS_MODE_SPECIFIC; - ColorWave.colors.resize(2); - 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_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; - Visor.speed_min = CORSAIR_PRO_SPEED_SLOW; - Visor.speed_max = CORSAIR_PRO_SPEED_FAST; - Visor.colors_min = 2; - Visor.colors_max = 2; - Visor.speed = CORSAIR_PRO_SPEED_SLOW; - Visor.direction = MODE_DIRECTION_VERTICAL; - Visor.color_mode = MODE_COLORS_MODE_SPECIFIC; - Visor.colors.resize(2); - 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_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; - Rain.speed_min = CORSAIR_PRO_SPEED_SLOW; - Rain.speed_max = CORSAIR_PRO_SPEED_FAST; - Rain.colors_min = 2; - Rain.colors_max = 2; - Rain.speed = CORSAIR_PRO_SPEED_SLOW; - Rain.direction = MODE_DIRECTION_DOWN; - Rain.color_mode = MODE_COLORS_MODE_SPECIFIC; - Rain.colors.resize(2); - modes.push_back(Rain); - - mode Marquee; - Marquee.name = "Marquee"; - Marquee.value = CORSAIR_PRO_MODE_MARQUEE; - Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR; - Marquee.speed_min = CORSAIR_PRO_SPEED_SLOW; - Marquee.speed_max = CORSAIR_PRO_SPEED_FAST; - Marquee.colors_min = 1; - Marquee.colors_max = 1; - Marquee.speed = CORSAIR_PRO_SPEED_SLOW; - Marquee.color_mode = MODE_COLORS_MODE_SPECIFIC; - Marquee.colors.resize(1); - 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.speed = CORSAIR_PRO_SPEED_SLOW; - Rainbow.color_mode = MODE_COLORS_NONE; - 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_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; - Sequential.speed_min = CORSAIR_PRO_SPEED_SLOW; - Sequential.speed_max = CORSAIR_PRO_SPEED_FAST; - Sequential.colors_min = 1; - Sequential.colors_max = 1; - Sequential.speed = CORSAIR_PRO_SPEED_SLOW; - Sequential.direction = MODE_DIRECTION_DOWN; - Sequential.color_mode = MODE_COLORS_MODE_SPECIFIC; - Sequential.colors.resize(1); - modes.push_back(Sequential); - - SetupZones(); - - active_mode = 9; -} - -RGBController_CorsairVengeancePro::~RGBController_CorsairVengeancePro() -{ - delete controller; -} - -void RGBController_CorsairVengeancePro::SetupZones() -{ - /*---------------------------------------------------------*\ - | Set up zone | - \*---------------------------------------------------------*/ - zone new_zone; - new_zone.name = "Corsair Pro Zone"; - new_zone.type = ZONE_TYPE_LINEAR; - new_zone.leds_min = controller->GetLEDCount(); - new_zone.leds_max = controller->GetLEDCount(); - new_zone.leds_count = controller->GetLEDCount(); - 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 = "Corsair Pro LED "; - new_led->name.append(std::to_string(led_idx)); - leds.push_back(*new_led); - } - - SetupColors(); -} - -void RGBController_CorsairVengeancePro::ResizeZone(int /*zone*/, int /*new_size*/) -{ - /*---------------------------------------------------------*\ - | This device does not support resizing zones | - \*---------------------------------------------------------*/ -} - -void RGBController_CorsairVengeancePro::DeviceUpdateLEDs() -{ - for(unsigned int led = 0; led < (unsigned int)colors.size(); led++) - { - RGBColor color = colors[led]; - unsigned char red = RGBGetRValue(color); - unsigned char grn = RGBGetGValue(color); - unsigned char blu = RGBGetBValue(color); - controller->SetLEDColor(led, red, grn, blu); - } - - controller->ApplyColors(); -} - -void RGBController_CorsairVengeancePro::UpdateZoneLEDs(int /*zone*/) -{ - DeviceUpdateLEDs(); -} - -void RGBController_CorsairVengeancePro::UpdateSingleLED(int led) -{ - RGBColor color = colors[led]; - unsigned char red = RGBGetRValue(color); - unsigned char grn = RGBGetGValue(color); - unsigned char blu = RGBGetBValue(color); - - controller->SetLEDColor(led, red, grn, blu); - controller->ApplyColors(); -} - -void RGBController_CorsairVengeancePro::DeviceUpdateMode() -{ - unsigned int corsair_direction = 0; - bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM); - unsigned char mode_colors[6]; - - 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; - } - - mode_colors[0] = 0; - mode_colors[1] = 0; - mode_colors[2] = 0; - mode_colors[3] = 0; - mode_colors[4] = 0; - mode_colors[5] = 0; - - if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC) - { - mode_colors[0] = RGBGetRValue(modes[active_mode].colors[0]); - mode_colors[1] = RGBGetGValue(modes[active_mode].colors[0]); - mode_colors[2] = RGBGetBValue(modes[active_mode].colors[0]); - - if(modes[active_mode].colors.size() == 2) - { - mode_colors[3] = RGBGetRValue(modes[active_mode].colors[1]); - mode_colors[4] = RGBGetGValue(modes[active_mode].colors[1]); - mode_colors[5] = RGBGetBValue(modes[active_mode].colors[1]); - } - } - - if (modes[active_mode].name == "Direct") - { - controller->SetDirect(true); - } - else - { - controller->SetDirect(false); - } - - controller->SetEffect(modes[active_mode].value, - modes[active_mode].speed, - corsair_direction, - random, - mode_colors[0], - mode_colors[1], - mode_colors[2], - mode_colors[3], - mode_colors[4], - mode_colors[5]); - - std::this_thread::sleep_for(std::chrono::milliseconds(15)); -} diff --git a/Controllers/CorsairVengeanceProController/RGBController_CorsairVengeancePro.h b/Controllers/CorsairVengeanceProController/RGBController_CorsairVengeancePro.h deleted file mode 100644 index e1901388..00000000 --- a/Controllers/CorsairVengeanceProController/RGBController_CorsairVengeancePro.h +++ /dev/null @@ -1,35 +0,0 @@ -/*---------------------------------------------------------*\ -| RGBController_CorsairVengeancePro.h | -| | -| RGBController for Corsair Vengeance Pro RGB RAM | -| | -| Adam Honse (CalcProgrammer1) 30 Jun 2019 | -| | -| This file is part of the OpenRGB project | -| SPDX-License-Identifier: GPL-2.0-or-later | -\*---------------------------------------------------------*/ - -#pragma once - -#include "RGBController.h" -#include "CorsairVengeanceProController.h" - -class RGBController_CorsairVengeancePro : public RGBController -{ -public: - RGBController_CorsairVengeancePro(CorsairVengeanceProController* controller_ptr); - ~RGBController_CorsairVengeancePro(); - - void SetupZones(); - - void ResizeZone(int zone, int new_size); - - void DeviceUpdateLEDs(); - void UpdateZoneLEDs(int zone); - void UpdateSingleLED(int led); - - void DeviceUpdateMode(); - -private: - CorsairVengeanceProController* controller; -};