Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46cc9ea248 | ||
|
|
bfd8030438 | ||
|
|
af84c5bb00 | ||
|
|
3de7150408 | ||
|
|
6fdf34e16f | ||
|
|
7bdf19387d | ||
|
|
a27c614a8b | ||
|
|
b7b93ad606 | ||
|
|
dbf796256b | ||
|
|
f38b90ad52 | ||
|
|
5f3fe509a4 | ||
|
|
189bf0d7a4 | ||
|
|
60531bbf07 | ||
|
|
fd9134c911 | ||
|
|
f33f00d8a9 | ||
|
|
f2d35466a5 | ||
|
|
bce9fc929e | ||
|
|
cdaae5fb9f | ||
|
|
9fc9059b0b | ||
|
|
2c1fe31211 | ||
|
|
13f53ae4f8 |
+1
-1
@@ -1,3 +1,3 @@
|
||||
[submodule "dependencies/libe131"]
|
||||
path = dependencies/libe131
|
||||
url = https://github.com/hhromic/libe131
|
||||
url = https://github.com/CalcProgrammer1/libe131
|
||||
|
||||
@@ -12,17 +12,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
AMDWraithPrismController::AMDWraithPrismController(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
@@ -31,6 +20,7 @@ AMDWraithPrismController::AMDWraithPrismController(libusb_device_handle* dev_han
|
||||
|
||||
SendEnableCommand();
|
||||
SetRingEffectChannel(0x00);
|
||||
SendApplyCommand();
|
||||
}
|
||||
|
||||
AMDWraithPrismController::~AMDWraithPrismController()
|
||||
@@ -283,17 +273,17 @@ void AMDWraithPrismController::SendEnableCommand()
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SendRemapCommand()
|
||||
void AMDWraithPrismController::SendApplyCommand()
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x51, 0xA0, 0x01, 0x00,
|
||||
0x00, 0x03, 0x00, 0x00,
|
||||
0x05, 0x06, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x07, 0x07, 0x07,
|
||||
0x07, 0x00, 0x00, 0x00,
|
||||
0x51, 0x28, 0x00, 0x00,
|
||||
0xE0, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
void SetRingColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
void SendEnableCommand();
|
||||
void SendRemapCommand();
|
||||
void SendApplyCommand();
|
||||
void SendEffectCommand();
|
||||
|
||||
private:
|
||||
|
||||
@@ -161,7 +161,7 @@ void AuraController::SetAllColorsDirect(unsigned char red, unsigned char green,
|
||||
{
|
||||
unsigned char* colors = new unsigned char[led_count * 3];
|
||||
|
||||
for (int i = 0; i < (led_count * 3); i += 3)
|
||||
for (unsigned int i = 0; i < (led_count * 3); i += 3)
|
||||
{
|
||||
colors[i + 0] = red;
|
||||
colors[i + 1] = blue;
|
||||
@@ -177,7 +177,7 @@ void AuraController::SetAllColorsEffect(unsigned char red, unsigned char green,
|
||||
{
|
||||
unsigned char* colors = new unsigned char[led_count * 3];
|
||||
|
||||
for (int i = 0; i < (led_count * 3); i += 3)
|
||||
for (unsigned int i = 0; i < (led_count * 3); i += 3)
|
||||
{
|
||||
colors[i + 0] = red;
|
||||
colors[i + 1] = blue;
|
||||
@@ -188,7 +188,7 @@ void AuraController::SetAllColorsEffect(unsigned char red, unsigned char green,
|
||||
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
|
||||
|
||||
delete colors;
|
||||
delete[] colors;
|
||||
}
|
||||
|
||||
void AuraController::SetDirect(unsigned char direct)
|
||||
|
||||
@@ -6,6 +6,75 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
| This list contains the available SMBus addresses for mapping Aura RAM |
|
||||
\*----------------------------------------------------------------------*/
|
||||
#define AURA_RAM_ADDRESS_COUNT 17
|
||||
|
||||
static const unsigned char aura_ram_addresses[] =
|
||||
{
|
||||
0x70,
|
||||
0x71,
|
||||
0x73,
|
||||
0x74,
|
||||
0x75,
|
||||
0x76,
|
||||
0x78,
|
||||
0x79,
|
||||
0x7A,
|
||||
0x7B,
|
||||
0x7C,
|
||||
0x7D,
|
||||
0x7E,
|
||||
0x7F,
|
||||
0x4F,
|
||||
0x66,
|
||||
0x67
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------------------*\
|
||||
| This list contains the available SMBus addresses for mapping Aura motherboards |
|
||||
\*---------------------------------------------------------------------------------*/
|
||||
#define AURA_MOBO_ADDRESS_COUNT 4
|
||||
|
||||
static const unsigned char aura_mobo_addresses[] =
|
||||
{
|
||||
0x40,
|
||||
0x4E,
|
||||
0x4F,
|
||||
0x66
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* AuraRegisterWrite *
|
||||
* *
|
||||
* A standalone version of the AuraController::AuraRegisterWrite function for access *
|
||||
* to Aura devices without instancing the AuraController class or reading the config *
|
||||
* table from the device. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void AuraRegisterWrite(i2c_smbus_interface* bus, aura_dev_id dev, aura_register reg, unsigned char val)
|
||||
{
|
||||
//Write Aura register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Write Aura value
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x01, val);
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForAuraController *
|
||||
@@ -62,6 +131,8 @@ void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vecto
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
int address_list_idx = 0;
|
||||
|
||||
// Remap Aura-enabled RAM modules on 0x77
|
||||
for (unsigned int slot = 0; slot < 8; slot++)
|
||||
{
|
||||
@@ -72,54 +143,48 @@ void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vecto
|
||||
break;
|
||||
}
|
||||
|
||||
AuraController temp_controller(busses[bus], 0x77);
|
||||
do
|
||||
{
|
||||
if(address_list_idx < AURA_RAM_ADDRESS_COUNT)
|
||||
{
|
||||
res = busses[bus]->i2c_smbus_write_quick(aura_ram_addresses[address_list_idx], I2C_SMBUS_WRITE);
|
||||
address_list_idx++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
} while (res >= 0);
|
||||
|
||||
temp_controller.AuraRegisterWrite(AURA_REG_SLOT_INDEX, slot);
|
||||
temp_controller.AuraRegisterWrite(AURA_REG_I2C_ADDRESS, 0xE0 + (slot << 1));
|
||||
AuraRegisterWrite(busses[bus], 0x77, AURA_REG_SLOT_INDEX, slot);
|
||||
AuraRegisterWrite(busses[bus], 0x77, AURA_REG_I2C_ADDRESS, (aura_ram_addresses[address_list_idx] << 1));
|
||||
}
|
||||
|
||||
// Add Aura-enabled controllers at their remapped addresses
|
||||
for (unsigned int slot = 0; slot < 8; slot++)
|
||||
for (unsigned int address_list_idx = 0; address_list_idx < AURA_RAM_ADDRESS_COUNT; address_list_idx++)
|
||||
{
|
||||
if (TestForAuraController(busses[bus], 0x70 + slot))
|
||||
if (TestForAuraController(busses[bus], aura_ram_addresses[address_list_idx]))
|
||||
{
|
||||
new_aura = new AuraController(busses[bus], 0x70 + slot);
|
||||
new_aura = new AuraController(busses[bus], aura_ram_addresses[address_list_idx]);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
Sleep(1);
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x40
|
||||
if (TestForAuraController(busses[bus], 0x40))
|
||||
// Add Aura-enabled motherboard controllers
|
||||
for (unsigned int address_list_idx = 0; address_list_idx < AURA_MOBO_ADDRESS_COUNT; address_list_idx++)
|
||||
{
|
||||
new_aura = new AuraController(busses[bus], 0x40);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
if (TestForAuraController(busses[bus], aura_mobo_addresses[address_list_idx]))
|
||||
{
|
||||
new_aura = new AuraController(busses[bus], aura_mobo_addresses[address_list_idx]);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x4E
|
||||
if (TestForAuraController(busses[bus], 0x4E))
|
||||
{
|
||||
new_aura = new AuraController(busses[bus], 0x4E);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x4F
|
||||
if (TestForAuraController(busses[bus], 0x4F))
|
||||
{
|
||||
new_aura = new AuraController(busses[bus], 0x4F);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x66
|
||||
if (TestForAuraController(busses[bus], 0x66))
|
||||
{
|
||||
new_aura = new AuraController(busses[bus], 0x66);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
Sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectAuraControllers() */
|
||||
} /* DetectAuraControllers() */
|
||||
|
||||
@@ -53,7 +53,7 @@ void CorsairController::SetAllColors(unsigned char red, unsigned char green, uns
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_MODE, CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
|
||||
}
|
||||
|
||||
void CorsairController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
void CorsairController::SetLEDColor(unsigned int /*led*/, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_FADE_TIME, 0x00);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_RED_VAL, red);
|
||||
@@ -62,7 +62,7 @@ void CorsairController::SetLEDColor(unsigned int led, unsigned char red, unsigne
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_MODE, CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
|
||||
}
|
||||
|
||||
void CorsairController::SetMode(unsigned char mode)
|
||||
void CorsairController::SetMode(unsigned char /*mode*/)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_MODE, CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ CorsairProController::CorsairProController(i2c_smbus_interface* bus, corsair_dev
|
||||
strcpy(device_name, "Corsair Vengeance Pro RGB");
|
||||
led_count = CORSAIR_PRO_LED_COUNT;
|
||||
|
||||
for (int i = 0; i < led_count; i++)
|
||||
for (unsigned int i = 0; i < led_count; i++)
|
||||
{
|
||||
led_red[i] = 0;
|
||||
led_green[i] = 0;
|
||||
@@ -64,7 +64,7 @@ unsigned int CorsairProController::GetLEDCount()
|
||||
|
||||
void CorsairProController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
for (int i = 0; i < led_count; i++)
|
||||
for (unsigned int i = 0; i < led_count; i++)
|
||||
{
|
||||
led_red[i] = red;
|
||||
led_green[i] = green;
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Processing Code for NZXT Hue 2 |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 12/29/2016 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "Hue2Controller.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
Hue2Controller::Hue2Controller(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
GetStripsOnChannel(HUE_2_CHANNEL_1);
|
||||
}
|
||||
|
||||
Hue2Controller::~Hue2Controller()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int Hue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
|
||||
{
|
||||
unsigned int ret_val = 0;
|
||||
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x20, 0x03, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
int actual = 0;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
|
||||
|
||||
for(int chan = 0; chan < 4; chan++)
|
||||
{
|
||||
unsigned int start = 0x0F + (6 * chan);
|
||||
unsigned int num_leds_on_channel = 0;
|
||||
for(int dev = 0; dev < 6; dev++)
|
||||
{
|
||||
switch(usb_buf[start + dev])
|
||||
{
|
||||
case 0x01: //Hue 1 strip
|
||||
num_leds_on_channel += 10;
|
||||
break;
|
||||
|
||||
case 0x04: //Hue 2 strip
|
||||
num_leds_on_channel += 10;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
channel_leds[chan] = num_leds_on_channel;
|
||||
}
|
||||
return(ret_val);
|
||||
}
|
||||
|
||||
void Hue2Controller::SetChannelLEDs(unsigned int channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x22, 0x10, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
unsigned char usb_apply[] =
|
||||
{
|
||||
0x22, 0xA0, 0x01, 0x00,
|
||||
0x01, 0x00, 0x00, 0x28,
|
||||
0x00, 0x00, 0x80, 0x00,
|
||||
0x32, 0x00, 0x00, 0x01,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
int actual;
|
||||
|
||||
std::size_t pkt_max = 20;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set channel in USB packets |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x02] = channel;
|
||||
usb_apply[0x02] = channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send first packet for first 20 LEDs |
|
||||
\*-----------------------------------------------------*/
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = colors.size();
|
||||
}
|
||||
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
int pixel_idx = idx * 3;
|
||||
RGBColor color = colors[idx];
|
||||
usb_buf[pixel_idx + 4] = RGBGetGValue(color);
|
||||
usb_buf[pixel_idx + 5] = RGBGetRValue(color);
|
||||
usb_buf[pixel_idx + 6] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send second packet for second 20 LEDs if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int idx = 4; idx < 64; idx++)
|
||||
{
|
||||
usb_buf[idx] = 0;
|
||||
}
|
||||
|
||||
usb_buf[0x01] = 0x11;
|
||||
pkt_max = 20;
|
||||
|
||||
if (colors.size() > 20)
|
||||
{
|
||||
pkt_max = colors.size() - 20;
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
int pixel_idx = idx * 3;
|
||||
RGBColor color = colors[idx + 20];
|
||||
usb_buf[pixel_idx + 4] = RGBGetGValue(color);
|
||||
usb_buf[pixel_idx + 5] = RGBGetRValue(color);
|
||||
usb_buf[pixel_idx + 6] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send apply packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_apply, 64, &actual, 0);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Definitions for NZXT Hue 2 |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 12/29/2016 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
HUE_2_CHANNEL_ALL = 0x00, /* All channels */
|
||||
HUE_2_CHANNEL_1 = 0x01, /* Channel 1 */
|
||||
HUE_2_CHANNEL_2 = 0x02, /* Channel 2 */
|
||||
HUE_2_CHANNEL_3 = 0x03, /* Channel 3 */
|
||||
HUE_2_CHANNEL_4 = 0x04, /* Channel 4 */
|
||||
HUE_2_NUM_CHANNELS = 0x04 /* Number of channels */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HUE_2_CHANNEL_1_IDX = 0x00, /* Channel 1 array index */
|
||||
HUE_2_CHANNEL_2_IDX = 0x01, /* Channel 2 array index */
|
||||
HUE_2_CHANNEL_3_IDX = 0x01, /* Channel 3 array index */
|
||||
HUE_2_CHANNEL_4_IDX = 0x01, /* Channel 4 array index */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HUE_2_MODE_FIXED = 0x00, /* Fixed colors mode */
|
||||
HUE_2_MODE_FADING = 0x01, /* Fading mode */
|
||||
HUE_2_MODE_SPECTRUM = 0x02, /* Spectrum cycle mode */
|
||||
HUE_2_MODE_MARQUEE = 0x03, /* Marquee mode */
|
||||
HUE_2_MODE_COVER_MARQUEE = 0x04, /* Cover marquee mode */
|
||||
HUE_2_MODE_ALTERNATING = 0x05, /* Alternating mode */
|
||||
HUE_2_MODE_PULSING = 0x06, /* Pulsing mode */
|
||||
HUE_2_MODE_BREATHING = 0x07, /* Breathing mode */
|
||||
HUE_2_NUM_MODES /* Number of Hue 2 modes */
|
||||
};
|
||||
|
||||
class Hue2Controller
|
||||
{
|
||||
public:
|
||||
Hue2Controller(libusb_device_handle* dev_handle);
|
||||
~Hue2Controller();
|
||||
|
||||
char* GetLEDString();
|
||||
unsigned int GetStripsOnChannel(unsigned int channel);
|
||||
void SetChannelLEDs(unsigned int channel, std::vector<RGBColor> colors);
|
||||
|
||||
unsigned int channel_leds[HUE_2_NUM_CHANNELS];
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "Hue2Controller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_Hue2.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#define NZXT_HUE_2_VID 0x1E71
|
||||
#define NZXT_HUE_2_PID 0x2001
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectHue2Controllers *
|
||||
* *
|
||||
* Detect devices supported by the Hue2 driver *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectHue2Controllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
|
||||
//Look for NZXT Hue 2
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, NZXT_HUE_2_VID, NZXT_HUE_2_PID);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
|
||||
Hue2Controller* controller = new Hue2Controller(dev);
|
||||
|
||||
RGBController_Hue2* rgb_controller = new RGBController_Hue2(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
} /* DetectHuePlusControllers() */
|
||||
@@ -96,7 +96,7 @@ void HuePlusController::SetChannelLEDs(unsigned int channel, std::vector<RGBColo
|
||||
serial_buf[i] = 0x00;
|
||||
}
|
||||
|
||||
for (int idx = 0; idx < (colors.size() * 3); idx += 3)
|
||||
for (unsigned int idx = 0; idx < (colors.size() * 3); idx += 3)
|
||||
{
|
||||
int pixel_idx = idx / 3;
|
||||
RGBColor color = colors[pixel_idx];
|
||||
@@ -111,4 +111,4 @@ void HuePlusController::SetChannelLEDs(unsigned int channel, std::vector<RGBColo
|
||||
delete[] serial_buf;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,8 @@
|
||||
#include "HuePlusController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_HuePlus.h"
|
||||
#include "find_usb_serial_port.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -29,60 +17,13 @@ void DetectHuePlusControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
HuePlusController* new_hueplus;
|
||||
RGBController_HuePlus* new_controller;
|
||||
|
||||
//Get file path in executable directory
|
||||
std::ifstream infile;
|
||||
char filename[2048];
|
||||
char arg1[64];
|
||||
|
||||
#ifdef WIN32
|
||||
GetModuleFileName(NULL, filename, 2048);
|
||||
strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
|
||||
#else
|
||||
snprintf(arg1, 64, "/proc/%d/exe", getpid());
|
||||
readlink(arg1, filename, 1024);
|
||||
strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
|
||||
#endif
|
||||
|
||||
strcat(filename, "/settings.txt");
|
||||
|
||||
//Open settings file
|
||||
infile.open(filename);
|
||||
|
||||
if (infile.good())
|
||||
std::string portname = find_usb_serial_port(0x04D8, 0x00DF);
|
||||
if( portname != "" )
|
||||
{
|
||||
for (std::string line; std::getline(infile, line); )
|
||||
{
|
||||
if (line == "")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ((line[0] != ';') && (line[0] != '#') && (line[0] != '/'))
|
||||
{
|
||||
char * argument;
|
||||
char * value;
|
||||
new_hueplus = new HuePlusController();
|
||||
new_hueplus->Initialize((char *)portname.c_str());
|
||||
|
||||
value = (char *)line.c_str();
|
||||
|
||||
argument = strtok_s(value, "=", &value);
|
||||
|
||||
//Strip off new line characters if present
|
||||
argument = strtok(argument, "\r\n");
|
||||
value = strtok(value, "\r\n");
|
||||
|
||||
if(argument)
|
||||
{
|
||||
if (strcmp(argument, "hueplus") == 0)
|
||||
{
|
||||
new_hueplus = new HuePlusController();
|
||||
new_hueplus->Initialize(value);
|
||||
|
||||
new_controller = new RGBController_HuePlus(new_hueplus);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
new_controller = new RGBController_HuePlus(new_hueplus);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
|
||||
} /* DetectHuePlusControllers() */
|
||||
|
||||
@@ -82,11 +82,9 @@ void DetectHyperXControllers(std::vector<i2c_smbus_interface*> &busses, std::vec
|
||||
{
|
||||
// Test for HyperX SPD at slot_addr
|
||||
// This test was copied from NGENUITY software
|
||||
// Tests SPD addresses in order: 0x40, 0x41, 0x68, and 0x67
|
||||
// Tests SPD addresses in order: 0x40, 0x41
|
||||
if((busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x40) == 0x01)
|
||||
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x41) == 0x98)
|
||||
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x68) == 0x10)
|
||||
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x67) == 0x00))
|
||||
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x41) == 0x98))
|
||||
{
|
||||
slots_valid |= (1 << (slot_addr - 0x50));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
/*-----------------------------------------*\
|
||||
| PatriotViperController.cpp |
|
||||
| |
|
||||
| Definitions and types for Patriot Viper |
|
||||
| RGB RAM lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/1/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "PatriotViperController.h"
|
||||
#include <cstring>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PatriotViperController::~PatriotViperController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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(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, 0x0C);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
|
||||
}
|
||||
|
||||
void PatriotViperController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_LED0_DIRECT_COLOR, red, blue, green);
|
||||
ViperRegisterWrite(VIPER_REG_LED1_DIRECT_COLOR, red, blue, green);
|
||||
ViperRegisterWrite(VIPER_REG_LED2_DIRECT_COLOR, red, blue, green);
|
||||
ViperRegisterWrite(VIPER_REG_LED3_DIRECT_COLOR, red, blue, green);
|
||||
ViperRegisterWrite(VIPER_REG_LED4_DIRECT_COLOR, red, blue, green);
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_APPLY, 0x01, 0x00, 0x00);
|
||||
}
|
||||
|
||||
void PatriotViperController::SetLEDColor(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 led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_LED0_EFFECT_COLOR + led, red, blue, green);
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, 0x0C);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
|
||||
}
|
||||
|
||||
void PatriotViperController::SetLEDColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
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, 0x0C);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
|
||||
}
|
||||
|
||||
void PatriotViperController::SetMode(unsigned char new_mode)
|
||||
{
|
||||
direct = false;
|
||||
mode = new_mode;
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, new_mode, 0x00, 0x0C);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
|
||||
}
|
||||
|
||||
void PatriotViperController::SetDirect()
|
||||
{
|
||||
direct = true;
|
||||
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_APPLY, 0x01, 0x00, 0x00);
|
||||
}
|
||||
|
||||
void PatriotViperController::ViperRegisterWrite(viper_register reg, unsigned char val0, unsigned char val1, unsigned char val2)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, reg, val0);
|
||||
bus->i2c_smbus_write_byte_data(dev, val2, val1);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*-----------------------------------------*\
|
||||
| PatriotViperController.h |
|
||||
| |
|
||||
| Definitions and types for Patriot Viper |
|
||||
| RGB RAM lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/1/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char viper_dev_id;
|
||||
typedef unsigned short viper_register;
|
||||
|
||||
enum
|
||||
{
|
||||
VIPER_REG_STATIC = 0x01, /* Set static mode */
|
||||
VIPER_REG_MODE = 0x03, /* Mode register */
|
||||
VIPER_REG_LED0_DIRECT_COLOR = 0x30, /* LED 0 Color (R, B, G) */
|
||||
VIPER_REG_LED1_DIRECT_COLOR = 0x31, /* LED 1 Color (R, B, G) */
|
||||
VIPER_REG_LED2_DIRECT_COLOR = 0x32, /* LED 2 Color (R, B, G) */
|
||||
VIPER_REG_LED3_DIRECT_COLOR = 0x33, /* LED 3 Color (R, B, G) */
|
||||
VIPER_REG_LED4_DIRECT_COLOR = 0x34, /* LED 4 Color (R, B, G) */
|
||||
VIPER_REG_APPLY = 0x35, /* Apply Changes (0x01, 0x00, 0x00) */
|
||||
VIPER_REG_LED0_EFFECT_COLOR = 0x3B, /* LED 0 Color (R, B, G) */
|
||||
VIPER_REG_LED1_EFFECT_COLOR = 0x3C, /* LED 1 Color (R, B, G) */
|
||||
VIPER_REG_LED2_EFFECT_COLOR = 0x3D, /* LED 2 Color (R, B, G) */
|
||||
VIPER_REG_LED3_EFFECT_COLOR = 0x3E, /* LED 3 Color (R, B, G) */
|
||||
VIPER_REG_LED4_EFFECT_COLOR = 0x3F, /* LED 4 Color (R, B, G) */
|
||||
VIPER_REG_START = 0xFF, /* Start Frame (0xFF, 0xFF, 0xFF) */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
VIPER_MODE_DARK = 0x00, /* Dark mode */
|
||||
VIPER_MODE_BREATHING = 0x01, /* Breathing mode */
|
||||
VIPER_MODE_VIPER = 0x02, /* Viper mode */
|
||||
VIPER_MODE_HEARTBEAT = 0x03, /* Heartbeat mode */
|
||||
VIPER_MODE_MARQUEE = 0x04, /* Marquee mode */
|
||||
VIPER_MODE_RAINDROP = 0x05, /* Raindrop mode */
|
||||
VIPER_MODE_AURORA = 0x06, /* Aurora mode */
|
||||
VIPER_MODE_NEON = 0x08, /* Neon mode */
|
||||
};
|
||||
|
||||
class PatriotViperController
|
||||
{
|
||||
public:
|
||||
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);
|
||||
void SetDirect();
|
||||
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetEffectColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDEffectColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDEffectColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
void ViperRegisterWrite(viper_register reg, unsigned char val0, unsigned char val1, unsigned char val2);
|
||||
bool direct;
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
unsigned int led_count;
|
||||
unsigned char slots_valid;
|
||||
i2c_smbus_interface* bus;
|
||||
viper_dev_id dev;
|
||||
unsigned int mode;
|
||||
};
|
||||
@@ -0,0 +1,81 @@
|
||||
#include "PatriotViperController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_PatriotViper.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* 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(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
PatriotViperController* new_viper;
|
||||
RGBController_PatriotViper* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
unsigned char slots_valid = 0x00;
|
||||
|
||||
for(int slot_addr = 0x50; slot_addr <= 0x57; slot_addr++)
|
||||
{
|
||||
// Test for Patriot Viper RGB SPD at slot_addr
|
||||
// This test was copied from Viper RGB software
|
||||
// Tests SPD addresses in order: 0x00, 0x40, 0x41, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68
|
||||
busses[bus]->i2c_smbus_write_byte_data(0x36, 0x00, 0xFF);
|
||||
|
||||
Sleep(1);
|
||||
|
||||
if(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x00) == 0x23)
|
||||
{
|
||||
busses[bus]->i2c_smbus_write_byte_data(0x37, 0x00, 0xFF);
|
||||
|
||||
Sleep(1);
|
||||
|
||||
if((busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x40) == 0x85)
|
||||
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x41) == 0x02)
|
||||
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x61) == 0x4D)
|
||||
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x62) == 0x49)
|
||||
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x63) == 0x43)
|
||||
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x64) == 0x53)
|
||||
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x65) == 0x59)
|
||||
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x66) == 0x53)
|
||||
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x67) == 0x5f)
|
||||
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x68) == 0x44))
|
||||
{
|
||||
slots_valid |= (1 << (slot_addr - 0x50));
|
||||
}
|
||||
}
|
||||
|
||||
Sleep(1);
|
||||
}
|
||||
|
||||
if(slots_valid != 0)
|
||||
{
|
||||
new_viper = new PatriotViperController(busses[bus], 0x77, slots_valid);
|
||||
new_controller = new RGBController_PatriotViper(new_viper);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectPatriotViperControllers() */
|
||||
@@ -34,6 +34,11 @@ PolychromeController::PolychromeController(i2c_smbus_interface* bus, polychrome_
|
||||
asr_led = false;
|
||||
strcpy(device_name, "ASRock Polychrome FW 3.00");
|
||||
break;
|
||||
|
||||
default:
|
||||
led_count = 0;
|
||||
strcpy(device_name, "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +74,11 @@ unsigned int PolychromeController::GetLEDCount()
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
unsigned int PolychromeController::GetMode()
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void PolychromeController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
if (asr_led)
|
||||
@@ -83,7 +93,7 @@ void PolychromeController::SetAllColors(unsigned char red, unsigned char green,
|
||||
}
|
||||
}
|
||||
|
||||
void PolychromeController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
void PolychromeController::SetLEDColor(unsigned int /*led*/, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
if (asr_led)
|
||||
{
|
||||
@@ -107,4 +117,4 @@ void PolychromeController::SetMode(unsigned char mode)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, POLYCHROME_REG_MODE, mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
|
||||
char* GetDeviceName();
|
||||
unsigned int GetLEDCount();
|
||||
unsigned int GetMode();
|
||||
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 SetMode(unsigned char mode);
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
#include "PolychromeController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_Polychrome.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForPolychromeController *
|
||||
* *
|
||||
* Tests the given address to see if an ASRock Polychrome RGB controller exists there.*
|
||||
* First does a quick write to test for a response *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForPolychromeController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForPolychromeController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectPolychromeControllers *
|
||||
* *
|
||||
* Detect ASRock Polychrome RGB controllers on the enumerated I2C busses at address *
|
||||
* 0x6A. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Polychrome device is connected *
|
||||
* dev - I2C address of Polychrome device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectPolychromeControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
PolychromeController* new_polychrome;
|
||||
RGBController_Polychrome* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for Polychrome controller at 0x6A
|
||||
if (TestForPolychromeController(busses[bus], 0x6A))
|
||||
{
|
||||
new_polychrome = new PolychromeController(busses[bus], 0x6A);
|
||||
|
||||
if(new_polychrome->GetLEDCount() != 0)
|
||||
{
|
||||
new_controller = new RGBController_Polychrome(new_polychrome);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete new_polychrome;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectPolychromeControllers() */
|
||||
@@ -22,6 +22,10 @@ RGBFusionController::RGBFusionController(i2c_smbus_interface* bus, rgb_fusion_de
|
||||
|
||||
// Set LED count
|
||||
led_count = 2;
|
||||
|
||||
// Enable control
|
||||
switch_bank(0);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x02, 0x09);
|
||||
}
|
||||
|
||||
RGBFusionController::~RGBFusionController()
|
||||
@@ -132,37 +136,38 @@ void RGBFusionController::dump()
|
||||
|
||||
unsigned char RGBFusionController::get_mode_ch_0()
|
||||
{
|
||||
s32 temp = bus->i2c_smbus_read_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_0_MODE);
|
||||
return(temp);
|
||||
return(bus->i2c_smbus_read_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_MODE));
|
||||
}
|
||||
|
||||
unsigned char RGBFusionController::get_mode_ch_1()
|
||||
{
|
||||
return(bus->i2c_smbus_read_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_1_MODE));
|
||||
return(bus->i2c_smbus_read_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_MODE));
|
||||
}
|
||||
|
||||
void RGBFusionController::set_color_ch_0(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_R, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_G, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_B, blue);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_0_R, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_0_G, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_0_B, blue);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x03, 0x01);
|
||||
}
|
||||
|
||||
void RGBFusionController::set_color_ch_1(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_R, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_G, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_B, blue);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_1_R, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_1_G, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_1_B, blue);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x0B, 0x01);
|
||||
}
|
||||
|
||||
void RGBFusionController::set_mode_ch_0(unsigned char mode)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_0_MODE, mode + RGB_FUSION_WRITE_MODE_OFST);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_MODE, mode + RGB_FUSION_WRITE_MODE_OFST);
|
||||
}
|
||||
|
||||
void RGBFusionController::set_mode_ch_1(unsigned char mode)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_1_MODE, mode + RGB_FUSION_WRITE_MODE_OFST);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_MODE, mode + RGB_FUSION_WRITE_MODE_OFST);
|
||||
}
|
||||
|
||||
void RGBFusionController::switch_bank(unsigned char bank)
|
||||
|
||||
@@ -16,14 +16,14 @@ typedef unsigned char rgb_fusion_dev_id;
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_BANK_0_REG_CH_0_R = 0x00, /* Channel 0 Red Value */
|
||||
RGB_FUSION_BANK_0_REG_CH_0_G = 0x01, /* Channel 0 Green Value */
|
||||
RGB_FUSION_BANK_0_REG_CH_0_B = 0x02, /* Channel 0 Blue Value */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_R = 0x08, /* Channel 1 Red Value */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_G = 0x09, /* Channel 1 Green Value */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_B = 0x0A, /* Channel 1 Blue Value */
|
||||
RGB_FUSION_BANK_1_REG_CH_0_MODE = 0x03, /* Channel 0 Mode Selection */
|
||||
RGB_FUSION_BANK_1_REG_CH_1_MODE = 0x13, /* Channel 1 Mode Selection */
|
||||
RGB_FUSION_BANK_0_REG_CH_0_MODE = 0x03, /* Channel 0 Mode Selection */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_MODE = 0x13, /* Channel 1 Mode Selection */
|
||||
RGB_FUSION_BANK_1_REG_CH_0_R = 0x00, /* Channel 0 Red Value */
|
||||
RGB_FUSION_BANK_1_REG_CH_0_G = 0x01, /* Channel 0 Green Value */
|
||||
RGB_FUSION_BANK_1_REG_CH_0_B = 0x02, /* Channel 0 Blue Value */
|
||||
RGB_FUSION_BANK_1_REG_CH_1_R = 0x08, /* Channel 1 Red Value */
|
||||
RGB_FUSION_BANK_1_REG_CH_1_G = 0x09, /* Channel 1 Green Value */
|
||||
RGB_FUSION_BANK_1_REG_CH_1_B = 0x0A, /* Channel 1 Blue Value */
|
||||
RGB_FUSION_BANK_SWITCH_REG = 0xF0, /* Bank Switch Register */
|
||||
};
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#include <string>
|
||||
#include "AuraController.h"
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#define MODE_AUTO 0
|
||||
#define MODE_QUICK 1
|
||||
#define MODE_READ 2
|
||||
#define MODE_FUNC 3
|
||||
|
||||
std::string DetectI2C(i2c_smbus_interface * bus, int mode);
|
||||
void DumpAuraRegisters(AuraController * controller);
|
||||
void DetectRGBControllers();
|
||||
@@ -1,14 +1,12 @@
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* OpenAuraSDK.cpp *
|
||||
* OpenRGB.cpp *
|
||||
* *
|
||||
* Functions for communicating with Asus Aura devices on Windows and Linux *
|
||||
* Functions for communicating with RGBController API devices on Windows and Linux *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
#include "AuraController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AorusGPU.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
@@ -319,51 +317,21 @@ void DetectI2CBusses()
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DumpAuraRegisters *
|
||||
* *
|
||||
* Dumps register values from an Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DumpAuraRegisters(AuraController * controller)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
int start = 0x0000;
|
||||
|
||||
FILE* file = freopen("auradump.txt", "a", stdout);
|
||||
|
||||
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n");
|
||||
|
||||
for (i = 0; i < 0xFFFF; i += 16)
|
||||
{
|
||||
printf("%04x: ", i + start);
|
||||
|
||||
for (j = 0; j < 16; j++)
|
||||
{
|
||||
printf("%02x ", controller->AuraRegisterRead(start + i + j));
|
||||
}
|
||||
|
||||
printf("\r\n");
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
} /* DumpAuraRegisters() */
|
||||
|
||||
void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectCorsairControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectCorsairProControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectHyperXControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectPolychromeControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectRGBFusionControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectHue2Controllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectHuePlusControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectRazerChromaSDKControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectAMDWraithPrismControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectAorusGPUControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -381,25 +349,30 @@ void DetectRGBControllers(void)
|
||||
DetectCorsairControllers(busses, rgb_controllers);
|
||||
DetectCorsairProControllers(busses, rgb_controllers);
|
||||
DetectHyperXControllers(busses, rgb_controllers);
|
||||
DetectPatriotViperControllers(busses, rgb_controllers);
|
||||
DetectPolychromeControllers(busses, rgb_controllers);
|
||||
DetectRGBFusionControllers(busses, rgb_controllers);
|
||||
|
||||
DetectLEDStripControllers(rgb_controllers);
|
||||
DetectHue2Controllers(rgb_controllers);
|
||||
DetectHuePlusControllers(rgb_controllers);
|
||||
|
||||
DetectAMDWraithPrismControllers(rgb_controllers);
|
||||
|
||||
DetectE131Controllers(rgb_controllers);
|
||||
|
||||
/*-------------------------------------*\
|
||||
| Windows-only devices |
|
||||
\*-------------------------------------*/
|
||||
#ifdef WIN32
|
||||
DetectRazerChromaSDKControllers(rgb_controllers);
|
||||
//DetectAorusGPUControllers(rgb_controllers);
|
||||
|
||||
/*-------------------------------------*\
|
||||
| Linux-only devices |
|
||||
\*-------------------------------------*/
|
||||
#else
|
||||
DetectE131Controllers(rgb_controllers);
|
||||
DetectOpenRazerControllers(rgb_controllers);
|
||||
#endif
|
||||
|
||||
//This is for testing Aorus GPU
|
||||
#if 0
|
||||
RGBController_AorusGPU * aorus_rgb = new RGBController_AorusGPU();
|
||||
|
||||
rgb_controllers.push_back(aorus_rgb);
|
||||
#endif
|
||||
|
||||
}
|
||||
} /* DetectRGBControllers() */
|
||||
+26
-6
@@ -6,6 +6,7 @@ TARGET = OpenRGB
|
||||
TEMPLATE = app
|
||||
|
||||
INCLUDEPATH += \
|
||||
dependencies/libe131/src/ \
|
||||
i2c_smbus/ \
|
||||
i2c_tools/ \
|
||||
net_port/ \
|
||||
@@ -14,17 +15,20 @@ INCLUDEPATH += \
|
||||
Controllers/AuraController/ \
|
||||
Controllers/CorsairController/ \
|
||||
Controllers/CorsairProController/ \
|
||||
Controllers/Hue2Controller/ \
|
||||
Controllers/HuePlusController/ \
|
||||
Controllers/HyperXController/ \
|
||||
Controllers/LEDStripController/ \
|
||||
Controllers/PatriotViperController/ \
|
||||
Controllers/PolychromeController/ \
|
||||
Controllers/RGBFusionController/ \
|
||||
RGBController/ \
|
||||
qt/
|
||||
|
||||
SOURCES += \
|
||||
dependencies/libe131/src/e131.c \
|
||||
main.cpp \
|
||||
OpenAuraSDK.cpp \
|
||||
OpenRGB.cpp \
|
||||
qt/OpenRGBDeviceInfoPage.cpp \
|
||||
qt/OpenRGBDevicePage.cpp \
|
||||
qt/OpenRGBDialog.cpp \
|
||||
@@ -43,22 +47,32 @@ SOURCES += \
|
||||
Controllers/CorsairController/CorsairControllerDetect.cpp \
|
||||
Controllers/CorsairProController/CorsairProController.cpp \
|
||||
Controllers/CorsairProController/CorsairProControllerDetect.cpp \
|
||||
Controllers/Hue2Controller/Hue2Controller.cpp \
|
||||
Controllers/Hue2Controller/Hue2ControllerDetect.cpp \
|
||||
Controllers/HuePlusController/HuePlusController.cpp \
|
||||
Controllers/HuePlusController/HuePlusControllerDetect.cpp \
|
||||
Controllers/HyperXController/HyperXController.cpp \
|
||||
Controllers/HyperXController/HyperXControllerDetect.cpp \
|
||||
Controllers/LEDStripController/LEDStripController.cpp \
|
||||
Controllers/LEDStripController/LEDStripControllerDetect.cpp \
|
||||
Controllers/PatriotViperController/PatriotViperController.cpp \
|
||||
Controllers/PatriotViperController/PatriotViperControllerDetect.cpp \
|
||||
Controllers/PolychromeController/PolychromeController.cpp \
|
||||
Controllers/PolychromeController/PolychromeControllerDetect.cpp \
|
||||
Controllers/RGBFusionController/RGBFusionController.cpp \
|
||||
Controllers/RGBFusionController/RGBFusionControllerDetect.cpp \
|
||||
RGBController/E131ControllerDetect.cpp \
|
||||
RGBController/RGBController_AMDWraithPrism.cpp \
|
||||
RGBController/RGBController_Aura.cpp \
|
||||
RGBController/RGBController_Corsair.cpp \
|
||||
RGBController/RGBController_CorsairPro.cpp \
|
||||
RGBController/RGBController_Hue2.cpp \
|
||||
RGBController/RGBController_HuePlus.cpp \
|
||||
RGBController/RGBController_HyperX.cpp \
|
||||
RGBController/RGBController_E131.cpp \
|
||||
RGBController/RGBController_LEDStrip.cpp \
|
||||
RGBController/RGBController_PatriotViper.cpp \
|
||||
RGBController/RGBController_Polychrome.cpp \
|
||||
RGBController/RGBController_RGBFusion.cpp
|
||||
|
||||
HEADERS += \
|
||||
@@ -71,21 +85,29 @@ HEADERS += \
|
||||
net_port/net_port.h \
|
||||
qt/OpenRGBDialog2.h \
|
||||
qt/OpenRGBSystemInfoPage.h \
|
||||
serial_port/find_usb_serial_port.h \
|
||||
serial_port/serial_port.h \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismController.h \
|
||||
Controllers/AuraController/AuraController.h \
|
||||
Controllers/CorsairController/CorsairController.h \
|
||||
Controllers/CorsairProController/CorsairProController.h \
|
||||
Controllers/Hue2Controller/Hue2Controller.h \
|
||||
Controllers/HuePlusController/HuePlusController.h \
|
||||
Controllers/HyperXController/HyperXController.h \
|
||||
Controllers/LEDStripController/LEDStripController.h \
|
||||
Controllers/PatriotViperController/PatriotViperController.h \
|
||||
Controllers/PolychromeController/PolychromeController.h \
|
||||
Controllers/RGBFusionController/RGBFusionController.h \
|
||||
RGBController/RGBController.h \
|
||||
RGBController/RGBController_AMDWraithPrism.h \
|
||||
RGBController/RGBController_Aura.h \
|
||||
RGBController/RGBController_Corsair.h \
|
||||
RGBController/RGBController_CorsairPro.h \
|
||||
RGBController/RGBController_E131.h \
|
||||
RGBController/RGBController_Hue2.h \
|
||||
RGBController/RGBController_HuePlus.h \
|
||||
RGBController/RGBController_HyperX.h \
|
||||
RGBController/RGBController_PatriotViper.h \
|
||||
RGBController/RGBController_Polychrome.h \
|
||||
RGBController/RGBController_RGBFusion.h
|
||||
|
||||
@@ -112,7 +134,9 @@ win32:SOURCES += \
|
||||
i2c_smbus/i2c_smbus_i801.cpp \
|
||||
i2c_smbus/i2c_smbus_nct6775.cpp \
|
||||
i2c_smbus/i2c_smbus_piix4.cpp \
|
||||
serial_port/find_usb_serial_port_win.cpp \
|
||||
wmi/wmi.cpp \
|
||||
RGBController/AorusGPUDetect.cpp \
|
||||
RGBController/RGBController_AorusGPU.cpp \
|
||||
RGBController/RazerChromaSDKDetect.cpp \
|
||||
RGBController/RGBController_RazerChromaSDK.cpp \
|
||||
@@ -145,19 +169,15 @@ win32:DEFINES += \
|
||||
# Linux specific project configuration
|
||||
#-----------------------------------------------
|
||||
unix:INCLUDEPATH += \
|
||||
dependencies/libe131/src/ \
|
||||
|
||||
unix:HEADERS += \
|
||||
i2c_smbus/i2c_smbus_linux.h \
|
||||
RGBController/RGBController_E131.h \
|
||||
|
||||
unix:LIBS += \
|
||||
-lusb-1.0
|
||||
|
||||
unix:SOURCES += \
|
||||
dependencies/libe131/src/e131.c \
|
||||
i2c_smbus/i2c_smbus_linux.cpp \
|
||||
serial_port/find_usb_serial_port_linux.cpp \
|
||||
RGBController/OpenRazerDetect.cpp \
|
||||
RGBController/E131ControllerDetect.cpp \
|
||||
RGBController/RGBController_E131.cpp \
|
||||
RGBController/RGBController_OpenRazer.cpp \
|
||||
|
||||
@@ -31,17 +31,20 @@ After getting a solid Aura implementation, the project branched out into other m
|
||||
## Installation
|
||||
#### Windows
|
||||
1. Download the latest Visual Studio Community Edition and Qt Creator.
|
||||
2. Open the OpenRGB_Win.pro project.
|
||||
3. Build the project for `x86` Architecture. The InpOut32 library I use does not support x64.
|
||||
4. Copy InpOut32.dll from dependencies to the same path as OpenAuraSDK.exe along with the Qt libraries.
|
||||
2. Update the submodules: git submodule update --init --recursive
|
||||
3. Open the OpenRGB_Win.pro project.
|
||||
4. Build the project for `x86` Architecture. The InpOut32 library I use does not support x64.
|
||||
5. Copy InpOut32.dll from dependencies to the same path as OpenAuraSDK.exe along with the Qt libraries.
|
||||
|
||||
**You must run the application as Administrator the first time to allow InpOut32 to set up. It can be run as a normal user afterwards**
|
||||
|
||||
#### Linux:
|
||||
1. Either open the project using QT Creator or build it using qmake.
|
||||
1. Either open the project using QT Creator or build it using qmake. You will need the libusb-1.0-0 (or equivalent) development package from your distribution's package manager installed.
|
||||
|
||||
cd OpenAuraSDK
|
||||
qmake OpenAuraSDK.pro
|
||||
git clone https://gitlab.com/CalcProgrammer1/OpenRGB
|
||||
cd OpenRGB
|
||||
git submodule update --init --recursive
|
||||
qmake OpenRGB.pro
|
||||
make
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AorusGPU.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAorusGPUControllers *
|
||||
* *
|
||||
* Detect devices supported by the Aorus GPU driver *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAorusGPUControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
RGBController_AorusGPU * aorus_rgb = new RGBController_AorusGPU();
|
||||
|
||||
rgb_controllers.push_back(aorus_rgb);
|
||||
} /* DetectLEDStripControllers() */
|
||||
@@ -13,6 +13,8 @@
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
@@ -167,4 +169,4 @@ void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectLEDStripControllers() */
|
||||
} /* DetectE131Controllers() */
|
||||
|
||||
@@ -22,7 +22,6 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
char driver_path[512];
|
||||
DIR *dir;
|
||||
struct dirent *ent;
|
||||
int test_fd;
|
||||
bool done = false;
|
||||
int driver_to_read = 0;
|
||||
|
||||
@@ -97,7 +96,6 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
}
|
||||
else
|
||||
{
|
||||
int device_type;
|
||||
char device_string[1024];
|
||||
strcpy(device_string, driver_path);
|
||||
strcat(device_string, ent->d_name);
|
||||
@@ -124,4 +122,4 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
driver_to_read++;
|
||||
}
|
||||
|
||||
} /* DetectOpenRazerControllers() */
|
||||
} /* DetectOpenRazerControllers() */
|
||||
|
||||
@@ -77,6 +77,8 @@ public:
|
||||
std::vector<RGBColor> colors; /* Color buffer */
|
||||
device_type type; /* device type */
|
||||
|
||||
virtual ~RGBController() = default;
|
||||
|
||||
virtual int GetMode() = 0;
|
||||
virtual void SetMode(int mode) = 0;
|
||||
virtual void SetCustomMode() = 0;
|
||||
|
||||
@@ -68,7 +68,7 @@ int RGBController_AMDWraithPrism::GetMode()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::SetMode(int mode)
|
||||
void RGBController_AMDWraithPrism::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -132,4 +132,4 @@ void RGBController_AMDWraithPrism::SetLED(int led, RGBColor color)
|
||||
void RGBController_AMDWraithPrism::UpdateLEDs()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,9 +61,9 @@ void RGBController_Aura::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
if (GetMode() == 0)
|
||||
{
|
||||
@@ -95,7 +95,7 @@ void RGBController_Aura::SetLED(int led, RGBColor color)
|
||||
|
||||
void RGBController_Aura::UpdateLEDs()
|
||||
{
|
||||
for(int led = 0; led < colors.size(); led++)
|
||||
for(std::size_t led = 0; led < colors.size(); led++)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[led]);
|
||||
unsigned char grn = RGBGetGValue(colors[led]);
|
||||
@@ -149,12 +149,12 @@ RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
|
||||
aura_modes[13].name = "Chase Rainbow Pulse";
|
||||
aura_modes[14].name = "Random Flicker";
|
||||
|
||||
for (int i = 0; i < (AURA_NUMBER_MODES + 1); i++)
|
||||
for (std::size_t i = 0; i < (AURA_NUMBER_MODES + 1); i++)
|
||||
{
|
||||
modes.push_back(aura_modes[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < aura->GetLEDCount(); i++)
|
||||
for (std::size_t i = 0; i < aura->GetLEDCount(); i++)
|
||||
{
|
||||
aura_channels.push_back(aura->GetChannel(i));
|
||||
|
||||
@@ -169,12 +169,12 @@ RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
|
||||
std::vector<unsigned char> aura_zones;
|
||||
|
||||
// Search through all LEDs and create zones for each channel type
|
||||
for (int i = 0; i < aura_channels.size(); i++)
|
||||
for (std::size_t i = 0; i < aura_channels.size(); i++)
|
||||
{
|
||||
bool matched = false;
|
||||
|
||||
// Search through existing zones to make sure we don't create a duplicate zone
|
||||
for (int j = 0; j < aura_zones.size(); j++)
|
||||
for (std::size_t j = 0; j < aura_zones.size(); j++)
|
||||
{
|
||||
if (aura_channels[i] == aura_zones[j])
|
||||
{
|
||||
@@ -192,7 +192,7 @@ RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
|
||||
new_zone->name = aura->GetChannelName(i);
|
||||
|
||||
// Find all LEDs with this channel type and add them to zone
|
||||
for (int j = 0; j < aura->GetLEDCount(); j++)
|
||||
for (std::size_t j = 0; j < aura->GetLEDCount(); j++)
|
||||
{
|
||||
if (aura->GetChannel(j) == aura_channels[i])
|
||||
{
|
||||
|
||||
@@ -39,9 +39,9 @@ void RGBController_Corsair::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
corsair->SetLEDColor(zones[zone].map[x][y], red, grn, blu);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ RGBController_Corsair::RGBController_Corsair(CorsairController* corsair_ptr)
|
||||
modes.push_back(corsair_modes[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < corsair->GetLEDCount(); i++)
|
||||
for (unsigned int i = 0; i < corsair->GetLEDCount(); i++)
|
||||
{
|
||||
led* new_led = new led();
|
||||
|
||||
@@ -99,7 +99,7 @@ RGBController_Corsair::RGBController_Corsair(CorsairController* corsair_ptr)
|
||||
|
||||
std::vector<int> zone_row;
|
||||
|
||||
for (int i = 0; i < corsair->GetLEDCount(); i++)
|
||||
for (unsigned int i = 0; i < corsair->GetLEDCount(); i++)
|
||||
{
|
||||
zone_row.push_back(i);
|
||||
}
|
||||
|
||||
@@ -72,9 +72,9 @@ void RGBController_CorsairPro::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
corsair->SetLEDColor(zones[zone].map[x][y], red, grn, blu);
|
||||
}
|
||||
@@ -125,7 +125,7 @@ RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair
|
||||
modes.push_back(corsair_modes[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < corsair->GetLEDCount(); i++)
|
||||
for (unsigned int i = 0; i < corsair->GetLEDCount(); i++)
|
||||
{
|
||||
led* new_led = new led();
|
||||
|
||||
@@ -142,7 +142,7 @@ RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair
|
||||
|
||||
std::vector<int> zone_row;
|
||||
|
||||
for (int i = 0; i < corsair->GetLEDCount(); i++)
|
||||
for (unsigned int i = 0; i < corsair->GetLEDCount(); i++)
|
||||
{
|
||||
zone_row.push_back(i);
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
|
||||
|
||||
sockfd = e131_socket();
|
||||
|
||||
for (int i = 0; i < devices.size(); i++)
|
||||
for (std::size_t i = 0; i < devices.size(); i++)
|
||||
{
|
||||
/*-----------------------------------------*\
|
||||
| Add LEDs |
|
||||
\*-----------------------------------------*/
|
||||
for (int led_idx = 0; led_idx < devices[i].num_leds; led_idx++)
|
||||
for (unsigned int led_idx = 0; led_idx < devices[i].num_leds; led_idx++)
|
||||
{
|
||||
colors.push_back(0x00000000);
|
||||
led new_led;
|
||||
@@ -44,7 +44,7 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
|
||||
led_zone.name = devices[i].name;
|
||||
led_zone.type = devices[i].type;
|
||||
std::vector<int> led_zone_map;
|
||||
for (int led_idx = 0; led_idx < devices[i].num_leds; led_idx++)
|
||||
for (unsigned int led_idx = 0; led_idx < devices[i].num_leds; led_idx++)
|
||||
{
|
||||
led_zone_map.push_back(led_zone_idx);
|
||||
led_zone_idx++;
|
||||
@@ -57,12 +57,12 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
|
||||
\*-----------------------------------------*/
|
||||
unsigned int total_universes = ceil( ( ( devices[i].num_leds * 3 ) + devices[i].start_channel ) / 512.0f );
|
||||
|
||||
for (int univ_idx = 0; univ_idx < total_universes; univ_idx++)
|
||||
for (unsigned int univ_idx = 0; univ_idx < total_universes; univ_idx++)
|
||||
{
|
||||
unsigned int universe = devices[i].start_universe + univ_idx;
|
||||
bool universe_exists = false;
|
||||
|
||||
for (int pkt_idx = 0; pkt_idx < packets.size(); pkt_idx++)
|
||||
for (std::size_t pkt_idx = 0; pkt_idx < packets.size(); pkt_idx++)
|
||||
{
|
||||
if(universes[pkt_idx] == universe)
|
||||
{
|
||||
@@ -91,7 +91,7 @@ int RGBController_E131::GetMode()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_E131::SetMode(int mode)
|
||||
void RGBController_E131::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -103,7 +103,7 @@ void RGBController_E131::SetCustomMode()
|
||||
|
||||
void RGBController_E131::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
for (std::size_t i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
@@ -113,9 +113,9 @@ void RGBController_E131::SetAllLEDs(RGBColor color)
|
||||
|
||||
void RGBController_E131::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
colors[zones[zone].map[x][y]] = color;
|
||||
}
|
||||
@@ -135,7 +135,7 @@ void RGBController_E131::UpdateLEDs()
|
||||
{
|
||||
int color_idx = 0;
|
||||
|
||||
for(int device_idx = 0; device_idx < devices.size(); device_idx++)
|
||||
for(std::size_t device_idx = 0; device_idx < devices.size(); device_idx++)
|
||||
{
|
||||
unsigned int total_universes = ceil( ( ( devices[device_idx].num_leds * 3 ) + devices[device_idx].start_channel ) / 512.0f );
|
||||
unsigned int channel_idx = devices[device_idx].start_channel;
|
||||
@@ -143,11 +143,11 @@ void RGBController_E131::UpdateLEDs()
|
||||
unsigned int rgb_idx = 0;
|
||||
bool done = false;
|
||||
|
||||
for (int univ_idx = 0; univ_idx < total_universes; univ_idx++)
|
||||
for (unsigned int univ_idx = 0; univ_idx < total_universes; univ_idx++)
|
||||
{
|
||||
unsigned int universe = devices[device_idx].start_universe + univ_idx;
|
||||
|
||||
for(int packet_idx = 0; packet_idx < packets.size(); packet_idx++)
|
||||
for(std::size_t packet_idx = 0; packet_idx < packets.size(); packet_idx++)
|
||||
{
|
||||
if(!done && (universes[packet_idx] == universe))
|
||||
{
|
||||
@@ -185,9 +185,9 @@ void RGBController_E131::UpdateLEDs()
|
||||
}
|
||||
}
|
||||
|
||||
for(int packet_idx = 0; packet_idx < packets.size(); packet_idx++)
|
||||
for(std::size_t packet_idx = 0; packet_idx < packets.size(); packet_idx++)
|
||||
{
|
||||
e131_send(sockfd, &packets[packet_idx], &dest_addrs[packet_idx]);
|
||||
packets[packet_idx].frame.seq_number++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Hue2.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for NZXT Hue 2 |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/29/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_Hue2.h"
|
||||
|
||||
|
||||
RGBController_Hue2::RGBController_Hue2(Hue2Controller* hue2_ptr)
|
||||
{
|
||||
hue2 = hue2_ptr;
|
||||
|
||||
name = "NZXT Hue 2";
|
||||
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
|
||||
unsigned int led_idx = 0;
|
||||
|
||||
for (unsigned int channel_idx = 0; channel_idx < HUE_2_NUM_CHANNELS; channel_idx++)
|
||||
{
|
||||
if(hue2->channel_leds[channel_idx] > 0)
|
||||
{
|
||||
zone* new_zone = new zone;
|
||||
|
||||
char ch_idx_string[2];
|
||||
sprintf(ch_idx_string, "%d", channel_idx + 1);
|
||||
|
||||
new_zone->name = "Hue 2 Channel ";
|
||||
new_zone->name.append(ch_idx_string);
|
||||
new_zone->type = ZONE_TYPE_LINEAR;
|
||||
|
||||
std::vector<int> *new_zone_map = new std::vector<int>();
|
||||
|
||||
for (unsigned int led_ch_idx = 0; led_ch_idx < hue2->channel_leds[channel_idx]; led_ch_idx++)
|
||||
{
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
char led_idx_string[3];
|
||||
sprintf(led_idx_string, "%d", led_ch_idx + 1);
|
||||
|
||||
led new_led;
|
||||
new_led.name = "Hue 2 Channel ";
|
||||
new_led.name.append(ch_idx_string);
|
||||
new_led.name.append(", LED ");
|
||||
new_led.name.append(led_idx_string);
|
||||
|
||||
leds.push_back(new_led);
|
||||
leds_channel.push_back(channel_idx + 1);
|
||||
|
||||
new_zone_map->push_back(led_idx);
|
||||
led_idx++;
|
||||
}
|
||||
|
||||
new_zone->map.push_back(*new_zone_map);
|
||||
zones.push_back(*new_zone);
|
||||
zones_channel.push_back(channel_idx + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int RGBController_Hue2::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_Hue2::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Hue2::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Hue2::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
for (std::size_t i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Hue2::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone];
|
||||
|
||||
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
colors[zones[zone].map[x][y]] = color;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
hue2->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
|
||||
void RGBController_Hue2::SetLED(int led, RGBColor color)
|
||||
{
|
||||
unsigned int channel = leds_channel[led];
|
||||
colors[led] = color;
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
hue2->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
|
||||
void RGBController_Hue2::UpdateLEDs()
|
||||
{
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(unsigned int channel = 0; channel < HUE_2_NUM_CHANNELS; channel++)
|
||||
{
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
hue2->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
|
||||
channel_colors.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Hue2.h |
|
||||
| |
|
||||
| Generic RGB Interface for NZXT Hue 2 |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/29/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "serial_port.h"
|
||||
#include "Hue2Controller.h"
|
||||
|
||||
class RGBController_Hue2 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Hue2(Hue2Controller* hue2_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
void SetLED(int led, RGBColor color);
|
||||
void UpdateLEDs();
|
||||
|
||||
private:
|
||||
Hue2Controller* hue2;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
std::vector<unsigned int> zones_channel;
|
||||
};
|
||||
@@ -40,7 +40,7 @@ RGBController_HuePlus::RGBController_HuePlus(HuePlusController* hueplus_ptr)
|
||||
|
||||
std::vector<int> *new_zone_map = new std::vector<int>();
|
||||
|
||||
for (int led_ch_idx = 0; led_ch_idx < hueplus->channel_leds[channel_idx]; led_ch_idx++)
|
||||
for (unsigned led_ch_idx = 0; led_ch_idx < hueplus->channel_leds[channel_idx]; led_ch_idx++)
|
||||
{
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
@@ -72,7 +72,7 @@ int RGBController_HuePlus::GetMode()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetMode(int mode)
|
||||
void RGBController_HuePlus::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -84,7 +84,7 @@ void RGBController_HuePlus::SetCustomMode()
|
||||
|
||||
void RGBController_HuePlus::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
for (std::size_t i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
@@ -94,11 +94,11 @@ void RGBController_HuePlus::SetAllLEDs(RGBColor color)
|
||||
|
||||
void RGBController_HuePlus::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
int channel = zones_channel[zone];
|
||||
unsigned int channel = zones_channel[zone];
|
||||
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
colors[zones[zone].map[x][y]] = color;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ void RGBController_HuePlus::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(int color = 0; color < colors.size(); color++)
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
@@ -119,12 +119,12 @@ void RGBController_HuePlus::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
|
||||
void RGBController_HuePlus::SetLED(int led, RGBColor color)
|
||||
{
|
||||
int channel = leds_channel[led];
|
||||
unsigned int channel = leds_channel[led];
|
||||
colors[led] = color;
|
||||
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(int color = 0; color < colors.size(); color++)
|
||||
for(std::size_t color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
|
||||
@@ -49,9 +49,9 @@ void RGBController_HyperX::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
|
||||
if(hyperx->GetMode() == HYPERX_MODE_DIRECT)
|
||||
{
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
hyperx->SetLEDColor(zones[zone].map[x][y], red, grn, blu);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ RGBController_HyperX::RGBController_HyperX(HyperXController* hyperx_ptr)
|
||||
|
||||
unsigned int led_idx = 0;
|
||||
|
||||
for(int slot = 0; slot < hyperx->GetSlotCount(); slot++)
|
||||
for(unsigned int slot = 0; slot < hyperx->GetSlotCount(); slot++)
|
||||
{
|
||||
zone* new_zone = new zone;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ int RGBController_LEDStrip::GetMode()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetMode(int mode)
|
||||
void RGBController_LEDStrip::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -58,7 +58,7 @@ void RGBController_LEDStrip::SetCustomMode()
|
||||
|
||||
void RGBController_LEDStrip::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
for (std::size_t i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
@@ -66,9 +66,9 @@ void RGBController_LEDStrip::SetAllLEDs(RGBColor color)
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
void RGBController_LEDStrip::SetAllZoneLEDs(int /*zone*/, RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
for (std::size_t i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ void RGBController_OpenRazer::UpdateLEDs()
|
||||
{
|
||||
char update_value = 1;
|
||||
|
||||
for (int row = 0; row < matrix_rows; row++)
|
||||
for (unsigned int row = 0; row < matrix_rows; row++)
|
||||
{
|
||||
unsigned int output_array_size;
|
||||
unsigned int output_offset;
|
||||
@@ -126,7 +126,7 @@ void RGBController_OpenRazer::UpdateLEDs()
|
||||
output_array[2] = matrix_cols - 1;
|
||||
}
|
||||
|
||||
for(int col = 0; col < matrix_cols; col++)
|
||||
for(unsigned int col = 0; col < matrix_cols; col++)
|
||||
{
|
||||
unsigned int color_idx = col + row_offset;
|
||||
output_array[(col * 3) + 0 + output_offset] = (char)RGBGetRValue(colors[color_idx]);
|
||||
@@ -189,7 +189,7 @@ void RGBController_OpenRazer::UpdateLEDs()
|
||||
|
||||
void RGBController_OpenRazer::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
for(int i = 0; i < colors.size(); i++)
|
||||
for(std::size_t i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
@@ -199,9 +199,9 @@ void RGBController_OpenRazer::SetAllLEDs(RGBColor color)
|
||||
|
||||
void RGBController_OpenRazer::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
colors[zones[zone].map[x][y]] = color;
|
||||
}
|
||||
@@ -340,7 +340,7 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Loop through all known devices to look for a name match |
|
||||
\*-----------------------------------------------------------------*/
|
||||
for (int i = 0; i < RAZER_NUM_DEVICES; i++)
|
||||
for (std::size_t i = 0; i < RAZER_NUM_DEVICES; i++)
|
||||
{
|
||||
if (device_list[i]->name == name)
|
||||
{
|
||||
@@ -395,11 +395,11 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
new_zone.name = device_list[i]->zones[zone_id]->name;
|
||||
new_zone.type = device_list[i]->zones[zone_id]->type;
|
||||
|
||||
for (int row_id = 0; row_id < device_list[i]->zones[zone_id]->rows; row_id++)
|
||||
for (unsigned int row_id = 0; row_id < device_list[i]->zones[zone_id]->rows; row_id++)
|
||||
{
|
||||
std::vector<int> new_zone_map;
|
||||
|
||||
for (int col_id = 0; col_id < device_list[i]->zones[zone_id]->cols; col_id++)
|
||||
for (unsigned int col_id = 0; col_id < device_list[i]->zones[zone_id]->cols; col_id++)
|
||||
{
|
||||
RGBColor new_color = 0x00000000;
|
||||
colors.push_back(new_color);
|
||||
@@ -420,4 +420,4 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_PatriotViper.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| Patriot Viper RGB interface |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/1/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_PatriotViper.h"
|
||||
|
||||
int RGBController_PatriotViper::GetMode()
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void RGBController_PatriotViper::SetMode(int mode)
|
||||
{
|
||||
if(mode == 0)
|
||||
{
|
||||
viper->SetDirect();
|
||||
}
|
||||
else
|
||||
{
|
||||
viper->SetMode(mode - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_PatriotViper::SetCustomMode()
|
||||
{
|
||||
viper->SetDirect();
|
||||
}
|
||||
|
||||
void RGBController_PatriotViper::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if(viper->direct == true)
|
||||
{
|
||||
viper->SetAllColors(red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
viper->SetEffectColor(red, grn, blu);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RGBController_PatriotViper::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if(viper->direct == true)
|
||||
{
|
||||
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
viper->SetLEDColor(zones[zone].map[x][y], red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
viper->SetLEDEffectColor(zones[zone].map[x][y], red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_PatriotViper::SetLED(int led, RGBColor color)
|
||||
{
|
||||
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::UpdateLEDs()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RGBController_PatriotViper::RGBController_PatriotViper(PatriotViperController* viper_ptr)
|
||||
{
|
||||
viper = viper_ptr;
|
||||
|
||||
name = viper->GetDeviceName();
|
||||
location = viper->GetDeviceLocation();
|
||||
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
|
||||
mode viper_modes[10];
|
||||
|
||||
viper_modes[0].name = "Direct";
|
||||
viper_modes[1].name = "Dark";
|
||||
viper_modes[2].name = "Breathing";
|
||||
viper_modes[3].name = "Viper";
|
||||
viper_modes[4].name = "Heartbeat";
|
||||
viper_modes[5].name = "Marquee";
|
||||
viper_modes[6].name = "Raindrop";
|
||||
viper_modes[7].name = "Aurora";
|
||||
viper_modes[8].name = "Unknown";
|
||||
viper_modes[9].name = "Neon";
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
modes.push_back(viper_modes[i]);
|
||||
}
|
||||
|
||||
unsigned int led_idx = 0;
|
||||
|
||||
for(unsigned int slot = 0; slot < viper->GetSlotCount(); slot++)
|
||||
{
|
||||
zone* new_zone = new zone;
|
||||
|
||||
char slot_idx_str[3];
|
||||
sprintf(slot_idx_str, "%d", slot);
|
||||
new_zone->name = "Patriot Viper RGB Slot ";
|
||||
new_zone->name.append(slot_idx_str);
|
||||
|
||||
new_zone->type = ZONE_TYPE_LINEAR;
|
||||
|
||||
std::vector<int> *new_zone_map = new std::vector<int>();
|
||||
|
||||
for(int led_slot_idx = 0; led_slot_idx < 5; led_slot_idx++)
|
||||
{
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
led* new_led = new led();
|
||||
|
||||
char led_idx_str[3];
|
||||
sprintf(led_idx_str, "%d", led_slot_idx);
|
||||
new_led->name = "Patriot Viper RGB Slot ";
|
||||
new_led->name.append(slot_idx_str);
|
||||
new_led->name.append(", LED ");
|
||||
new_led->name.append(led_idx_str);
|
||||
|
||||
leds.push_back(*new_led);
|
||||
|
||||
new_zone_map->push_back(led_idx);
|
||||
led_idx++;
|
||||
}
|
||||
|
||||
new_zone->map.push_back(*new_zone_map);
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_PatriotViper.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| Patriot Viper RGB interface |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/1/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "PatriotViperController.h"
|
||||
|
||||
class RGBController_PatriotViper : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_PatriotViper(PatriotViperController* viper_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
void SetLED(int led, RGBColor color);
|
||||
void UpdateLEDs();
|
||||
|
||||
private:
|
||||
PatriotViperController* viper;
|
||||
};
|
||||
@@ -53,7 +53,7 @@ void RGBController_Polychrome::SetLED(int led, RGBColor color)
|
||||
|
||||
void RGBController_Polychrome::UpdateLEDs()
|
||||
{
|
||||
for (int led = 0; led < colors.size(); led++)
|
||||
for (std::size_t led = 0; led < colors.size(); led++)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[led]);
|
||||
unsigned char grn = RGBGetGValue(colors[led]);
|
||||
@@ -86,7 +86,7 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
|
||||
}
|
||||
|
||||
// Search through all LEDs and create zones for each channel type
|
||||
for (int i = 0; i < polychrome->GetLEDCount(); i++)
|
||||
for (unsigned int i = 0; i < polychrome->GetLEDCount(); i++)
|
||||
{
|
||||
zone* new_zone = new zone();
|
||||
led* new_led = new led();
|
||||
@@ -109,4 +109,4 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
|
||||
// Push new zone to zones vector
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ void RGBController_RGBFusion::SetLED(int led, RGBColor color)
|
||||
|
||||
void RGBController_RGBFusion::UpdateLEDs()
|
||||
{
|
||||
for (int led = 0; led < colors.size(); led++)
|
||||
for (std::size_t led = 0; led < colors.size(); led++)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[led]);
|
||||
unsigned char grn = RGBGetGValue(colors[led]);
|
||||
@@ -91,7 +91,7 @@ RGBController_RGBFusion::RGBController_RGBFusion(RGBFusionController* rgb_fusion
|
||||
}
|
||||
|
||||
// Search through all LEDs and create zones for each channel type
|
||||
for (int i = 0; i < rgb_fusion->GetLEDCount(); i++)
|
||||
for (unsigned int i = 0; i < rgb_fusion->GetLEDCount(); i++)
|
||||
{
|
||||
zone* new_zone = new zone();
|
||||
led* new_led = new led();
|
||||
|
||||
Vendored
+1
-1
Submodule dependencies/libe131 updated: 0fc009f1f6...930956795a
@@ -54,6 +54,8 @@ class i2c_smbus_interface
|
||||
public:
|
||||
char device_name[512];
|
||||
|
||||
virtual ~i2c_smbus_interface() = default;
|
||||
|
||||
//Functions derived from i2c-core.c
|
||||
s32 i2c_smbus_write_quick(u8 addr, u8 value);
|
||||
s32 i2c_smbus_read_byte(u8 addr);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
#include "OpenAuraSDK.h"
|
||||
#include "OpenRGB.h"
|
||||
#include "RGBController.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
|
||||
@@ -236,7 +236,7 @@ void net_port::tcp_close()
|
||||
connected = false;
|
||||
}
|
||||
|
||||
int net_port::tcp_listen(char * recv_data, int length)
|
||||
int net_port::tcp_listen(char * recv_data, int /*length*/)
|
||||
{
|
||||
int ret = 0;
|
||||
int len = 0;
|
||||
|
||||
+12
-12
@@ -66,7 +66,7 @@ OpenRGBDevicePage::OpenRGBDevicePage(RGBController *dev, QWidget *parent) :
|
||||
\*-----------------------------------------------------*/
|
||||
ui->ModeBox->clear();
|
||||
|
||||
for (int i = 0; i < device->modes.size(); i++)
|
||||
for (std::size_t i = 0; i < device->modes.size(); i++)
|
||||
{
|
||||
ui->ModeBox->addItem(device->modes[i].name.c_str());
|
||||
}
|
||||
@@ -75,7 +75,7 @@ OpenRGBDevicePage::OpenRGBDevicePage(RGBController *dev, QWidget *parent) :
|
||||
|
||||
ui->ZoneBox->clear();
|
||||
|
||||
for (int i = 0; i < device->zones.size(); i++)
|
||||
for (std::size_t i = 0; i < device->zones.size(); i++)
|
||||
{
|
||||
ui->ZoneBox->addItem(device->zones[i].name.c_str());
|
||||
}
|
||||
@@ -84,7 +84,7 @@ OpenRGBDevicePage::OpenRGBDevicePage(RGBController *dev, QWidget *parent) :
|
||||
|
||||
ui->LEDBox->clear();
|
||||
|
||||
for (int i = 0; i < device->leds.size(); i++)
|
||||
for (std::size_t i = 0; i < device->leds.size(); i++)
|
||||
{
|
||||
ui->LEDBox->addItem(device->leds[i].name.c_str());
|
||||
}
|
||||
@@ -97,17 +97,17 @@ OpenRGBDevicePage::~OpenRGBDevicePage()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_ZoneBox_currentIndexChanged(int index)
|
||||
void Ui::OpenRGBDevicePage::on_ZoneBox_currentIndexChanged(int /*index*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_LEDBox_currentIndexChanged(int index)
|
||||
void Ui::OpenRGBDevicePage::on_LEDBox_currentIndexChanged(int /*index*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_ModeBox_currentIndexChanged(int index)
|
||||
void Ui::OpenRGBDevicePage::on_ModeBox_currentIndexChanged(int /*index*/)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Change device mode |
|
||||
@@ -274,32 +274,32 @@ void Ui::OpenRGBDevicePage::updateHSV()
|
||||
UpdatingColor = false;
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_RedSpinBox_valueChanged(int arg1)
|
||||
void Ui::OpenRGBDevicePage::on_RedSpinBox_valueChanged(int /*arg1*/)
|
||||
{
|
||||
updateHSV();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_HueSpinBox_valueChanged(int arg1)
|
||||
void Ui::OpenRGBDevicePage::on_HueSpinBox_valueChanged(int /*arg1*/)
|
||||
{
|
||||
updateRGB();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_GreenSpinBox_valueChanged(int arg1)
|
||||
void Ui::OpenRGBDevicePage::on_GreenSpinBox_valueChanged(int /*arg1*/)
|
||||
{
|
||||
updateHSV();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_SatSpinBox_valueChanged(int arg1)
|
||||
void Ui::OpenRGBDevicePage::on_SatSpinBox_valueChanged(int /*arg1*/)
|
||||
{
|
||||
updateRGB();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_BlueSpinBox_valueChanged(int arg1)
|
||||
void Ui::OpenRGBDevicePage::on_BlueSpinBox_valueChanged(int /*arg1*/)
|
||||
{
|
||||
updateHSV();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_ValSpinBox_valueChanged(int arg1)
|
||||
void Ui::OpenRGBDevicePage::on_ValSpinBox_valueChanged(int /*arg1*/)
|
||||
{
|
||||
updateRGB();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "OpenRGBDialog.h"
|
||||
#include "OpenAuraSDK.h"
|
||||
|
||||
using namespace Ui;
|
||||
|
||||
@@ -54,7 +53,7 @@ OpenRGBDialog::OpenRGBDialog(std::vector<i2c_smbus_interface *>& bus, std::vecto
|
||||
ui->ButtonMagenta->setFlat(true);
|
||||
ui->ButtonMagenta->update();
|
||||
|
||||
for (int i = 0; i < controllers.size(); i++)
|
||||
for (std::size_t i = 0; i < controllers.size(); i++)
|
||||
{
|
||||
ui->ComboDevices->addItem(controllers[i]->name.c_str());
|
||||
}
|
||||
@@ -123,7 +122,7 @@ void Ui::OpenRGBDialog::on_ButtonSetAll_clicked()
|
||||
ui->EditLED0B->text().toInt()
|
||||
);
|
||||
|
||||
for (int i = 0; i < controllers.size(); i++)
|
||||
for (std::size_t i = 0; i < controllers.size(); i++)
|
||||
{
|
||||
controllers[i]->SetCustomMode();
|
||||
controllers[i]->SetAllLEDs(color);
|
||||
@@ -163,11 +162,11 @@ void Ui::OpenRGBDialog::on_ButtonSetLED_clicked()
|
||||
controllers[ui->ComboDevices->currentIndex()]->SetLED(ui->ComboLEDs->currentIndex(), color);
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDialog::on_ComboDevices_currentIndexChanged(int index)
|
||||
void Ui::OpenRGBDialog::on_ComboDevices_currentIndexChanged()
|
||||
{
|
||||
ui->ComboModes->clear();
|
||||
|
||||
for (int i = 0; i < controllers[ui->ComboDevices->currentIndex()]->modes.size(); i++)
|
||||
for (std::size_t i = 0; i < controllers[ui->ComboDevices->currentIndex()]->modes.size(); i++)
|
||||
{
|
||||
ui->ComboModes->addItem(controllers[ui->ComboDevices->currentIndex()]->modes[i].name.c_str());
|
||||
}
|
||||
@@ -176,7 +175,7 @@ void Ui::OpenRGBDialog::on_ComboDevices_currentIndexChanged(int index)
|
||||
|
||||
ui->ComboZones->clear();
|
||||
|
||||
for (int i = 0; i < controllers[ui->ComboDevices->currentIndex()]->zones.size(); i++)
|
||||
for (std::size_t i = 0; i < controllers[ui->ComboDevices->currentIndex()]->zones.size(); i++)
|
||||
{
|
||||
ui->ComboZones->addItem(controllers[ui->ComboDevices->currentIndex()]->zones[i].name.c_str());
|
||||
}
|
||||
@@ -185,7 +184,7 @@ void Ui::OpenRGBDialog::on_ComboDevices_currentIndexChanged(int index)
|
||||
|
||||
ui->ComboLEDs->clear();
|
||||
|
||||
for (int i = 0; i < controllers[ui->ComboDevices->currentIndex()]->leds.size(); i++)
|
||||
for (std::size_t i = 0; i < controllers[ui->ComboDevices->currentIndex()]->leds.size(); i++)
|
||||
{
|
||||
ui->ComboLEDs->addItem(controllers[ui->ComboDevices->currentIndex()]->leds[i].name.c_str());
|
||||
}
|
||||
@@ -193,7 +192,7 @@ void Ui::OpenRGBDialog::on_ComboDevices_currentIndexChanged(int index)
|
||||
ui->ComboLEDs->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDialog::on_ComboModes_currentIndexChanged(int index)
|
||||
void Ui::OpenRGBDialog::on_ComboModes_currentIndexChanged()
|
||||
{
|
||||
controllers[ui->ComboDevices->currentIndex()]->SetMode(ui->ComboModes->currentIndex());
|
||||
}
|
||||
|
||||
+2
-2
@@ -48,9 +48,9 @@ private slots:
|
||||
|
||||
void on_ButtonSetLED_clicked();
|
||||
|
||||
void on_ComboDevices_currentIndexChanged(int index);
|
||||
void on_ComboDevices_currentIndexChanged();
|
||||
|
||||
void on_ComboModes_currentIndexChanged(int index);
|
||||
void on_ComboModes_currentIndexChanged();
|
||||
|
||||
private:
|
||||
Ui::OpenRGBDialogUi *ui;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "OpenRGBDevicePage.h"
|
||||
#include "OpenRGBDeviceInfoPage.h"
|
||||
#include "OpenRGBSystemInfoPage.h"
|
||||
#include "OpenAuraSDK.h"
|
||||
#include <QLabel>
|
||||
#include <QTabBar>
|
||||
|
||||
@@ -20,7 +19,7 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
|
||||
\*-----------------------------------------------------*/
|
||||
QTabBar *DevicesTabBar = ui->DevicesTabBar->tabBar();
|
||||
|
||||
for(int dev_idx = 0; dev_idx < control.size(); dev_idx++)
|
||||
for(std::size_t dev_idx = 0; dev_idx < control.size(); dev_idx++)
|
||||
{
|
||||
OpenRGBDevicePage *NewPage = new OpenRGBDevicePage(control[dev_idx]);
|
||||
ui->DevicesTabBar->addTab(NewPage, "");
|
||||
@@ -80,7 +79,7 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
|
||||
\*-----------------------------------------------------*/
|
||||
QTabBar *InformationTabBar = ui->InformationTabBar->tabBar();
|
||||
|
||||
for(int dev_idx = 0; dev_idx < control.size(); dev_idx++)
|
||||
for(std::size_t dev_idx = 0; dev_idx < control.size(); dev_idx++)
|
||||
{
|
||||
OpenRGBDeviceInfoPage *NewPage = new OpenRGBDeviceInfoPage(control[dev_idx]);
|
||||
ui->InformationTabBar->addTab(NewPage, "");
|
||||
|
||||
@@ -5,8 +5,8 @@ using namespace Ui;
|
||||
|
||||
OpenRGBSystemInfoPage::OpenRGBSystemInfoPage(std::vector<i2c_smbus_interface *>& bus, QWidget *parent) :
|
||||
QFrame(parent),
|
||||
busses(bus),
|
||||
ui(new Ui::OpenRGBSystemInfoPageUi)
|
||||
ui(new Ui::OpenRGBSystemInfoPageUi),
|
||||
busses(bus)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -22,7 +22,7 @@ OpenRGBSystemInfoPage::OpenRGBSystemInfoPage(std::vector<i2c_smbus_interface *>&
|
||||
\*-----------------------------------------------------*/
|
||||
ui->SMBusAdaptersBox->clear();
|
||||
|
||||
for (int i = 0; i < busses.size(); i++)
|
||||
for (std::size_t i = 0; i < busses.size(); i++)
|
||||
{
|
||||
ui->SMBusAdaptersBox->addItem(busses[i]->device_name);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
std::string find_usb_serial_port(unsigned short vid, unsigned short pid);
|
||||
@@ -0,0 +1,116 @@
|
||||
#include "find_usb_serial_port.h"
|
||||
|
||||
/*---------------------------------------------------------------------*\
|
||||
| |
|
||||
| find_usb_serial_port |
|
||||
| |
|
||||
| This function returns the name of the first USB serial port matching|
|
||||
| the given USB product and vendor ID. |
|
||||
| |
|
||||
| vid: Vendor ID code |
|
||||
| pid: Product ID code |
|
||||
| |
|
||||
| returns: std::string containing port name "COMx" or "/dev/ttyX" |
|
||||
| |
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
std::string find_usb_serial_port(unsigned short vid, unsigned short pid)
|
||||
{
|
||||
std::string ret_string = "";
|
||||
DIR* dir;
|
||||
char symlink_path[1024] = {0};
|
||||
struct dirent* ent;
|
||||
char vid_pid[10] = {0}; //Store VID/PID
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Open /sys/class/tty |
|
||||
\*-----------------------------------------------------------------*/
|
||||
dir = opendir("/sys/class/tty");
|
||||
|
||||
if(dir == NULL)
|
||||
{
|
||||
closedir(dir);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Loop through all symlinks in /sys/class/tty directory to find |
|
||||
| paths with "usb" in them. These links should have the USB device |
|
||||
| index which can be used to find the VID/PID |
|
||||
\*-----------------------------------------------------------------*/
|
||||
ent = readdir(dir);
|
||||
|
||||
while(ent != NULL)
|
||||
{
|
||||
if(ent->d_type == DT_LNK)
|
||||
{
|
||||
char tty_path[1024];
|
||||
strcpy(tty_path, "/sys/class/tty/");
|
||||
strcat(tty_path, ent->d_name);
|
||||
|
||||
readlink(tty_path, symlink_path, 1024);
|
||||
|
||||
char * usb_string = strstr(symlink_path, "usb");
|
||||
|
||||
if(usb_string != NULL)
|
||||
{
|
||||
char * usb_dev = strstr(usb_string, "/");
|
||||
usb_dev++;
|
||||
usb_dev = strtok(usb_dev, "/");
|
||||
|
||||
char usb_path[1024];
|
||||
|
||||
strcpy(usb_path, "/sys/bus/usb/devices/");
|
||||
strcat(usb_path, usb_dev);
|
||||
|
||||
char vendor_path[1024];
|
||||
char product_path[1024];
|
||||
|
||||
strcpy(vendor_path, usb_path);
|
||||
strcat(vendor_path, "/idVendor");
|
||||
|
||||
strcpy(product_path, usb_path);
|
||||
strcat(product_path, "/idProduct");
|
||||
|
||||
std::ifstream vendor_file;
|
||||
std::ifstream product_file;
|
||||
std::string vendor_string;
|
||||
std::string product_string;
|
||||
|
||||
vendor_file.open(vendor_path);
|
||||
product_file.open(product_path);
|
||||
|
||||
std::getline(vendor_file, vendor_string);
|
||||
std::getline(product_file, product_string);
|
||||
|
||||
snprintf(vid_pid, 10, "%04x", vid);
|
||||
|
||||
if((strcmp(vid_pid, vendor_string.c_str()) == 0)
|
||||
{
|
||||
snprintf(vid_pid, 10, "%04x", pid);
|
||||
if(strcmp(vid_pid, product_string.c_str()) == 0)
|
||||
{
|
||||
char* port_string = NULL;
|
||||
for(int i = strlen(tty_path); i > 0; i--)
|
||||
{
|
||||
if(tty_path[i] == '/')
|
||||
{
|
||||
port_string = &tty_path[i + 1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
ret_string.append("/dev/");
|
||||
ret_string.append(port_string);
|
||||
|
||||
return ret_string;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ent = readdir(dir);
|
||||
}
|
||||
|
||||
return ret_string;
|
||||
|
||||
} /* find_usb_serial_port() */
|
||||
@@ -0,0 +1,118 @@
|
||||
#include "find_usb_serial_port.h"
|
||||
|
||||
#include <initguid.h>
|
||||
#include <windows.h>
|
||||
#include <Setupapi.h>
|
||||
|
||||
//Buffer length
|
||||
#define BUFF_LEN 20
|
||||
|
||||
#pragma comment (lib, "Setupapi.lib")
|
||||
#pragma comment(lib, "advapi32")
|
||||
|
||||
/*---------------------------------------------------------------------*\
|
||||
| |
|
||||
| find_usb_serial_port |
|
||||
| |
|
||||
| This function returns the name of the first USB serial port matching|
|
||||
| the given USB product and vendor ID. |
|
||||
| |
|
||||
| vid: Vendor ID code |
|
||||
| pid: Product ID code |
|
||||
| |
|
||||
| returns: std::string containing port name "COMx" or "/dev/ttyX" |
|
||||
| |
|
||||
\*---------------------------------------------------------------------*/
|
||||
|
||||
std::string find_usb_serial_port(unsigned short vid, unsigned short pid)
|
||||
{
|
||||
std::string ret_str = "";
|
||||
HDEVINFO DeviceInfoSet;
|
||||
DWORD DeviceIndex = 0;
|
||||
SP_DEVINFO_DATA DeviceInfoData;
|
||||
const char * DevEnum = "USB";
|
||||
char ExpectedDeviceId[80] = {0}; //Store hardware id
|
||||
char vid_pid[10] = {0}; //Store VID/PID
|
||||
BYTE szBuffer[1024] = {0};
|
||||
DEVPROPTYPE ulPropertyType;
|
||||
DWORD dwSize = 0;
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Create device hardware id |
|
||||
| "vid_ABCD&pid_CDEF" |
|
||||
\*-----------------------------------------------------------------*/
|
||||
strcpy(ExpectedDeviceId, "vid_");
|
||||
snprintf(vid_pid, 10, "%04X", vid);
|
||||
strcat(ExpectedDeviceId, vid_pid);
|
||||
strcat(ExpectedDeviceId, "&pid_");
|
||||
snprintf(vid_pid, 10, "%04X", pid);
|
||||
strcat(ExpectedDeviceId, vid_pid);
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| SetupDiGetClassDevs returns a handle to a device information set |
|
||||
\*-----------------------------------------------------------------*/
|
||||
DeviceInfoSet = SetupDiGetClassDevs( NULL, DevEnum, NULL, DIGCF_ALLCLASSES | DIGCF_PRESENT);
|
||||
|
||||
if (DeviceInfoSet == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Set up Device Info Data |
|
||||
\*-----------------------------------------------------------------*/
|
||||
memset(&DeviceInfoData, 0, sizeof(SP_DEVINFO_DATA));
|
||||
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Receive information about an enumerated device |
|
||||
\*-----------------------------------------------------------------*/
|
||||
while (SetupDiEnumDeviceInfo( DeviceInfoSet, DeviceIndex, &DeviceInfoData))
|
||||
{
|
||||
DeviceIndex++;
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Retrieves a specified Plug and Play device property |
|
||||
\*-------------------------------------------------------------*/
|
||||
if (SetupDiGetDeviceRegistryProperty (DeviceInfoSet, &DeviceInfoData, SPDRP_HARDWAREID, &ulPropertyType, (BYTE*)szBuffer, sizeof(szBuffer), &dwSize))
|
||||
{
|
||||
HKEY hDeviceRegistryKey;
|
||||
|
||||
hDeviceRegistryKey = SetupDiOpenDevRegKey(DeviceInfoSet, &DeviceInfoData,DICS_FLAG_GLOBAL, 0,DIREG_DEV, KEY_READ);
|
||||
if (hDeviceRegistryKey == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
char pszPortName[BUFF_LEN];
|
||||
DWORD dwSize = sizeof(pszPortName);
|
||||
DWORD dwType = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Read in the name of the port |
|
||||
\*-----------------------------------------------------*/
|
||||
if( (RegQueryValueEx(hDeviceRegistryKey,"PortName", NULL, &dwType, (LPBYTE) pszPortName, &dwSize) == ERROR_SUCCESS) && (dwType == REG_SZ))
|
||||
{
|
||||
if(strncmp(pszPortName, "COM", 3) == 0)
|
||||
{
|
||||
ret_str.append(pszPortName);
|
||||
return ret_str;
|
||||
}
|
||||
}
|
||||
|
||||
// Close the key now that we are finished with it
|
||||
RegCloseKey(hDeviceRegistryKey);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (DeviceInfoSet)
|
||||
{
|
||||
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
|
||||
}
|
||||
|
||||
return ret_str;
|
||||
|
||||
} /* find_usb_serial_port() */
|
||||
Reference in New Issue
Block a user