Compare commits
75
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42df4c5026 | ||
|
|
dd6a6ca85a | ||
|
|
4d5003f49d | ||
|
|
7226a4164f | ||
|
|
c7030ad47d | ||
|
|
11770aaa3a | ||
|
|
f8212ca59e | ||
|
|
dbf3dd86b4 | ||
|
|
0fe3adc267 | ||
|
|
f45b20602b | ||
|
|
f6bf044ba0 | ||
|
|
420e4dc077 | ||
|
|
3c77c1a9a8 | ||
|
|
5074a923d1 | ||
|
|
bfd8030438 | ||
|
|
af84c5bb00 | ||
|
|
3de7150408 | ||
|
|
6fdf34e16f | ||
|
|
7bdf19387d | ||
|
|
a27c614a8b | ||
|
|
b7b93ad606 | ||
|
|
dbf796256b | ||
|
|
f38b90ad52 | ||
|
|
5f3fe509a4 | ||
|
|
189bf0d7a4 | ||
|
|
60531bbf07 | ||
|
|
fd9134c911 | ||
|
|
f33f00d8a9 | ||
|
|
f2d35466a5 | ||
|
|
bce9fc929e | ||
|
|
cdaae5fb9f | ||
|
|
9fc9059b0b | ||
|
|
2c1fe31211 | ||
|
|
13f53ae4f8 | ||
|
|
eac739fdb4 | ||
|
|
5ae3de993d | ||
|
|
e79c97c4d0 | ||
|
|
45c7bc8008 | ||
|
|
7de0b2549b | ||
|
|
39b52326b6 | ||
|
|
b35c900fae | ||
|
|
7cea74e466 | ||
|
|
5f3e43e7b8 | ||
|
|
a84407b609 | ||
|
|
000511deff | ||
|
|
fe37c261a2 | ||
|
|
cbdbb71d79 | ||
|
|
5f786e649a | ||
|
|
f76bf34d8d | ||
|
|
e799574730 | ||
|
|
1a5b12c7a0 | ||
|
|
d2acc75ba8 | ||
|
|
74bcfbd940 | ||
|
|
1db45f2cf2 | ||
|
|
6e467fe8cd | ||
|
|
441c462e59 | ||
|
|
89b4716012 | ||
|
|
e51e9a71a0 | ||
|
|
02273a3601 | ||
|
|
e0018b23aa | ||
|
|
b06f384350 | ||
|
|
7dddb9d111 | ||
|
|
0d38154134 | ||
|
|
7dd84c7ac8 | ||
|
|
ffd0088378 | ||
|
|
f0c486c30d | ||
|
|
010ab1182d | ||
|
|
7e64ca1f83 | ||
|
|
2fcff92523 | ||
|
|
8beeb5f7b2 | ||
|
|
7d2b5f285f | ||
|
|
b8eb4e9bcb | ||
|
|
733b904ec4 | ||
|
|
59a3b41480 | ||
|
|
28b41451f8 |
+1
-1
@@ -1,3 +1,3 @@
|
||||
[submodule "dependencies/libe131"]
|
||||
path = dependencies/libe131
|
||||
url = https://github.com/hhromic/libe131
|
||||
url = https://github.com/CalcProgrammer1/libe131
|
||||
|
||||
@@ -0,0 +1,330 @@
|
||||
/*-----------------------------------------*\
|
||||
| AMDWraithPrismController.h |
|
||||
| |
|
||||
| Driver for AMD Wraith Prism RGB lighting |
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/6/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AMDWraithPrismController.h"
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
AMDWraithPrismController::AMDWraithPrismController(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
strcpy(device_name, "AMD Wraith Prism");
|
||||
|
||||
SendEnableCommand();
|
||||
SetRingEffectChannel(0x00);
|
||||
SendApplyCommand();
|
||||
}
|
||||
|
||||
AMDWraithPrismController::~AMDWraithPrismController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
char* AMDWraithPrismController::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
std::string AMDWraithPrismController::GetEffectChannelString(unsigned char channel)
|
||||
{
|
||||
std::string ret_string = "";
|
||||
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x40, 0x21, 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;
|
||||
|
||||
usb_buf[0x02] = channel;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
|
||||
ret_string.append((char *)&usb_buf[0x08]);
|
||||
|
||||
return(ret_string);
|
||||
}
|
||||
|
||||
std::string AMDWraithPrismController::GetFirmwareVersionString()
|
||||
{
|
||||
std::string ret_string = "";
|
||||
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x12, 0x20, 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;
|
||||
unsigned char fw_buf[16] = {0x00};
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
|
||||
for(int char_idx = 0; char_idx < 16; char_idx+=2)
|
||||
{
|
||||
if(usb_buf[char_idx + 0x08] != 0)
|
||||
{
|
||||
fw_buf[char_idx / 2] = usb_buf[char_idx + 0x08];
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ret_string.append((char *)fw_buf);
|
||||
|
||||
return(ret_string);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SetFanColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x51, 0x2C, 0x01, 0x00,
|
||||
0x06, 0xFF, 0x00, 0x01,
|
||||
0xFF, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF
|
||||
};
|
||||
|
||||
int actual;
|
||||
|
||||
usb_buf[0x0A] = red;
|
||||
usb_buf[0x0B] = green;
|
||||
usb_buf[0x0C] = blue;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SetLogoColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x51, 0x2C, 0x01, 0x00,
|
||||
0x05, 0xFF, 0x00, 0x01,
|
||||
0xFF, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF
|
||||
};
|
||||
|
||||
int actual;
|
||||
|
||||
usb_buf[0x0A] = red;
|
||||
usb_buf[0x0B] = green;
|
||||
usb_buf[0x0C] = blue;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SetRingColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x51, 0x2C, 0x01, 0x00,
|
||||
0x00, 0xFF, 0x00, 0xFF,
|
||||
0xFF, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF
|
||||
};
|
||||
|
||||
int actual;
|
||||
|
||||
usb_buf[0x0A] = red;
|
||||
usb_buf[0x0B] = green;
|
||||
usb_buf[0x0C] = blue;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SetRingEffectChannel(unsigned char channel)
|
||||
{
|
||||
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,
|
||||
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;
|
||||
|
||||
for(int led = 0x0A; led <= 0x18; led++)
|
||||
{
|
||||
usb_buf[led] = channel;
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SendEnableCommand()
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x41, 0x80, 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;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SendApplyCommand()
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
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,
|
||||
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;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SendEffectCommand()
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x51, 0x2C, 0x01, 0x00,
|
||||
0x05, 0xFF, 0x00, 0x01,
|
||||
0xFF, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF
|
||||
};
|
||||
|
||||
int actual;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*-----------------------------------------*\
|
||||
| AMDWraithPrismController.h |
|
||||
| |
|
||||
| Definitions and types for AMD Wraith |
|
||||
| Prism lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/6/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
class AMDWraithPrismController
|
||||
{
|
||||
public:
|
||||
AMDWraithPrismController(libusb_device_handle* dev_handle);
|
||||
~AMDWraithPrismController();
|
||||
|
||||
char* GetDeviceName();
|
||||
|
||||
std::string GetEffectChannelString(unsigned char channel);
|
||||
std::string GetFirmwareVersionString();
|
||||
|
||||
void SetRingEffectChannel(unsigned char channel);
|
||||
|
||||
void SetFanColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLogoColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetRingColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
void SendEnableCommand();
|
||||
void SendApplyCommand();
|
||||
void SendEffectCommand();
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
libusb_device_handle* dev;
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "AMDWraithPrismController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AMDWraithPrism.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#define AMD_WRAITH_PRISM_VID 0x2516
|
||||
#define AMD_WRAITH_PRISM_PID 0x0051
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAMDWraithPrismControllers *
|
||||
* *
|
||||
* Tests the USB address to see if an AMD Wraith Prism controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAMDWraithPrismControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
|
||||
//Look for AMD Wraith Prism
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, AMD_WRAITH_PRISM_VID, AMD_WRAITH_PRISM_PID);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 1);
|
||||
libusb_claim_interface(dev, 1);
|
||||
|
||||
AMDWraithPrismController* controller = new AMDWraithPrismController(dev);
|
||||
|
||||
RGBController_AMDWraithPrism* rgb_controller = new RGBController_AMDWraithPrism(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraController.h |
|
||||
| AuraController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB lighting |
|
||||
| controller |
|
||||
@@ -82,11 +82,21 @@ AuraController::~AuraController()
|
||||
|
||||
}
|
||||
|
||||
char * AuraController::GetDeviceName()
|
||||
std::string AuraController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string AuraController::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 char AuraController::GetChannel(unsigned int led)
|
||||
{
|
||||
return(config_table[channel_cfg + led]);
|
||||
@@ -147,11 +157,26 @@ unsigned int AuraController::GetLEDCount()
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
unsigned char AuraController::GetLEDRed(unsigned int led)
|
||||
{
|
||||
return(AuraRegisterRead(direct_reg + ( 3 * led )));
|
||||
}
|
||||
|
||||
unsigned char AuraController::GetLEDGreen(unsigned int led)
|
||||
{
|
||||
return(AuraRegisterRead(direct_reg + ( 3 * led ) + 2));
|
||||
}
|
||||
|
||||
unsigned char AuraController::GetLEDBlue(unsigned int led)
|
||||
{
|
||||
return(AuraRegisterRead(direct_reg + ( 3 * led ) + 1));
|
||||
}
|
||||
|
||||
void AuraController::SetAllColorsDirect(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
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;
|
||||
@@ -167,7 +192,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;
|
||||
@@ -178,7 +203,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)
|
||||
@@ -219,30 +244,45 @@ void AuraController::AuraUpdateDeviceName()
|
||||
|
||||
unsigned char AuraController::AuraRegisterRead(aura_register reg)
|
||||
{
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
//Write Aura register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Read Aura value
|
||||
return(bus->i2c_smbus_read_byte_data(dev, 0x81));
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void AuraController::AuraRegisterWrite(aura_register reg, unsigned char val)
|
||||
{
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
//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);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void AuraController::AuraRegisterWriteBlock(aura_register reg, unsigned char * data, unsigned char sz)
|
||||
{
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
//Write Aura register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Write Aura block data
|
||||
bus->i2c_smbus_write_block_data(dev, 0x03, sz, data);
|
||||
|
||||
}
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
| Adam Honse (CalcProgrammer1) 8/19/2018 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
@@ -93,10 +94,14 @@ public:
|
||||
AuraController(i2c_smbus_interface* bus, aura_dev_id dev);
|
||||
~AuraController();
|
||||
|
||||
char* GetDeviceName();
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
unsigned char GetChannel(unsigned int led);
|
||||
const char* GetChannelName(unsigned int led);
|
||||
unsigned int GetLEDCount();
|
||||
unsigned char GetLEDRed(unsigned int led);
|
||||
unsigned char GetLEDGreen(unsigned int led);
|
||||
unsigned char GetLEDBlue(unsigned int led);
|
||||
void SetAllColorsDirect(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetAllColorsEffect(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetDirect(unsigned char direct);
|
||||
@@ -120,4 +125,4 @@ private:
|
||||
i2c_smbus_interface * bus;
|
||||
aura_dev_id dev;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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() */
|
||||
|
||||
@@ -24,35 +24,48 @@ CorsairController::~CorsairController()
|
||||
|
||||
}
|
||||
|
||||
char * CorsairController::GetDeviceName()
|
||||
std::string CorsairController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string CorsairController::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 CorsairController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
void CorsairController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
void CorsairController::SetLEDColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
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);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_GREEN_VAL, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_BLUE_VAL, blue);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_MODE, CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void CorsairController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
void CorsairController::SetMode(unsigned char /*mode*/)
|
||||
{
|
||||
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);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_GREEN_VAL, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_BLUE_VAL, blue);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_MODE, CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
|
||||
}
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
void CorsairController::SetMode(unsigned char mode)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_MODE, CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
|
||||
}
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
| Adam Honse (CalcProgrammer1) 3/8/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
@@ -38,16 +39,16 @@ public:
|
||||
CorsairController(i2c_smbus_interface* bus, corsair_dev_id dev);
|
||||
~CorsairController();
|
||||
|
||||
char* GetDeviceName();
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
unsigned int GetLEDCount();
|
||||
void SetMode(unsigned char mode);
|
||||
|
||||
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 SetLEDColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
unsigned int led_count;
|
||||
i2c_smbus_interface * bus;
|
||||
corsair_dev_id dev;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
void Sleep(unsigned int milliseconds)
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
@@ -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;
|
||||
@@ -42,11 +42,21 @@ CorsairProController::~CorsairProController()
|
||||
|
||||
}
|
||||
|
||||
char* CorsairProController::GetDeviceName()
|
||||
std::string CorsairProController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string CorsairProController::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 CorsairProController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
@@ -54,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;
|
||||
@@ -71,6 +81,9 @@ void CorsairProController::SetLEDColor(unsigned int led, unsigned char red, unsi
|
||||
|
||||
void CorsairProController::ApplyColors()
|
||||
{
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x02);
|
||||
Sleep(1);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
|
||||
@@ -85,10 +98,16 @@ void CorsairProController::ApplyColors()
|
||||
}
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x82, 0x02);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void CorsairProController::SetEffect(unsigned char mode)
|
||||
{
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x01);
|
||||
Sleep(1);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
|
||||
@@ -117,6 +136,9 @@ void CorsairProController::SetEffect(unsigned char mode)
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x82, 0x01);
|
||||
WaitReady();
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void CorsairProController::SetCustom()
|
||||
@@ -134,4 +156,4 @@ bool CorsairProController::WaitReady()
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
| Adam Honse (CalcProgrammer1) 6/30/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
@@ -65,7 +66,8 @@ public:
|
||||
CorsairProController(i2c_smbus_interface* bus, corsair_dev_id dev);
|
||||
~CorsairProController();
|
||||
|
||||
char* GetDeviceName();
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
unsigned int GetLEDCount();
|
||||
void SetEffect(unsigned char mode);
|
||||
void SetCustom();
|
||||
@@ -85,4 +87,4 @@ private:
|
||||
|
||||
i2c_smbus_interface* bus;
|
||||
corsair_dev_id dev;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| 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;
|
||||
|
||||
case 0x0B: //Aer 2 fan
|
||||
num_leds_on_channel += 8;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
channel_leds[chan] = num_leds_on_channel;
|
||||
}
|
||||
return(ret_val);
|
||||
}
|
||||
|
||||
void Hue2Controller::SetChannelEffect(unsigned int channel, unsigned int mode, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x28, 0x03, 0x00, 0x28,
|
||||
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;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set channel in USB packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x02] = 1 << channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set mode in USB packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x04] = mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set color count in USB packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x08] = colors.size();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for (std::size_t idx = 0; idx < colors.size(); idx++)
|
||||
{
|
||||
int pixel_idx = idx * 3;
|
||||
RGBColor color = colors[idx];
|
||||
usb_buf[pixel_idx + 0x0A] = RGBGetGValue(color);
|
||||
usb_buf[pixel_idx + 0x0B] = RGBGetRValue(color);
|
||||
usb_buf[pixel_idx + 0x0C] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
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] = 1 << channel;
|
||||
usb_apply[0x02] = 1 << 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 = 0;
|
||||
|
||||
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,59 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| 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 SetChannelEffect(unsigned int channel, unsigned int mode, std::vector<RGBColor> colors);
|
||||
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() */
|
||||
@@ -10,87 +10,35 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
HuePlusController::HuePlusController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
HuePlusController::~HuePlusController()
|
||||
{
|
||||
}
|
||||
|
||||
void HuePlusController::Initialize(char* ledstring)
|
||||
void HuePlusController::Initialize(char* port_name)
|
||||
{
|
||||
strcpy(led_string, ledstring);
|
||||
strcpy(led_string, port_name);
|
||||
|
||||
serialport = new serial_port(port_name, HUE_PLUS_BAUD);
|
||||
|
||||
LPSTR source = NULL;
|
||||
LPSTR channels = NULL;
|
||||
LPSTR numleds = NULL;
|
||||
LPSTR next = NULL;
|
||||
|
||||
source = strtok_s(ledstring, ",", &next);
|
||||
|
||||
//Check for selected channel 0=both, 1= Ch.1, 2= Ch.2
|
||||
if (strlen(next))
|
||||
{
|
||||
channels = strtok_s(next, ",", &next);
|
||||
}
|
||||
|
||||
switch (atoi(channels))
|
||||
{
|
||||
case 0:
|
||||
channel = 0x00;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
channel = 0x01;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
channel = 0x02;
|
||||
break;
|
||||
}
|
||||
|
||||
//Check for the number of LEDs, sets the corresponding variable with the counter for the fans
|
||||
if (strlen(next))
|
||||
{
|
||||
numleds = strtok_s(next, ",", &next);
|
||||
}
|
||||
|
||||
switch (atoi(numleds) / 8)
|
||||
{
|
||||
case 1:
|
||||
fans = 0x00;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
fans = 0x01;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
fans = 0x02;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
fans = 0x03;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
fans = 0x04;
|
||||
break;
|
||||
}
|
||||
|
||||
//Initialize with default baud rate
|
||||
source = strtok(source, "\r");
|
||||
strcpy(port_name, source);
|
||||
baud_rate = 256000;
|
||||
serialport = new serial_port(port_name, baud_rate);
|
||||
|
||||
if (numleds != NULL && strlen(numleds))
|
||||
{
|
||||
num_leds = atoi(numleds);
|
||||
}
|
||||
channel_leds[HUE_PLUS_CHANNEL_1_IDX] = GetStripsOnChannel(HUE_PLUS_CHANNEL_1) * 10;
|
||||
channel_leds[HUE_PLUS_CHANNEL_2_IDX] = GetStripsOnChannel(HUE_PLUS_CHANNEL_2) * 10;
|
||||
}
|
||||
|
||||
char* HuePlusController::GetLEDString()
|
||||
@@ -98,39 +46,164 @@ char* HuePlusController::GetLEDString()
|
||||
return(led_string);
|
||||
}
|
||||
|
||||
void HuePlusController::SetLEDs(std::vector<RGBColor> colors)
|
||||
unsigned int HuePlusController::GetStripsOnChannel(unsigned int channel)
|
||||
{
|
||||
if (serialport != NULL)
|
||||
unsigned char serial_buf[] =
|
||||
{
|
||||
unsigned char *serial_buf;
|
||||
0x8D, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
serial_buf = new unsigned char[hueSize]; //Size of Message always 5 XX Blocks (Mode Selection) + 3 XX for each LED (1 color)
|
||||
//-> max of 40 LEDs per Channel (or 5 Fans a 8 LEDs) -> 125 Blocks (empty LEDs are written, too
|
||||
serial_buf[0] = 0x4b;
|
||||
serial_buf[1] = channel;
|
||||
serial_buf[2] = 0x0e;
|
||||
serial_buf[3] = fans;
|
||||
serial_buf[4] = 0x00;
|
||||
unsigned int ret_val = 0;
|
||||
|
||||
for (int i = 5; i < hueSize; i++)
|
||||
{
|
||||
//clearing the buf otherwise sometimes strange things are written to the COM Port
|
||||
serial_buf[i] = 0x00;
|
||||
}
|
||||
/*-----------------------------------------------------*\
|
||||
| Set channel in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x01] = channel;
|
||||
|
||||
for (int idx = 0; idx < (num_leds * 3); idx += 3)
|
||||
{
|
||||
int pixel_idx = idx / 3;
|
||||
RGBColor color = colors[pixel_idx];
|
||||
serial_buf[idx + 5] = RGBGetGValue(color);
|
||||
serial_buf[idx + 6] = RGBGetRValue(color);
|
||||
serial_buf[idx + 7] = RGBGetBValue(color);
|
||||
}
|
||||
serialport->serial_flush_rx();
|
||||
serialport->serial_write((char *)serial_buf, 2);
|
||||
serialport->serial_flush_tx();
|
||||
|
||||
serialport->serial_write((char *)serial_buf, hueSize);
|
||||
serialport->serial_flush_tx();
|
||||
Sleep(50);
|
||||
|
||||
delete[] serial_buf;
|
||||
int bytes_read = serialport->serial_read((char *)serial_buf, 5);
|
||||
|
||||
if(bytes_read == 5)
|
||||
{
|
||||
ret_val = serial_buf[4];
|
||||
}
|
||||
|
||||
}
|
||||
return(ret_val);
|
||||
}
|
||||
|
||||
void HuePlusController::SetChannelEffect(unsigned int channel, unsigned int mode, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char serial_buf[] =
|
||||
{
|
||||
0x4B, 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, 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
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set channel in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x01] = channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set mode in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x02] = mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for (std::size_t idx = 0; idx < colors.size(); idx++)
|
||||
{
|
||||
int pixel_idx = idx * 3;
|
||||
RGBColor color = colors[idx];
|
||||
serial_buf[pixel_idx + 0x05] = RGBGetGValue(color);
|
||||
serial_buf[pixel_idx + 0x06] = RGBGetRValue(color);
|
||||
serial_buf[pixel_idx + 0x07] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
serialport->serial_write((char *)serial_buf, HUE_PLUS_PACKET_SIZE);
|
||||
serialport->serial_flush_tx();
|
||||
|
||||
Sleep(10);
|
||||
}
|
||||
|
||||
void HuePlusController::SetChannelLEDs(unsigned int channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char serial_buf[] =
|
||||
{
|
||||
0x4B, 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, 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
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set channel in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x01] = channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set mode in serial packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0x02] = HUE_PLUS_MODE_FIXED;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for (unsigned int idx = 0; idx < (colors.size() * 3); idx += 3)
|
||||
{
|
||||
int pixel_idx = idx / 3;
|
||||
RGBColor color = colors[pixel_idx];
|
||||
serial_buf[idx + 5] = RGBGetGValue(color);
|
||||
serial_buf[idx + 6] = RGBGetRValue(color);
|
||||
serial_buf[idx + 7] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
serialport->serial_write((char *)serial_buf, HUE_PLUS_PACKET_SIZE);
|
||||
serialport->serial_flush_tx();
|
||||
|
||||
Sleep(10);
|
||||
}
|
||||
|
||||
@@ -22,24 +22,46 @@
|
||||
#define strtok_s strtok_r
|
||||
#endif
|
||||
|
||||
#define HUE_PLUS_BAUD 256000
|
||||
#define HUE_PLUS_PACKET_SIZE 125
|
||||
|
||||
enum
|
||||
{
|
||||
HUE_PLUS_CHANNEL_BOTH = 0x00, /* Both channels */
|
||||
HUE_PLUS_CHANNEL_1 = 0x01, /* Channel 1 */
|
||||
HUE_PLUS_CHANNEL_2 = 0x02, /* Channel 2 */
|
||||
HUE_PLUS_NUM_CHANNELS = 0x02 /* Number of channels */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HUE_PLUS_CHANNEL_1_IDX = 0x00, /* Channel 1 array index */
|
||||
HUE_PLUS_CHANNEL_2_IDX = 0x01, /* Channel 2 array index */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HUE_PLUS_MODE_FIXED = 0x00, /* Fixed colors mode */
|
||||
HUE_PLUS_MODE_FADING = 0x01, /* Fading mode */
|
||||
HUE_PLUS_MODE_SPECTRUM = 0x02, /* Spectrum cycle mode */
|
||||
HUE_PLUS_NUM_MODES /* Number of Hue Plus modes */
|
||||
};
|
||||
|
||||
class HuePlusController
|
||||
{
|
||||
public:
|
||||
HuePlusController();
|
||||
~HuePlusController();
|
||||
|
||||
void Initialize(char* ledstring);
|
||||
char* GetLEDString();
|
||||
void SetLEDs(std::vector<RGBColor> colors);
|
||||
void Initialize(char* port_name);
|
||||
char* GetLEDString();
|
||||
unsigned int GetStripsOnChannel(unsigned int channel);
|
||||
void SetChannelEffect(unsigned int channel, unsigned int mode, std::vector<RGBColor> colors);
|
||||
void SetChannelLEDs(unsigned int channel, std::vector<RGBColor> colors);
|
||||
|
||||
int num_leds;
|
||||
unsigned int channel_leds[HUE_PLUS_NUM_CHANNELS];
|
||||
|
||||
private:
|
||||
int baud_rate;
|
||||
int fans;
|
||||
int channel;
|
||||
const int hueSize = 125;
|
||||
|
||||
char led_string[1024];
|
||||
char port_name[128];
|
||||
serial_port *serialport;
|
||||
|
||||
@@ -1,20 +1,11 @@
|
||||
#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
|
||||
#define NZXT_HUE_PLUS_VID 0x04D8
|
||||
#define NZXT_HUE_PLUS_PID 0x00DF
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -29,61 +20,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());
|
||||
strcat(filename, "\\settings.txt");
|
||||
#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(NZXT_HUE_PLUS_VID, NZXT_HUE_PLUS_PID);
|
||||
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() */
|
||||
} /* DetectHuePlusControllers() */
|
||||
|
||||
@@ -10,13 +10,25 @@
|
||||
#include "HyperXController.h"
|
||||
#include <cstring>
|
||||
|
||||
HyperXController::HyperXController(i2c_smbus_interface* bus, hyperx_dev_id dev)
|
||||
HyperXController::HyperXController(i2c_smbus_interface* bus, hyperx_dev_id dev, unsigned char slots)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
slots_valid = slots;
|
||||
|
||||
strcpy(device_name, "HyperX Predator RGB");
|
||||
led_count = 1;
|
||||
|
||||
led_count = 0;
|
||||
|
||||
for(int i = 0; i < 8; i++)
|
||||
{
|
||||
if((slots_valid & (1 << i)) != 0)
|
||||
{
|
||||
led_count += 5;
|
||||
}
|
||||
}
|
||||
|
||||
mode = HYPERX_MODE_DIRECT;
|
||||
}
|
||||
|
||||
HyperXController::~HyperXController()
|
||||
@@ -24,46 +36,203 @@ HyperXController::~HyperXController()
|
||||
|
||||
}
|
||||
|
||||
char* HyperXController::GetDeviceName()
|
||||
std::string HyperXController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string HyperXController::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 HyperXController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
void HyperXController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
unsigned int HyperXController::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 HyperXController::GetMode()
|
||||
{
|
||||
return(mode);
|
||||
}
|
||||
|
||||
void HyperXController::SetEffectColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_RED, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_GREEN, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_BLUE, blue);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_EFFECT_RED, red );
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_EFFECT_GREEN, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_EFFECT_BLUE, blue );
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_EFFECT_BRIGHTNESS, 0x64 );
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void HyperXController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Loop through all slots and only set those which are |
|
||||
| active. |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int slot = 0; slot < 4; slot++)
|
||||
{
|
||||
if((slots_valid & (1 << slot)) != 0)
|
||||
{
|
||||
unsigned char base = slot_base[slot];
|
||||
unsigned char red_base = base + 0x00;
|
||||
unsigned char green_base = base + 0x01;
|
||||
unsigned char blue_base = base + 0x02;
|
||||
unsigned char bright_base = base + 0x10;
|
||||
|
||||
if(mode == HYPERX_MODE_DIRECT)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE3, HYPERX_MODE3_DIRECT);
|
||||
}
|
||||
|
||||
for(int led = 0; led < 5; led++)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, red_base + (3 * led), red );
|
||||
bus->i2c_smbus_write_byte_data(dev, green_base + (3 * led), green);
|
||||
bus->i2c_smbus_write_byte_data(dev, blue_base + (3 * led), blue );
|
||||
bus->i2c_smbus_write_byte_data(dev, bright_base + (3 * led), 0x64 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void HyperXController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| led_slot - the unmapped slot ID for the given LED |
|
||||
| led - the LED ID within that slot |
|
||||
| slot_id - counts enabled slots |
|
||||
| slot - the mapped slot ID for the given LED |
|
||||
\*-----------------------------------------------------*/
|
||||
int led_slot = led / 5;
|
||||
int slot_id = -1;
|
||||
int slot;
|
||||
|
||||
led -= (led_slot * 5);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Loop through all possible slots and only count those |
|
||||
| which are active. |
|
||||
\*-----------------------------------------------------*/
|
||||
for(slot = 0; slot < 4; slot++)
|
||||
{
|
||||
if((slots_valid & ( 1 << slot)) != 0)
|
||||
{
|
||||
slot_id++;
|
||||
}
|
||||
|
||||
if(slot_id == led_slot)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char base = slot_base[slot];
|
||||
unsigned char red_base = base + 0x00;
|
||||
unsigned char green_base = base + 0x01;
|
||||
unsigned char blue_base = base + 0x02;
|
||||
unsigned char bright_base = base + 0x10;
|
||||
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_RED, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_GREEN, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_BLUE, blue);
|
||||
bus->i2c_smbus_write_byte_data(dev, red_base + (3 * led), red );
|
||||
bus->i2c_smbus_write_byte_data(dev, green_base + (3 * led), green);
|
||||
bus->i2c_smbus_write_byte_data(dev, blue_base + (3 * led), blue );
|
||||
bus->i2c_smbus_write_byte_data(dev, bright_base + (3 * led), 0x64 );
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void HyperXController::SetMode(unsigned char mode)
|
||||
|
||||
void HyperXController::SetLEDColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char base = slot_base[slot];
|
||||
unsigned char red_base = base + 0x00;
|
||||
unsigned char green_base = base + 0x01;
|
||||
unsigned char blue_base = base + 0x02;
|
||||
unsigned char bright_base = base + 0x10;
|
||||
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, red_base + (3 * led), red );
|
||||
bus->i2c_smbus_write_byte_data(dev, green_base + (3 * led), green);
|
||||
bus->i2c_smbus_write_byte_data(dev, blue_base + (3 * led), blue );
|
||||
bus->i2c_smbus_write_byte_data(dev, bright_base + (3 * led), 0x64 );
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void HyperXController::SetMode(unsigned char new_mode)
|
||||
{
|
||||
mode = new_mode;
|
||||
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case HYPERX_MODE_DIRECT:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE3, HYPERX_MODE3_DIRECT);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_STATIC:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_STATIC);
|
||||
break;
|
||||
@@ -99,4 +268,7 @@ void HyperXController::SetMode(unsigned char mode)
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
|
||||
}
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
| Adam Honse (CalcProgrammer1) 6/29/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
@@ -16,13 +17,98 @@ typedef unsigned short hyperx_register;
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_REG_BRIGHTNESS = 0xDD, /* Brightness control register (0-100) */
|
||||
HYPERX_REG_SLOT0_LED0_RED = 0x11, /* R color register for LED 0, Slot 0 */
|
||||
HYPERX_REG_SLOT0_LED0_GREEN = 0x12, /* G color register for LED 0, Slot 0 */
|
||||
HYPERX_REG_SLOT0_LED0_BLUE = 0x13, /* B color register for LED 0, Slot 0 */
|
||||
HYPERX_REG_SLOT0_LED1_RED = 0x14, /* R color register for LED 1, Slot 0 */
|
||||
HYPERX_REG_SLOT0_LED1_GREEN = 0x15, /* G color register for LED 1, Slot 0 */
|
||||
HYPERX_REG_SLOT0_LED1_BLUE = 0x16, /* B color register for LED 1, Slot 0 */
|
||||
HYPERX_REG_SLOT0_LED2_RED = 0x17, /* R color register for LED 2, Slot 0 */
|
||||
HYPERX_REG_SLOT0_LED2_GREEN = 0x18, /* G color register for LED 2, Slot 0 */
|
||||
HYPERX_REG_SLOT0_LED2_BLUE = 0x19, /* B color register for LED 2, Slot 0 */
|
||||
HYPERX_REG_SLOT0_LED3_RED = 0x1A, /* R color register for LED 3, Slot 0 */
|
||||
HYPERX_REG_SLOT0_LED3_GREEN = 0x1B, /* G color register for LED 3, Slot 0 */
|
||||
HYPERX_REG_SLOT0_LED3_BLUE = 0x1C, /* B color register for LED 3, Slot 0 */
|
||||
HYPERX_REG_SLOT0_LED4_RED = 0x1D, /* R color register for LED 4, Slot 0 */
|
||||
HYPERX_REG_SLOT0_LED4_GREEN = 0x1E, /* G color register for LED 4, Slot 0 */
|
||||
HYPERX_REG_SLOT0_LED4_BLUE = 0x1F, /* B color register for LED 4, Slot 0 */
|
||||
HYPERX_REG_SLOT0_LED0_BRIGHTNESS = 0x21, /* Brightness for LED 0, Slot 0 (0-100) */
|
||||
HYPERX_REG_SLOT0_LED1_BRIGHTNESS = 0x24, /* Brightness for LED 1, Slot 0 (0-100) */
|
||||
HYPERX_REG_SLOT0_LED2_BRIGHTNESS = 0x27, /* Brightness for LED 2, Slot 0 (0-100) */
|
||||
HYPERX_REG_SLOT0_LED3_BRIGHTNESS = 0x2A, /* Brightness for LED 3, Slot 0 (0-100) */
|
||||
HYPERX_REG_SLOT0_LED4_BRIGHTNESS = 0x2D, /* Brightness for LED 4, Slot 0 (0-100) */
|
||||
|
||||
HYPERX_REG_SLOT1_LED0_RED = 0x41, /* R color register for LED 0, Slot 1 */
|
||||
HYPERX_REG_SLOT1_LED0_GREEN = 0x42, /* G color register for LED 0, Slot 1 */
|
||||
HYPERX_REG_SLOT1_LED0_BLUE = 0x43, /* B color register for LED 0, Slot 1 */
|
||||
HYPERX_REG_SLOT1_LED1_RED = 0x44, /* R color register for LED 1, Slot 1 */
|
||||
HYPERX_REG_SLOT1_LED1_GREEN = 0x45, /* G color register for LED 1, Slot 1 */
|
||||
HYPERX_REG_SLOT1_LED1_BLUE = 0x46, /* B color register for LED 1, Slot 1 */
|
||||
HYPERX_REG_SLOT1_LED2_RED = 0x47, /* R color register for LED 2, Slot 1 */
|
||||
HYPERX_REG_SLOT1_LED2_GREEN = 0x48, /* G color register for LED 2, Slot 1 */
|
||||
HYPERX_REG_SLOT1_LED2_BLUE = 0x49, /* B color register for LED 2, Slot 1 */
|
||||
HYPERX_REG_SLOT1_LED3_RED = 0x4A, /* R color register for LED 3, Slot 1 */
|
||||
HYPERX_REG_SLOT1_LED3_GREEN = 0x4B, /* G color register for LED 3, Slot 1 */
|
||||
HYPERX_REG_SLOT1_LED3_BLUE = 0x4C, /* B color register for LED 3, Slot 1 */
|
||||
HYPERX_REG_SLOT1_LED4_RED = 0x4D, /* R color register for LED 4, Slot 1 */
|
||||
HYPERX_REG_SLOT1_LED4_GREEN = 0x4E, /* G color register for LED 4, Slot 1 */
|
||||
HYPERX_REG_SLOT1_LED4_BLUE = 0x4F, /* B color register for LED 4, Slot 1 */
|
||||
HYPERX_REG_SLOT1_LED0_BRIGHTNESS = 0x51, /* Brightness for LED 0, Slot 1 (0-100) */
|
||||
HYPERX_REG_SLOT1_LED1_BRIGHTNESS = 0x54, /* Brightness for LED 1, Slot 1 (0-100) */
|
||||
HYPERX_REG_SLOT1_LED2_BRIGHTNESS = 0x57, /* Brightness for LED 2, Slot 1 (0-100) */
|
||||
HYPERX_REG_SLOT1_LED3_BRIGHTNESS = 0x5A, /* Brightness for LED 3, Slot 1 (0-100) */
|
||||
HYPERX_REG_SLOT1_LED4_BRIGHTNESS = 0x5D, /* Brightness for LED 4, Slot 1 (0-100) */
|
||||
|
||||
HYPERX_REG_SLOT2_LED0_RED = 0x71, /* R color register for LED 0, Slot 2 */
|
||||
HYPERX_REG_SLOT2_LED0_GREEN = 0x72, /* G color register for LED 0, Slot 2 */
|
||||
HYPERX_REG_SLOT2_LED0_BLUE = 0x73, /* B color register for LED 0, Slot 2 */
|
||||
HYPERX_REG_SLOT2_LED1_RED = 0x74, /* R color register for LED 1, Slot 2 */
|
||||
HYPERX_REG_SLOT2_LED1_GREEN = 0x75, /* G color register for LED 1, Slot 2 */
|
||||
HYPERX_REG_SLOT2_LED1_BLUE = 0x76, /* B color register for LED 1, Slot 2 */
|
||||
HYPERX_REG_SLOT2_LED2_RED = 0x77, /* R color register for LED 2, Slot 2 */
|
||||
HYPERX_REG_SLOT2_LED2_GREEN = 0x78, /* G color register for LED 2, Slot 2 */
|
||||
HYPERX_REG_SLOT2_LED2_BLUE = 0x79, /* B color register for LED 2, Slot 2 */
|
||||
HYPERX_REG_SLOT2_LED3_RED = 0x7A, /* R color register for LED 3, Slot 2 */
|
||||
HYPERX_REG_SLOT2_LED3_GREEN = 0x7B, /* G color register for LED 3, Slot 2 */
|
||||
HYPERX_REG_SLOT2_LED3_BLUE = 0x7C, /* B color register for LED 3, Slot 2 */
|
||||
HYPERX_REG_SLOT2_LED4_RED = 0x7D, /* R color register for LED 4, Slot 2 */
|
||||
HYPERX_REG_SLOT2_LED4_GREEN = 0x7E, /* G color register for LED 4, Slot 2 */
|
||||
HYPERX_REG_SLOT2_LED4_BLUE = 0x7F, /* B color register for LED 4, Slot 2 */
|
||||
HYPERX_REG_SLOT2_LED0_BRIGHTNESS = 0x81, /* Brightness for LED 0, Slot 2 (0-100) */
|
||||
HYPERX_REG_SLOT2_LED1_BRIGHTNESS = 0x84, /* Brightness for LED 1, Slot 2 (0-100) */
|
||||
HYPERX_REG_SLOT2_LED2_BRIGHTNESS = 0x87, /* Brightness for LED 2, Slot 2 (0-100) */
|
||||
HYPERX_REG_SLOT2_LED3_BRIGHTNESS = 0x8A, /* Brightness for LED 3, Slot 2 (0-100) */
|
||||
HYPERX_REG_SLOT2_LED4_BRIGHTNESS = 0x8D, /* Brightness for LED 4, Slot 2 (0-100) */
|
||||
|
||||
HYPERX_REG_SLOT3_LED0_RED = 0xA1, /* R color register for LED 0, Slot 3 */
|
||||
HYPERX_REG_SLOT3_LED0_GREEN = 0xA2, /* G color register for LED 0, Slot 3 */
|
||||
HYPERX_REG_SLOT3_LED0_BLUE = 0xA3, /* B color register for LED 0, Slot 3 */
|
||||
HYPERX_REG_SLOT3_LED1_RED = 0xA4, /* R color register for LED 1, Slot 3 */
|
||||
HYPERX_REG_SLOT3_LED1_GREEN = 0xA5, /* G color register for LED 1, Slot 3 */
|
||||
HYPERX_REG_SLOT3_LED1_BLUE = 0xA6, /* B color register for LED 1, Slot 3 */
|
||||
HYPERX_REG_SLOT3_LED2_RED = 0xA7, /* R color register for LED 2, Slot 3 */
|
||||
HYPERX_REG_SLOT3_LED2_GREEN = 0xA8, /* G color register for LED 2, Slot 3 */
|
||||
HYPERX_REG_SLOT3_LED2_BLUE = 0xA9, /* B color register for LED 2, Slot 3 */
|
||||
HYPERX_REG_SLOT3_LED3_RED = 0xAA, /* R color register for LED 3, Slot 3 */
|
||||
HYPERX_REG_SLOT3_LED3_GREEN = 0xAB, /* G color register for LED 3, Slot 3 */
|
||||
HYPERX_REG_SLOT3_LED3_BLUE = 0xAC, /* B color register for LED 3, Slot 3 */
|
||||
HYPERX_REG_SLOT3_LED4_RED = 0xAD, /* R color register for LED 4, Slot 3 */
|
||||
HYPERX_REG_SLOT3_LED4_GREEN = 0xAE, /* G color register for LED 4, Slot 3 */
|
||||
HYPERX_REG_SLOT3_LED4_BLUE = 0xAF, /* B color register for LED 4, Slot 3 */
|
||||
HYPERX_REG_SLOT3_LED0_BRIGHTNESS = 0xB1, /* Brightness for LED 0, Slot 3 (0-100) */
|
||||
HYPERX_REG_SLOT3_LED1_BRIGHTNESS = 0xB4, /* Brightness for LED 1, Slot 3 (0-100) */
|
||||
HYPERX_REG_SLOT3_LED2_BRIGHTNESS = 0xB7, /* Brightness for LED 2, Slot 3 (0-100) */
|
||||
HYPERX_REG_SLOT3_LED3_BRIGHTNESS = 0xBA, /* Brightness for LED 3, Slot 3 (0-100) */
|
||||
HYPERX_REG_SLOT3_LED4_BRIGHTNESS = 0xBD, /* Brightness for LED 4, Slot 3 (0-100) */
|
||||
|
||||
HYPERX_REG_EFFECT_BRIGHTNESS = 0xDD, /* Brightness for effects (0-100) */
|
||||
HYPERX_REG_APPLY = 0xE1, /* Apply changes register */
|
||||
HYPERX_REG_MODE1 = 0xE3, /* Mode control register 1 */
|
||||
HYPERX_REG_MODE2 = 0xE4, /* Mode control register 2 */
|
||||
HYPERX_REG_RED = 0xEC, /* Red color register */
|
||||
HYPERX_REG_GREEN = 0xED, /* Green color register */
|
||||
HYPERX_REG_BLUE = 0xEE, /* Blue color register */
|
||||
HYPERX_REG_MODE3 = 0xE5, /* Mode control register 3 */
|
||||
HYPERX_REG_EFFECT_RED = 0xEC, /* Red color register for effects */
|
||||
HYPERX_REG_EFFECT_GREEN = 0xED, /* Green color register for effects */
|
||||
HYPERX_REG_EFFECT_BLUE = 0xEE, /* Blue color register for effects */
|
||||
};
|
||||
|
||||
enum
|
||||
@@ -43,34 +129,54 @@ enum
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_MODE_STATIC = 0, /* Static color mode */
|
||||
HYPERX_MODE_RAINBOW = 1, /* Rainbow wave mode */
|
||||
HYPERX_MODE_COMET = 2, /* Comet (chase) mode */
|
||||
HYPERX_MODE_HEARTBEAT = 3, /* Heartbeat (pulsing) mode */
|
||||
HYPERX_MODE_CYCLE = 4, /* Spectrum cycle mode */
|
||||
HYPERX_MODE_BREATHING = 5, /* Breathing mode */
|
||||
HYPERX_MODE_BOUNCE = 6, /* Bounce mode */
|
||||
HYPERX_MODE_BLINK = 7, /* Blinking mode */
|
||||
HYPERX_MODE3_DIRECT = 0x21, /* Mode 3 direct control */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_MODE_DIRECT = 0, /* Direct control mode */
|
||||
HYPERX_MODE_STATIC = 1, /* Static color mode */
|
||||
HYPERX_MODE_RAINBOW = 2, /* Rainbow wave mode */
|
||||
HYPERX_MODE_COMET = 3, /* Comet (chase) mode */
|
||||
HYPERX_MODE_HEARTBEAT = 4, /* Heartbeat (pulsing) mode */
|
||||
HYPERX_MODE_CYCLE = 5, /* Spectrum cycle mode */
|
||||
HYPERX_MODE_BREATHING = 6, /* Breathing mode */
|
||||
HYPERX_MODE_BOUNCE = 7, /* Bounce mode */
|
||||
HYPERX_MODE_BLINK = 8, /* Blinking mode */
|
||||
HYPERX_NUMBER_MODES /* Number of HyperX modes */
|
||||
};
|
||||
|
||||
static const unsigned char slot_base[4] =
|
||||
{
|
||||
HYPERX_REG_SLOT0_LED0_RED, /* SPD 0x50 maps to slot 0 */
|
||||
HYPERX_REG_SLOT1_LED0_RED, /* SPD 0x51 maps to slot 1 */
|
||||
HYPERX_REG_SLOT2_LED0_RED, /* SPD 0x52 maps to slot 2 */
|
||||
HYPERX_REG_SLOT3_LED0_RED /* SPD 0x53 maps to slot 3 */
|
||||
};
|
||||
|
||||
class HyperXController
|
||||
{
|
||||
public:
|
||||
HyperXController(i2c_smbus_interface* bus, hyperx_dev_id dev);
|
||||
HyperXController(i2c_smbus_interface* bus, hyperx_dev_id dev, unsigned char slots);
|
||||
~HyperXController();
|
||||
|
||||
char* GetDeviceName();
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
unsigned int GetLEDCount();
|
||||
void SetMode(unsigned char mode);
|
||||
unsigned int GetSlotCount();
|
||||
unsigned int GetMode();
|
||||
void SetMode(unsigned char new_mode);
|
||||
|
||||
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);
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
unsigned int led_count;
|
||||
unsigned char slots_valid;
|
||||
i2c_smbus_interface* bus;
|
||||
hyperx_dev_id dev;
|
||||
};
|
||||
unsigned int mode;
|
||||
};
|
||||
|
||||
@@ -6,6 +6,17 @@
|
||||
#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
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForHyperXController *
|
||||
@@ -58,13 +69,36 @@ void DetectHyperXControllers(std::vector<i2c_smbus_interface*> &busses, std::vec
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
unsigned char slots_valid = 0x00;
|
||||
|
||||
// Check for HyperX controller at 0x27
|
||||
if (TestForHyperXController(busses[bus], 0x27))
|
||||
{
|
||||
new_hyperx = new HyperXController(busses[bus], 0x27);
|
||||
new_controller = new RGBController_HyperX(new_hyperx);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
busses[bus]->i2c_smbus_write_byte_data(0x37, 0x00, 0xFF);
|
||||
|
||||
Sleep(1);
|
||||
|
||||
for(int slot_addr = 0x50; slot_addr <= 0x57; slot_addr++)
|
||||
{
|
||||
// Test for HyperX SPD at slot_addr
|
||||
// This test was copied from NGENUITY software
|
||||
// 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))
|
||||
{
|
||||
slots_valid |= (1 << (slot_addr - 0x50));
|
||||
}
|
||||
|
||||
Sleep(1);
|
||||
}
|
||||
|
||||
if(slots_valid != 0)
|
||||
{
|
||||
new_hyperx = new HyperXController(busses[bus], 0x27, slots_valid);
|
||||
new_controller = new RGBController_HyperX(new_hyperx);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectHyperXControllers() */
|
||||
} /* DetectHyperXControllers() */
|
||||
|
||||
@@ -0,0 +1,224 @@
|
||||
/*-----------------------------------------*\
|
||||
| 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)
|
||||
{
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
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);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void PatriotViperController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
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);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void PatriotViperController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
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);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void PatriotViperController::SetLEDEffectColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
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);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void PatriotViperController::SetLEDColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
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);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void PatriotViperController::SetLEDEffectColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
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);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void PatriotViperController::SetMode(unsigned char new_mode)
|
||||
{
|
||||
direct = false;
|
||||
mode = new_mode;
|
||||
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
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);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void PatriotViperController::SetDirect()
|
||||
{
|
||||
direct = true;
|
||||
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
|
||||
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
|
||||
ViperRegisterWrite(VIPER_REG_APPLY, 0x01, 0x00, 0x00);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
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() */
|
||||
@@ -0,0 +1,120 @@
|
||||
/*-----------------------------------------*\
|
||||
| PolychromeController.cpp |
|
||||
| |
|
||||
| Driver for for ASRock ASR LED and |
|
||||
| Polychrome RGB lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/14/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "PolychromeController.h"
|
||||
#include <cstring>
|
||||
|
||||
PolychromeController::PolychromeController(i2c_smbus_interface* bus, polychrome_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
switch (GetFirmwareVersion())
|
||||
{
|
||||
case FIRMWARE_VER_1_PT_10:
|
||||
led_count = 1;
|
||||
asr_led = true;
|
||||
strcpy(device_name, "ASRock ASR LED FW 1.10");
|
||||
break;
|
||||
|
||||
case FIRMWARE_VER_2_PT_00:
|
||||
led_count = 1;
|
||||
asr_led = false;
|
||||
strcpy(device_name, "ASRock Polychrome FW 2.00");
|
||||
break;
|
||||
|
||||
case FIRMWARE_VER_3_PT_00:
|
||||
led_count = 1;
|
||||
asr_led = false;
|
||||
strcpy(device_name, "ASRock Polychrome FW 3.00");
|
||||
break;
|
||||
|
||||
default:
|
||||
led_count = 0;
|
||||
strcpy(device_name, "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PolychromeController::~PolychromeController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
char* PolychromeController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
unsigned short PolychromeController::GetFirmwareVersion()
|
||||
{
|
||||
// The firmware register holds two bytes, so the first read should return 2
|
||||
// If not, report invalid firmware revision FFFF
|
||||
if (bus->i2c_smbus_read_byte_data(dev, POLYCHROME_REG_FIRMWARE_VER) == 0x02)
|
||||
{
|
||||
unsigned char major = bus->i2c_smbus_read_byte(dev);
|
||||
unsigned char minor = bus->i2c_smbus_read_byte(dev);
|
||||
|
||||
return((major << 8) | minor);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(0xFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char colors[3] = { red, green, blue };
|
||||
|
||||
bus->i2c_smbus_write_block_data(dev, POLYCHROME_REG_COLOR, 3, colors);
|
||||
}
|
||||
}
|
||||
|
||||
void PolychromeController::SetLEDColor(unsigned int /*led*/, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
if (asr_led)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char colors[3] = { red, green, blue };
|
||||
|
||||
bus->i2c_smbus_write_block_data(dev, POLYCHROME_REG_COLOR, 3, colors);
|
||||
}
|
||||
}
|
||||
|
||||
void PolychromeController::SetMode(unsigned char mode)
|
||||
{
|
||||
if (asr_led)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, POLYCHROME_REG_MODE, mode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*-----------------------------------------*\
|
||||
| PolychromeController.h |
|
||||
| |
|
||||
| Definitions and types for ASRock |
|
||||
| ASR LED and Polychrome RGB lighting |
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/13/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char polychrome_dev_id;
|
||||
|
||||
enum
|
||||
{
|
||||
FIRMWARE_VER_1_PT_10 = 0x010A, /* Firmware nu51_1.10 */
|
||||
FIRMWARE_VER_2_PT_00 = 0x0200, /* Firmware nu51_2.00 */
|
||||
FIRMWARE_VER_3_PT_00 = 0x0300, /* Firmware nu51_3.00 */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ASRLED_REG_FIRMWARE_VER = 0x00, /* Firmware version Major.Minor */
|
||||
ASRLED_REG_MODE = 0x30, /* Mode selection register */
|
||||
};
|
||||
|
||||
#define ASRLED_NUM_MODES 8 /* Number of ASR LED modes */
|
||||
|
||||
enum
|
||||
{
|
||||
ASRLED_MODE_OFF = 0x10, /* OFF mode */
|
||||
ASRLED_MODE_STATIC = 0x11, /* Static color mode */
|
||||
ASRLED_MODE_BREATHING = 0x12, /* Breathing effect mode */
|
||||
ASRLED_MODE_FLASHING = 0x13, /* Flashing effect mode */
|
||||
ASRLED_MODE_SPECTRUM_CYCLE = 0x14, /* Spectrum Cycle effect mode */
|
||||
ASRLED_MODE_RANDOM = 0x15, /* Random effect mode */
|
||||
ASRLED_MODE_MUSIC = 0x17, /* Music effect mode */
|
||||
ASRLED_MODE_WAVE = 0x18, /* Wave effect mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POLYCHROME_REG_FIRMWARE_VER = 0x00, /* Firmware version Major.Minor */
|
||||
POLYCHROME_REG_MODE = 0x30, /* Mode selection register */
|
||||
POLYCHROME_REG_COLOR = 0x34, /* Color register: Red, Green, Blue */
|
||||
};
|
||||
|
||||
#define POLYCHROME_NUM_MODES 14 /* Number of Polychrome modes */
|
||||
|
||||
enum
|
||||
{
|
||||
POLYCHROME_MODE_OFF = 0x10, /* OFF mode */
|
||||
POLYCHROME_MODE_STATIC = 0x11, /* Static color mode */
|
||||
POLYCHROME_MODE_BREATHING = 0x12, /* Breating effect mode */
|
||||
POLYCHROME_MODE_FLASHING = 0x13, /* Flashing effect mode */
|
||||
POLYCHROME_MODE_SPECTRUM_CYCLE = 0x14, /* Spectrum Cycle effect mode */
|
||||
POLYCHROME_MODE_RANDOM = 0x15, /* Random effect mode */
|
||||
POLYCHROME_MODE_WAVE = 0x17, /* Wave effect mode */
|
||||
POLYCHROME_MODE_SPRING = 0x18, /* Spring effect mode */
|
||||
POLYCHROME_MODE_STACK = 0x19, /* Stack effect mode */
|
||||
POLYCHROME_MODE_CRAM = 0x1A, /* Cram effect mode */
|
||||
POLYCHROME_MODE_SCAN = 0x1B, /* Scan effect mode */
|
||||
POLYCHROME_MODE_NEON = 0x1C, /* Neon effect mode */
|
||||
POLYCHROME_MODE_WATER = 0x1D, /* Water effect mode */
|
||||
POLYCHROME_MODE_RAINBOW = 0x1E, /* Rainbow effect mode */
|
||||
};
|
||||
|
||||
class PolychromeController
|
||||
{
|
||||
public:
|
||||
PolychromeController(i2c_smbus_interface* bus, polychrome_dev_id dev);
|
||||
~PolychromeController();
|
||||
|
||||
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);
|
||||
unsigned short GetFirmwareVersion();
|
||||
|
||||
private:
|
||||
bool asr_led;
|
||||
char device_name[32];
|
||||
unsigned int led_count;
|
||||
i2c_smbus_interface* bus;
|
||||
polychrome_dev_id dev;
|
||||
|
||||
};
|
||||
@@ -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() */
|
||||
@@ -0,0 +1,199 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBFusionController.cpp |
|
||||
| |
|
||||
| Driver for Gigabyte Aorus RGB Fusion |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/10/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBFusionController.h"
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
RGBFusionController::RGBFusionController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
// Set Device name
|
||||
strcpy(device_name, "Gigabyte Motherboard");
|
||||
|
||||
// Set LED count
|
||||
led_count = 2;
|
||||
|
||||
// Enable control
|
||||
switch_bank(0);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x02, 0x09);
|
||||
}
|
||||
|
||||
RGBFusionController::~RGBFusionController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string RGBFusionController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string RGBFusionController::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 RGBFusionController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
unsigned char RGBFusionController::GetMode()
|
||||
{
|
||||
switch_bank(0);
|
||||
return(get_mode_ch_0());
|
||||
}
|
||||
|
||||
void RGBFusionController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char mode_ch_0;
|
||||
unsigned char mode_ch_1;
|
||||
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
switch_bank(1);
|
||||
set_color_ch_0(red, green, blue);
|
||||
set_color_ch_1(red, green, blue);
|
||||
|
||||
switch_bank(0);
|
||||
mode_ch_0 = get_mode_ch_0();
|
||||
mode_ch_1 = get_mode_ch_1();
|
||||
set_mode_ch_0(mode_ch_0);
|
||||
set_mode_ch_1(mode_ch_1);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void RGBFusionController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char mode;
|
||||
|
||||
switch (led)
|
||||
{
|
||||
case 0:
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
switch_bank(1);
|
||||
set_color_ch_0(red, green, blue);
|
||||
|
||||
switch_bank(0);
|
||||
mode = get_mode_ch_0();
|
||||
set_mode_ch_0(mode);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
switch_bank(1);
|
||||
set_color_ch_1(red, green, blue);
|
||||
|
||||
switch_bank(0);
|
||||
mode = get_mode_ch_1();
|
||||
set_mode_ch_1(mode);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RGBFusionController::SetMode(unsigned char mode)
|
||||
{
|
||||
//Lock SMBus interface
|
||||
bus->i2c_smbus_wait_and_lock();
|
||||
|
||||
switch_bank(0);
|
||||
set_mode_ch_0(mode);
|
||||
set_mode_ch_1(mode);
|
||||
|
||||
//Unlock SMBus interface
|
||||
bus->i2c_smbus_unlock();
|
||||
}
|
||||
|
||||
void RGBFusionController::dump()
|
||||
{
|
||||
int i, j;
|
||||
|
||||
int start = 0x00;
|
||||
|
||||
FILE* file = freopen("rgb_fusion_dump.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 < 0xFF; i += 16)
|
||||
{
|
||||
printf("%04x: ", i + start);
|
||||
|
||||
for (j = 0; j < 16; j++)
|
||||
{
|
||||
printf("%02x ", bus->i2c_smbus_read_byte_data(dev, (start + i + j)));
|
||||
}
|
||||
|
||||
printf("\r\n");
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
unsigned char RGBFusionController::get_mode_ch_0()
|
||||
{
|
||||
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_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_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_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_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_0_REG_CH_1_MODE, mode + RGB_FUSION_WRITE_MODE_OFST);
|
||||
}
|
||||
|
||||
void RGBFusionController::switch_bank(unsigned char bank)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_SWITCH_REG, bank);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBFusionController.h |
|
||||
| |
|
||||
| Definitions and types for Gigabyte Aorus |
|
||||
| RGB Fusion lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/10/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char rgb_fusion_dev_id;
|
||||
|
||||
enum
|
||||
{
|
||||
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 */
|
||||
};
|
||||
|
||||
#define RGB_FUSION_NUMBER_MODES 3 /* Number of RGB Fusion modes */
|
||||
#define RGB_FUSION_WRITE_MODE_OFST 0x10 /* offset to add when writing mode */
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_MODE_STATIC = 0x00, /* Static color mode */
|
||||
RGB_FUSION_MODE_BREATHING = 0x01, /* Breathing effect mode */
|
||||
RGB_FUSION_MODE_FLASHING = 0x02, /* Flashing effect mode */
|
||||
};
|
||||
|
||||
class RGBFusionController
|
||||
{
|
||||
public:
|
||||
RGBFusionController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev);
|
||||
~RGBFusionController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
unsigned int GetLEDCount();
|
||||
unsigned char 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);
|
||||
|
||||
private:
|
||||
void dump();
|
||||
|
||||
unsigned char get_mode_ch_0();
|
||||
unsigned char get_mode_ch_1();
|
||||
|
||||
void set_color_ch_0(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void set_color_ch_1(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void set_mode_ch_0(unsigned char mode);
|
||||
void set_mode_ch_1(unsigned char mode);
|
||||
void switch_bank(unsigned char bank);
|
||||
|
||||
char device_name[32];
|
||||
unsigned int led_count;
|
||||
i2c_smbus_interface* bus;
|
||||
rgb_fusion_dev_id dev;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,67 @@
|
||||
#include "RGBFusionController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_RGBFusion.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForRGBFusionController *
|
||||
* *
|
||||
* Tests the given address to see if an RGB Fusion controller exists there. First *
|
||||
* does a quick write to test for a response *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForRGBFusionController(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;
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0xF2);
|
||||
|
||||
if (res != 0xC4)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForRGBFusionController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectRGBFusionControllers *
|
||||
* *
|
||||
* Detect RGB Fusion controllers on the enumerated I2C busses at address 0x28. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where RGB Fusion device is connected *
|
||||
* dev - I2C address of RGB Fusion device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectRGBFusionControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
RGBFusionController* new_rgb_fusion;
|
||||
RGBController_RGBFusion* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for RGB Fusion controller at 0x28
|
||||
if (TestForRGBFusionController(busses[bus], 0x28))
|
||||
{
|
||||
new_rgb_fusion = new RGBFusionController(busses[bus], 0x28);
|
||||
new_controller = new RGBController_RGBFusion(new_rgb_fusion);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectRGBFusionControllers() */
|
||||
@@ -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,79 +0,0 @@
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = OpenAuraSDK.bin
|
||||
TEMPLATE = app
|
||||
|
||||
INCLUDEPATH += \
|
||||
dependencies/libe131/src/ \
|
||||
i2c_smbus/ \
|
||||
net_port/ \
|
||||
serial_port/ \
|
||||
Controllers/AuraController/ \
|
||||
Controllers/CorsairController/ \
|
||||
Controllers/CorsairProController/ \
|
||||
Controllers/HuePlusController/ \
|
||||
Controllers/HyperXController/ \
|
||||
Controllers/LEDStripController/ \
|
||||
RGBController/ \
|
||||
qt/
|
||||
|
||||
SOURCES += \
|
||||
dependencies/libe131/src/e131.c \
|
||||
main.cpp \
|
||||
OpenAuraSDK.cpp \
|
||||
qt/OpenAuraSDKQtDialog.cpp \
|
||||
i2c_smbus/i2c_smbus.cpp \
|
||||
i2c_smbus/i2c_smbus_linux.cpp \
|
||||
net_port/net_port.cpp \
|
||||
serial_port/serial_port.cpp \
|
||||
Controllers/AuraController/AuraController.cpp \
|
||||
Controllers/AuraController/AuraControllerDetect.cpp \
|
||||
Controllers/CorsairController/CorsairController.cpp \
|
||||
Controllers/CorsairController/CorsairControllerDetect.cpp \
|
||||
Controllers/CorsairProController/CorsairProController.cpp \
|
||||
Controllers/CorsairProController/CorsairProControllerDetect.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 \
|
||||
RGBController/OpenRazerDetect.cpp \
|
||||
RGBController/E131ControllerDetect.cpp \
|
||||
RGBController/RGBController_Aura.cpp \
|
||||
RGBController/RGBController_Corsair.cpp \
|
||||
RGBController/RGBController_CorsairPro.cpp \
|
||||
RGBController/RGBController_E131.cpp \
|
||||
RGBController/RGBController_HuePlus.cpp \
|
||||
RGBController/RGBController_HyperX.cpp \
|
||||
RGBController/RGBController_LEDStrip.cpp \
|
||||
RGBController/RGBController_OpenRazer.cpp
|
||||
|
||||
HEADERS += \
|
||||
qt/OpenAuraSDKQtDialog.h \
|
||||
i2c_smbus/i2c_smbus.h \
|
||||
i2c_smbus/i2c_smbus_linux.h \
|
||||
net_port/net_port.h \
|
||||
serial_port/serial_port.h \
|
||||
Controllers/AuraController/AuraController.h \
|
||||
Controllers/CorsairController/CorsairController.h \
|
||||
Controllers/CorsairProController/CorsairProController.h \
|
||||
Controllers/HuePlusController/HuePlusController.h \
|
||||
Controllers/HyperXController/HyperXController.h \
|
||||
Controllers/LEDStripController/LEDStripController.h \
|
||||
RGBController/RGBController.h \
|
||||
RGBController/RGBController_Aura.h \
|
||||
RGBController/RGBController_Corsair.h \
|
||||
RGBController/RGBController_CorsairPro.h \
|
||||
RGBController/RGBController_E131.h \
|
||||
RGBController/RGBController_HuePlus.h \
|
||||
RGBController/RGBController_HyperX.h \
|
||||
RGBController/RGBController_OpenRazer.h
|
||||
|
||||
RESOURCES += \
|
||||
qt/resources.qrc
|
||||
|
||||
FORMS += \
|
||||
qt/openaurasdk.ui
|
||||
@@ -1,31 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.28803.452
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenAuraSDK", "OpenAuraSDK.vcxproj", "{6D22BFF3-C1DF-407A-8816-05D63919A991}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Debug|x64.Build.0 = Debug|x64
|
||||
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Debug|x86.Build.0 = Debug|Win32
|
||||
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Release|x64.ActiveCfg = Release|x64
|
||||
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Release|x64.Build.0 = Release|x64
|
||||
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Release|x86.ActiveCfg = Release|Win32
|
||||
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {A2BB3E13-D506-413D-900E-F2B1323B3BB3}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,249 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{6D22BFF3-C1DF-407A-8816-05D63919A991}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>OpenAuraSDK</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetExt>.exe</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetExt>.exe</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetExt>.exe</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetExt>.exe</TargetExt>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_AFXDLL;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32_LEAN_AND_MEAN</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>.\dependencies\inpout32_1501\Win32;.\dependencies\razer-chroma-2.9.0\inc;.\Controllers\AuraController;.\Controllers\CorsairController;.\Controllers\CorsairProController;.\Controllers\HuePlusController;.\Controllers\HyperXController;.\Controllers\LEDStripController;.\RGBController;.\i2c_smbus;.\net_port;.\serial_port;.\vc;.\wmi;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<PrecompiledHeaderFile />
|
||||
<PrecompiledHeaderOutputFile />
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>.\dependencies\inpout32_1501\Win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_AFXDLL;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32_LEAN_AND_MEAN</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeaderFile />
|
||||
<PrecompiledHeaderOutputFile />
|
||||
<AdditionalIncludeDirectories>.\dependencies\inpout32_1501\Win32;.\dependencies\razer-chroma-2.9.0\inc;.\Controllers\AuraController;.\Controllers\CorsairController;.\Controllers\CorsairProController;.\Controllers\HuePlusController;.\Controllers\HyperXController;.\Controllers\LEDStripController;.\RGBController;.\i2c_smbus;.\net_port;.\serial_port;.\vc;.\wmi;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>.\dependencies\inpout32_1501\Win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_AFXDLL;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32_LEAN_AND_MEAN</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>.\dependencies\inpout32_1501\Win32;.\dependencies\razer-chroma-2.9.0\inc;.\Controllers\AuraController;.\Controllers\CorsairController;.\Controllers\CorsairProController;.\Controllers\HuePlusController;.\Controllers\HyperXController;.\Controllers\LEDStripController;.\RGBController;.\i2c_smbus;.\net_port;.\serial_port;.\vc;.\wmi;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<PrecompiledHeaderFile />
|
||||
<PrecompiledHeaderOutputFile />
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>.\dependencies\inpout32_1501\Win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_AFXDLL;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32_LEAN_AND_MEAN</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeaderFile />
|
||||
<PrecompiledHeaderOutputFile />
|
||||
<AdditionalIncludeDirectories>.\dependencies\inpout32_1501\Win32;.\dependencies\razer-chroma-2.9.0\inc;.\Controllers\AuraController;.\Controllers\CorsairController;.\Controllers\CorsairProController;.\Controllers\HuePlusController;.\Controllers\HyperXController;.\Controllers\LEDStripController;.\RGBController;.\i2c_smbus;.\net_port;.\serial_port;.\vc;.\wmi;.\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>.\dependencies\inpout32_1501\Win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Controllers\AuraController\AuraController.cpp" />
|
||||
<ClCompile Include="Controllers\AuraController\AuraControllerDetect.cpp" />
|
||||
<ClCompile Include="Controllers\CorsairController\CorsairController.cpp" />
|
||||
<ClCompile Include="Controllers\CorsairController\CorsairControllerDetect.cpp" />
|
||||
<ClCompile Include="Controllers\CorsairProController\CorsairProController.cpp" />
|
||||
<ClCompile Include="Controllers\CorsairProController\CorsairProControllerDetect.cpp" />
|
||||
<ClCompile Include="Controllers\HuePlusController\HuePlusController.cpp" />
|
||||
<ClCompile Include="Controllers\HuePlusController\HuePlusControllerDetect.cpp" />
|
||||
<ClCompile Include="Controllers\HyperXController\HyperXController.cpp" />
|
||||
<ClCompile Include="Controllers\HyperXController\HyperXControllerDetect.cpp" />
|
||||
<ClCompile Include="Controllers\LEDStripController\LEDStripController.cpp" />
|
||||
<ClCompile Include="Controllers\LEDStripController\LEDStripControllerDetect.cpp" />
|
||||
<ClCompile Include="i2c_smbus\i2c_smbus.cpp" />
|
||||
<ClCompile Include="i2c_smbus\i2c_smbus_i801.cpp" />
|
||||
<ClCompile Include="i2c_smbus\i2c_smbus_nct6775.cpp" />
|
||||
<ClCompile Include="i2c_smbus\i2c_smbus_piix4.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="net_port\net_port.cpp" />
|
||||
<ClCompile Include="OpenAuraSDK.cpp" />
|
||||
<ClCompile Include="RGBController\RazerChromaSDKDetect.cpp" />
|
||||
<ClCompile Include="RGBController\RGBController_AorusGPU.cpp" />
|
||||
<ClCompile Include="RGBController\RGBController_Aura.cpp" />
|
||||
<ClCompile Include="RGBController\RGBController_Corsair.cpp" />
|
||||
<ClCompile Include="RGBController\RGBController_CorsairPro.cpp" />
|
||||
<ClCompile Include="RGBController\RGBController_HuePlus.cpp" />
|
||||
<ClCompile Include="RGBController\RGBController_HyperX.cpp" />
|
||||
<ClCompile Include="RGBController\RGBController_LEDStrip.cpp" />
|
||||
<ClCompile Include="RGBController\RGBController_RazerChromaSDK.cpp" />
|
||||
<ClCompile Include="serial_port\serial_port.cpp" />
|
||||
<ClCompile Include="vc\I2CDetectDialog.cpp" />
|
||||
<ClCompile Include="vc\OpenAuraSDKDialog.cpp" />
|
||||
<ClCompile Include="wmi\wmi.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="vc\Resource.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Controllers\AuraController\AuraController.h" />
|
||||
<ClInclude Include="Controllers\CorsairController\CorsairController.h" />
|
||||
<ClInclude Include="Controllers\CorsairProController\CorsairProController.h" />
|
||||
<ClInclude Include="Controllers\HuePlusController\HuePlusController.h" />
|
||||
<ClInclude Include="Controllers\HyperXController\HyperXController.h" />
|
||||
<ClInclude Include="Controllers\LEDStripController\LEDStripController.h" />
|
||||
<ClInclude Include="i2c_smbus\i2c_smbus.h" />
|
||||
<ClInclude Include="i2c_smbus\i2c_smbus_i801.h" />
|
||||
<ClInclude Include="i2c_smbus\i2c_smbus_nct6775.h" />
|
||||
<ClInclude Include="i2c_smbus\i2c_smbus_piix4.h" />
|
||||
<ClInclude Include="net_port\net_port.h" />
|
||||
<ClInclude Include="OpenAuraSDK.h" />
|
||||
<ClInclude Include="RGBController\RGBController.h" />
|
||||
<ClInclude Include="RGBController\RGBController_AorusGPU.h" />
|
||||
<ClInclude Include="RGBController\RGBController_Aura.h" />
|
||||
<ClInclude Include="RGBController\RGBController_Corsair.h" />
|
||||
<ClInclude Include="RGBController\RGBController_CorsairPro.h" />
|
||||
<ClInclude Include="RGBController\RGBController_HuePlus.h" />
|
||||
<ClInclude Include="RGBController\RGBController_HyperX.h" />
|
||||
<ClInclude Include="RGBController\RGBController_LEDStrip.h" />
|
||||
<ClInclude Include="RGBController\RGBController_RazerChromaSDK.h" />
|
||||
<ClInclude Include="serial_port\serial_port.h" />
|
||||
<ClInclude Include="vc\I2CDetectDialog.h" />
|
||||
<ClInclude Include="vc\OpenAuraSDKDialog.h" />
|
||||
<ClInclude Include="vc\resource.h" />
|
||||
<ClInclude Include="wmi\wmi.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -1,221 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Controllers">
|
||||
<UniqueIdentifier>{192d5e34-581a-40c4-bc69-f4b61632fd81}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Application">
|
||||
<UniqueIdentifier>{d64d74dd-f822-4617-a88c-00dca03f70d9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\RGBController">
|
||||
<UniqueIdentifier>{ee7c811d-9bd1-43a8-9d42-62801332ab30}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\i2c_smbus">
|
||||
<UniqueIdentifier>{fa28cfae-d8a7-4194-8f25-e35827dd0145}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Controllers">
|
||||
<UniqueIdentifier>{a50a158e-81a1-45c3-a300-67e869afcc2f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\i2c_smbus">
|
||||
<UniqueIdentifier>{8eae9b90-7558-4b0b-9f03-d3a651cb6624}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\RGBController">
|
||||
<UniqueIdentifier>{02dd848e-6106-4f74-a58c-4a7547498ac3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="OpenAuraSDK.cpp">
|
||||
<Filter>Source Files\Application</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files\Application</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wmi\wmi.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="serial_port\serial_port.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Controllers\AuraController\AuraController.cpp">
|
||||
<Filter>Source Files\Controllers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Controllers\AuraController\AuraControllerDetect.cpp">
|
||||
<Filter>Source Files\Controllers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Controllers\CorsairController\CorsairController.cpp">
|
||||
<Filter>Source Files\Controllers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Controllers\CorsairController\CorsairControllerDetect.cpp">
|
||||
<Filter>Source Files\Controllers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Controllers\CorsairProController\CorsairProController.cpp">
|
||||
<Filter>Source Files\Controllers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Controllers\CorsairProController\CorsairProControllerDetect.cpp">
|
||||
<Filter>Source Files\Controllers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Controllers\HyperXController\HyperXController.cpp">
|
||||
<Filter>Source Files\Controllers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Controllers\HyperXController\HyperXControllerDetect.cpp">
|
||||
<Filter>Source Files\Controllers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="i2c_smbus\i2c_smbus.cpp">
|
||||
<Filter>Source Files\i2c_smbus</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="i2c_smbus\i2c_smbus_i801.cpp">
|
||||
<Filter>Source Files\i2c_smbus</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="i2c_smbus\i2c_smbus_nct6775.cpp">
|
||||
<Filter>Source Files\i2c_smbus</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="i2c_smbus\i2c_smbus_piix4.cpp">
|
||||
<Filter>Source Files\i2c_smbus</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RGBController\RGBController_AorusGPU.cpp">
|
||||
<Filter>Source Files\RGBController</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RGBController\RGBController_Aura.cpp">
|
||||
<Filter>Source Files\RGBController</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RGBController\RGBController_Corsair.cpp">
|
||||
<Filter>Source Files\RGBController</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RGBController\RGBController_CorsairPro.cpp">
|
||||
<Filter>Source Files\RGBController</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RGBController\RGBController_HyperX.cpp">
|
||||
<Filter>Source Files\RGBController</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RGBController\RGBController_LEDStrip.cpp">
|
||||
<Filter>Source Files\RGBController</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="vc\I2CDetectDialog.cpp">
|
||||
<Filter>Source Files\Application</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Controllers\LEDStripController\LEDStripController.cpp">
|
||||
<Filter>Source Files\Controllers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Controllers\LEDStripController\LEDStripControllerDetect.cpp">
|
||||
<Filter>Source Files\Controllers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="vc\OpenAuraSDKDialog.cpp">
|
||||
<Filter>Source Files\Application</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Controllers\HuePlusController\HuePlusController.cpp">
|
||||
<Filter>Source Files\Controllers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Controllers\HuePlusController\HuePlusControllerDetect.cpp">
|
||||
<Filter>Source Files\Controllers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="net_port\net_port.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RGBController\RGBController_HuePlus.cpp">
|
||||
<Filter>Source Files\RGBController</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RGBController\RGBController_RazerChromaSDK.cpp">
|
||||
<Filter>Source Files\RGBController</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RGBController\RazerChromaSDKDetect.cpp">
|
||||
<Filter>Source Files\RGBController</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="vc\Resource.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="wmi\wmi.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="serial_port\serial_port.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Controllers\AuraController\AuraController.h">
|
||||
<Filter>Header Files\Controllers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Controllers\CorsairController\CorsairController.h">
|
||||
<Filter>Header Files\Controllers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Controllers\CorsairProController\CorsairProController.h">
|
||||
<Filter>Header Files\Controllers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Controllers\HyperXController\HyperXController.h">
|
||||
<Filter>Header Files\Controllers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Controllers\LEDStripController\LEDStripController.h">
|
||||
<Filter>Header Files\Controllers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RGBController\RGBController.h">
|
||||
<Filter>Header Files\RGBController</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RGBController\RGBController_AorusGPU.h">
|
||||
<Filter>Header Files\RGBController</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RGBController\RGBController_Aura.h">
|
||||
<Filter>Header Files\RGBController</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RGBController\RGBController_Corsair.h">
|
||||
<Filter>Header Files\RGBController</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RGBController\RGBController_CorsairPro.h">
|
||||
<Filter>Header Files\RGBController</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RGBController\RGBController_HyperX.h">
|
||||
<Filter>Header Files\RGBController</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RGBController\RGBController_LEDStrip.h">
|
||||
<Filter>Header Files\RGBController</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="i2c_smbus\i2c_smbus.h">
|
||||
<Filter>Header Files\i2c_smbus</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="i2c_smbus\i2c_smbus_i801.h">
|
||||
<Filter>Header Files\i2c_smbus</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="i2c_smbus\i2c_smbus_nct6775.h">
|
||||
<Filter>Header Files\i2c_smbus</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="i2c_smbus\i2c_smbus_piix4.h">
|
||||
<Filter>Header Files\i2c_smbus</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="vc\I2CDetectDialog.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="OpenAuraSDK.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="vc\OpenAuraSDKDialog.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="vc\resource.h">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Controllers\HuePlusController\HuePlusController.h">
|
||||
<Filter>Header Files\Controllers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="net_port\net_port.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RGBController\RGBController_HuePlus.h">
|
||||
<Filter>Header Files\RGBController</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RGBController\RGBController_RazerChromaSDK.h">
|
||||
<Filter>Header Files\RGBController</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+28
-127
@@ -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>
|
||||
@@ -16,7 +14,6 @@
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <tchar.h>
|
||||
#include <regex>
|
||||
#include "i2c_smbus_piix4.h"
|
||||
#include "i2c_smbus_i801.h"
|
||||
@@ -320,126 +317,21 @@ void DetectI2CBusses()
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectI2C *
|
||||
* *
|
||||
* Prints a list of all detected I2C addresses on the given bus *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface to scan *
|
||||
* mode - one of AUTO, QUICK, READ, FUNC - method of access *
|
||||
* *
|
||||
* Code adapted from i2cdetect.c from i2c-tools Linux package *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
#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)
|
||||
{
|
||||
int i, j;
|
||||
int res;
|
||||
int slave_addr;
|
||||
char line[128];
|
||||
std::string text;
|
||||
|
||||
sprintf(line, " 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n");
|
||||
text.append(line);
|
||||
|
||||
for (i = 0; i < 128; i += 16)
|
||||
{
|
||||
sprintf(line, "%02x: ", i);
|
||||
text.append(line);
|
||||
|
||||
for (j = 0; j < 16; j++)
|
||||
{
|
||||
/* Set slave address */
|
||||
slave_addr = i + j;
|
||||
|
||||
/* Probe this address */
|
||||
switch (mode)
|
||||
{
|
||||
case MODE_QUICK:
|
||||
res = bus->i2c_smbus_write_quick(slave_addr, I2C_SMBUS_WRITE);
|
||||
break;
|
||||
case MODE_READ:
|
||||
res = bus->i2c_smbus_read_byte(slave_addr);
|
||||
break;
|
||||
default:
|
||||
if ((i + j >= 0x30 && i + j <= 0x37)
|
||||
|| (i + j >= 0x50 && i + j <= 0x5F))
|
||||
res = bus->i2c_smbus_read_byte(slave_addr);
|
||||
else
|
||||
res = bus->i2c_smbus_write_quick(slave_addr, I2C_SMBUS_WRITE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (res < 0)
|
||||
{
|
||||
sprintf(line, "-- ");
|
||||
text.append(line);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(line, "%02x ", i + j);
|
||||
text.append(line);
|
||||
}
|
||||
}
|
||||
sprintf(line, "\r\n");
|
||||
text.append(line);
|
||||
}
|
||||
|
||||
return text;
|
||||
|
||||
} /* DetectI2C() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* 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);
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -457,21 +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() */
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = OpenRGB
|
||||
TEMPLATE = app
|
||||
|
||||
INCLUDEPATH += \
|
||||
dependencies/libe131/src/ \
|
||||
i2c_smbus/ \
|
||||
i2c_tools/ \
|
||||
net_port/ \
|
||||
serial_port/ \
|
||||
Controllers/AMDWraithPrismController/ \
|
||||
Controllers/AuraController/ \
|
||||
Controllers/CorsairController/ \
|
||||
Controllers/CorsairProController/ \
|
||||
Controllers/Hue2Controller/ \
|
||||
Controllers/HuePlusController/ \
|
||||
Controllers/HyperXController/ \
|
||||
Controllers/LEDStripController/ \
|
||||
Controllers/PatriotViperController/ \
|
||||
Controllers/PolychromeController/ \
|
||||
Controllers/RGBFusionController/ \
|
||||
RGBController/ \
|
||||
qt/
|
||||
|
||||
SOURCES += \
|
||||
RGBController/RGBController.cpp \
|
||||
dependencies/libe131/src/e131.c \
|
||||
main.cpp \
|
||||
OpenRGB.cpp \
|
||||
qt/OpenRGBDeviceInfoPage.cpp \
|
||||
qt/OpenRGBDevicePage.cpp \
|
||||
qt/OpenRGBDialog.cpp \
|
||||
i2c_smbus/i2c_smbus.cpp \
|
||||
i2c_tools/i2c_tools.cpp \
|
||||
net_port/net_port.cpp \
|
||||
qt/OpenRGBDialog2.cpp \
|
||||
qt/OpenRGBSystemInfoPage.cpp \
|
||||
qt/hsv.cpp \
|
||||
serial_port/serial_port.cpp \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp \
|
||||
Controllers/AuraController/AuraController.cpp \
|
||||
Controllers/AuraController/AuraControllerDetect.cpp \
|
||||
Controllers/CorsairController/CorsairController.cpp \
|
||||
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 += \
|
||||
Controllers/RGBFusionController/RGBFusionController.h \
|
||||
qt/OpenRGBDeviceInfoPage.h \
|
||||
qt/OpenRGBDevicePage.h \
|
||||
qt/OpenRGBDialog.h \
|
||||
i2c_smbus/i2c_smbus.h \
|
||||
i2c_tools/i2c_tools.h \
|
||||
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
|
||||
|
||||
RESOURCES += \
|
||||
qt/resources.qrc
|
||||
|
||||
FORMS += \
|
||||
qt/OpenRGBDeviceInfoPage.ui \
|
||||
qt/OpenRGBDevicePage.ui \
|
||||
qt/OpenRGBDialog.ui \
|
||||
qt/OpenRGBDialog2.ui \
|
||||
qt/OpenRGBSystemInfoPage.ui
|
||||
|
||||
#-----------------------------------------------
|
||||
# Windows specific project configuration
|
||||
#-----------------------------------------------
|
||||
win32:INCLUDEPATH += \
|
||||
dependencies/inpout32_1501/Win32/ \
|
||||
dependencies/razer-chroma-2.9.0/inc \
|
||||
dependencies/libusb-1.0.22/include \
|
||||
wmi/ \
|
||||
|
||||
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 \
|
||||
|
||||
win32:HEADERS += \
|
||||
dependencies/inpout32_1501/Win32/inpout32.h \
|
||||
i2c_smbus/i2c_smbus_i801.h \
|
||||
i2c_smbus/i2c_smbus_nct6775.h \
|
||||
i2c_smbus/i2c_smbus_piix4.h \
|
||||
wmi/wmi.h \
|
||||
RGBController/RGBController_AorusGPU.h \
|
||||
RGBController/RGBController_RazerChromaSDK.h \
|
||||
|
||||
win32:LIBS += \
|
||||
-lws2_32 \
|
||||
-L"$$PWD/dependencies/inpout32_1501/Win32/" -linpout32 \
|
||||
-L"$$PWD/dependencies/libusb-1.0.22/MS32/dll" -llibusb-1.0
|
||||
|
||||
win32:DEFINES -= \
|
||||
UNICODE
|
||||
|
||||
win32:DEFINES += \
|
||||
_MBCS \
|
||||
WIN32 \
|
||||
_CRT_SECURE_NO_WARNINGS \
|
||||
_WINSOCK_DEPRECATED_NO_WARNINGS \
|
||||
WIN32_LEAN_AND_MEAN
|
||||
|
||||
#-----------------------------------------------
|
||||
# Linux specific project configuration
|
||||
#-----------------------------------------------
|
||||
unix:INCLUDEPATH += \
|
||||
|
||||
unix:HEADERS += \
|
||||
i2c_smbus/i2c_smbus_linux.h \
|
||||
|
||||
unix:LIBS += \
|
||||
-lusb-1.0
|
||||
|
||||
unix:SOURCES += \
|
||||
i2c_smbus/i2c_smbus_linux.cpp \
|
||||
serial_port/find_usb_serial_port_linux.cpp \
|
||||
RGBController/OpenRazerDetect.cpp \
|
||||
RGBController/RGBController_OpenRazer.cpp \
|
||||
@@ -1,40 +1,50 @@
|
||||
# OpenAuraSDK
|
||||
##### This project is an open-source implementation of the Asus Aura RGB controller software. It currently only supports a limited number of motherboard and RAM module lighting controllers.
|
||||
# OpenRGB (formerly OpenAuraSDK)
|
||||
|
||||
## Supported Devices
|
||||
The goal of this project is to create an easy-to-use open source software program and library for accessing and controlling RGB lights on various PC hardware including motherboards, RAM modules, graphics cards, cooling devices, and peripherals.
|
||||
|
||||
Confirmed supported motherboards:
|
||||
- ASUS PRIME X370 Pro
|
||||
- ASUS PRIME X470 Pro
|
||||
- ASUS PRIME Z270-A
|
||||
- ASUS PRIME Z370-A
|
||||
- ASUS ROG Strix Z370-E
|
||||
|
||||
Confirmed supported RGB RAM (except on X299):
|
||||
- G.Skill Trident Z RGB
|
||||
- Geil Super Luce
|
||||
- TeamGroup Delta RGB
|
||||
This project originally focused only on ASUS Aura. It was spun off of Keyboard Visualizer's AsusAuraWindows branch to learn more about the details behind the Aura protocol and to develop a more flexible, compatible, and reliable driver for Aura. Our Aura implementation is now quite solid and supports multiple generations of Aura controller across both Intel and AMD platforms. It also supports Aura-compatible controllers used across multiple manufacturers of RGB memory modules including G.Skill Trident Z RGB and others. It is still lacking a few capabilities, namely saving settings to persist across reboots, but the core functionality of setting colors and modes is there.
|
||||
|
||||
Experimental support in generic RGB testing branch:
|
||||
- Corsair Vengeance RGB
|
||||
- Corsair Vengeance Pro RGB
|
||||
- HyperX Predator RGB
|
||||
After getting a solid Aura implementation, the project branched out into other manufacturers and categories of RGB devices. A major focus was to develop a software API that could reliably represent as many RGB devices as possible, exposing their various modes and describing their LED layouts via zones, that was generic enough to write a user application without specifically targeting any one manufacturer. To this extent, the generic_rgb_interface_test branch was created which became the foundation of OpenRGB. The goal of OpenRGB is to both develop new drivers for unsupported devices and integrate existing open source drivers for devices that do have some sort of open support. The goal is to be the one-stop solution to open source RGB lighting control!
|
||||
|
||||
## Supported Devices
|
||||
|
||||
* Asus Aura (SMBus variants only)
|
||||
|
||||
* Gigabyte RGB Fusion 1.0
|
||||
|
||||
* Asus Aura RAM
|
||||
|
||||
* Corsair Vengeance RGB
|
||||
|
||||
* Corsair Vengeance Pro RGB
|
||||
|
||||
* HyperX Predator RGB
|
||||
|
||||
* NZXT Hue+
|
||||
|
||||
* KeyboardVisualizer Arduino LED Strips
|
||||
|
||||
* E1.31 (Linux only)
|
||||
|
||||
* OpenRazer (Linux only)
|
||||
|
||||
## Installation
|
||||
#### Windows
|
||||
1. Download the latest Visual Studio Community Edition and open the `.sln`.
|
||||
2. Build the project for `x86` Architecture. The InpOut32 library I use does not support x64.
|
||||
3. Copy InpOut32.dll from dependencies to the same path as OpenAuraSDK.exe.
|
||||
|
||||
**You may have to retarget the project to the latest version of the Windows SDK and build tools and stuff.**
|
||||
1. Download the latest Visual Studio Community Edition and Qt Creator.
|
||||
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() */
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "RGBController.h"
|
||||
|
||||
RGBColor RGBController::GetLED(int led)
|
||||
{
|
||||
if(led < colors.size())
|
||||
{
|
||||
return(colors[led]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(0x00000000);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController::SetLED(int led, RGBColor color)
|
||||
{
|
||||
if(led < colors.size())
|
||||
{
|
||||
colors[led] = color;
|
||||
|
||||
UpdateSingleLED(led);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
for(int led = 0; led < colors.size(); led++)
|
||||
{
|
||||
colors[led] = color;
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateZoneLEDs(zone);
|
||||
}
|
||||
@@ -39,6 +39,22 @@ enum
|
||||
ZONE_TYPE_MATRIX
|
||||
};
|
||||
|
||||
typedef int device_type;
|
||||
|
||||
enum
|
||||
{
|
||||
DEVICE_TYPE_MOTHERBOARD,
|
||||
DEVICE_TYPE_DRAM,
|
||||
DEVICE_TYPE_GPU,
|
||||
DEVICE_TYPE_COOLER,
|
||||
DEVICE_TYPE_LEDSTRIP,
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
DEVICE_TYPE_MOUSE,
|
||||
DEVICE_TYPE_MOUSEMAT,
|
||||
DEVICE_TYPE_HEADSET,
|
||||
DEVICE_TYPE_UNKNOWN
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name; /* Zone name */
|
||||
@@ -50,17 +66,34 @@ typedef struct
|
||||
class RGBController
|
||||
{
|
||||
public:
|
||||
std::string name; /* controller name */
|
||||
std::vector<led> leds; /* LEDs */
|
||||
std::vector<zone> zones; /* Zones */
|
||||
std::vector<mode> modes; /* Modes */
|
||||
std::vector<RGBColor> colors; /* Color buffer */
|
||||
std::string name; /* controller name */
|
||||
std::string description; /* controller description */
|
||||
std::string version; /* controller version */
|
||||
std::string serial; /* controller serial number */
|
||||
std::string location; /* controller location */
|
||||
std::vector<led> leds; /* LEDs */
|
||||
std::vector<zone> zones; /* Zones */
|
||||
std::vector<mode> modes; /* Modes */
|
||||
std::vector<RGBColor> colors; /* Color buffer */
|
||||
device_type type; /* device type */
|
||||
|
||||
virtual int GetMode() = 0;
|
||||
virtual void SetMode(int mode) = 0;
|
||||
virtual void SetCustomMode() = 0;
|
||||
virtual void SetAllLEDs(RGBColor color) = 0;
|
||||
virtual void SetAllZoneLEDs(int zone, RGBColor color) = 0;
|
||||
virtual void SetLED(int led, RGBColor color) = 0;
|
||||
virtual void UpdateLEDs() = 0;
|
||||
};
|
||||
virtual ~RGBController() = default;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Generic functions implemented in RGBController.cpp |
|
||||
\*---------------------------------------------------------*/
|
||||
RGBColor GetLED(int led);
|
||||
void SetLED(int led, RGBColor color);
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Functions to be implemented in device implementation |
|
||||
\*---------------------------------------------------------*/
|
||||
virtual int GetMode() = 0;
|
||||
virtual void SetMode(int mode) = 0;
|
||||
virtual void SetCustomMode() = 0;
|
||||
virtual void UpdateLEDs() = 0;
|
||||
virtual void UpdateZoneLEDs(int zone) = 0;
|
||||
virtual void UpdateSingleLED(int led) = 0;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AMDWraithPrism.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for AMD Wraith |
|
||||
| Prism |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/25/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_AMDWraithPrism.h"
|
||||
|
||||
RGBController_AMDWraithPrism::RGBController_AMDWraithPrism(AMDWraithPrismController* wraith_ptr)
|
||||
{
|
||||
wraith = wraith_ptr;
|
||||
|
||||
name = "AMD Wraith Prism";
|
||||
type = DEVICE_TYPE_COOLER;
|
||||
version = wraith->GetFirmwareVersionString();
|
||||
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
|
||||
led logo_led;
|
||||
logo_led.name = "Logo";
|
||||
leds.push_back(logo_led);
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
zone logo_zone;
|
||||
logo_zone.name = "Logo";
|
||||
logo_zone.type = ZONE_TYPE_SINGLE;
|
||||
std::vector<int> logo_zone_map;
|
||||
logo_zone_map.push_back(0);
|
||||
logo_zone.map.push_back(logo_zone_map);
|
||||
zones.push_back(logo_zone);
|
||||
|
||||
led fan_led;
|
||||
fan_led.name = "Fan";
|
||||
leds.push_back(fan_led);
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
zone fan_zone;
|
||||
fan_zone.name = "Fan";
|
||||
fan_zone.type = ZONE_TYPE_SINGLE;
|
||||
std::vector<int> fan_zone_map;
|
||||
fan_zone_map.push_back(1);
|
||||
fan_zone.map.push_back(fan_zone_map);
|
||||
zones.push_back(fan_zone);
|
||||
|
||||
led ring_led;
|
||||
ring_led.name = "Ring";
|
||||
leds.push_back(ring_led);
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
zone ring_zone;
|
||||
ring_zone.name = "Ring";
|
||||
ring_zone.type = ZONE_TYPE_SINGLE;
|
||||
std::vector<int> ring_zone_map;
|
||||
ring_zone_map.push_back(2);
|
||||
ring_zone.map.push_back(ring_zone_map);
|
||||
zones.push_back(ring_zone);
|
||||
}
|
||||
|
||||
RGBController_AMDWraithPrism::~RGBController_AMDWraithPrism()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int RGBController_AMDWraithPrism::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::UpdateLEDs()
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
wraith->SetLogoColor(red, grn, blu);
|
||||
|
||||
red = RGBGetRValue(colors[1]);
|
||||
grn = RGBGetGValue(colors[1]);
|
||||
blu = RGBGetBValue(colors[1]);
|
||||
wraith->SetFanColor(red, grn, blu);
|
||||
|
||||
red = RGBGetRValue(colors[2]);
|
||||
grn = RGBGetGValue(colors[2]);
|
||||
blu = RGBGetBValue(colors[2]);
|
||||
wraith->SetRingColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
RGBColor color = colors[zone];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if(zone == 0)
|
||||
{
|
||||
wraith->SetLogoColor(red, grn, blu);
|
||||
}
|
||||
else if(zone == 1)
|
||||
{
|
||||
wraith->SetFanColor(red, grn, blu);
|
||||
}
|
||||
else if(zone == 2)
|
||||
{
|
||||
wraith->SetRingColor(red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AMDWraithPrism::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateZoneLEDs(led);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AMDWraithPrism.h |
|
||||
| |
|
||||
| Generic RGB Interface for AMD Wraith |
|
||||
| Prism |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/25/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "AMDWraithPrismController.h"
|
||||
|
||||
class RGBController_AMDWraithPrism : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AMDWraithPrism(AMDWraithPrismController* wraith_ptr);
|
||||
~RGBController_AMDWraithPrism();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
private:
|
||||
AMDWraithPrismController* wraith;
|
||||
};
|
||||
@@ -35,8 +35,9 @@ void RGBController_AorusGPU::SetCustomMode()
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::SetAllLEDs(RGBColor color)
|
||||
void RGBController_AorusGPU::UpdateLEDs()
|
||||
{
|
||||
RGBColor color = colors[0];
|
||||
data[9] = RGBGetRValue(color);
|
||||
data[10] = RGBGetGValue(color);
|
||||
data[11] = RGBGetBValue(color);
|
||||
@@ -44,27 +45,20 @@ void RGBController_AorusGPU::SetAllLEDs(RGBColor color)
|
||||
GvWriteI2C(0x00000000, data, 0x00000000);
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
void RGBController_AorusGPU::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
data[9] = RGBGetRValue(color);
|
||||
data[10] = RGBGetGValue(color);
|
||||
data[11] = RGBGetBValue(color);
|
||||
|
||||
GvWriteI2C(0x00000000, data, 0x00000000);
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::SetLED(int led, RGBColor color)
|
||||
void RGBController_AorusGPU::UpdateSingleLED(int led)
|
||||
{
|
||||
data[9] = RGBGetRValue(color);
|
||||
data[10] = RGBGetGValue(color);
|
||||
data[11] = RGBGetBValue(color);
|
||||
|
||||
GvWriteI2C(0x00000000, data, 0x00000000);
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
RGBController_AorusGPU::RGBController_AorusGPU()
|
||||
{
|
||||
name = "Aorus GPU";
|
||||
type = DEVICE_TYPE_GPU;
|
||||
|
||||
handle = LoadLibrary("GvDisplay.dll");
|
||||
|
||||
@@ -75,6 +69,8 @@ RGBController_AorusGPU::RGBController_AorusGPU()
|
||||
GvFreeDispLib();
|
||||
GvInitDispLib();
|
||||
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
mode aorus_mode;
|
||||
aorus_mode.name = "Static";
|
||||
modes.push_back(aorus_mode);
|
||||
@@ -89,4 +85,4 @@ RGBController_AorusGPU::RGBController_AorusGPU()
|
||||
aorus_zone_map.push_back(0);
|
||||
aorus_zone.map.push_back(aorus_zone_map);
|
||||
zones.push_back(aorus_zone);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,15 +19,15 @@ class RGBController_AorusGPU : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AorusGPU();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
void SetLED(int led, RGBColor color);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
private:
|
||||
_GvWriteI2C GvWriteI2C;
|
||||
_GvFreeDispLib GvFreeDispLib;
|
||||
_GvInitDispLib GvInitDispLib;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -39,63 +39,9 @@ void RGBController_Aura::SetCustomMode()
|
||||
aura->SetDirect(true);
|
||||
}
|
||||
|
||||
void RGBController_Aura::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if (GetMode() == 0)
|
||||
{
|
||||
aura->SetAllColorsDirect(red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetAllColorsEffect(red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Aura::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
if (GetMode() == 0)
|
||||
{
|
||||
aura->SetLEDColorDirect(zones[zone].map[x][y], red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetLEDColorEffect(zones[zone].map[x][y], red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Aura::SetLED(int led, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if (GetMode() == 0)
|
||||
{
|
||||
aura->SetLEDColorDirect(led, red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetLEDColorEffect(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
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]);
|
||||
@@ -112,13 +58,65 @@ void RGBController_Aura::UpdateLEDs()
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Aura::UpdateZoneLEDs(int 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++)
|
||||
{
|
||||
int led = zones[zone].map[x][y];
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if (GetMode() == 0)
|
||||
{
|
||||
aura->SetLEDColorDirect(led, red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetLEDColorEffect(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Aura::UpdateSingleLED(int led)
|
||||
{
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if (GetMode() == 0)
|
||||
{
|
||||
aura->SetLEDColorDirect(led, red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetLEDColorEffect(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
|
||||
{
|
||||
std::vector<unsigned char> aura_channels;
|
||||
|
||||
aura = aura_ptr;
|
||||
|
||||
name = aura->GetDeviceName();
|
||||
version = aura->GetDeviceName();
|
||||
location = aura->GetDeviceLocation();
|
||||
if((version.find("DIMM_LED") != std::string::npos) || (version.find("AUDA") != std::string::npos) )
|
||||
{
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
name = "ASUS Aura DRAM";
|
||||
}
|
||||
else
|
||||
{
|
||||
type = DEVICE_TYPE_MOTHERBOARD;
|
||||
name = "ASUS Aura Motherboard";
|
||||
}
|
||||
|
||||
mode aura_modes[AURA_NUMBER_MODES + 1];
|
||||
|
||||
@@ -138,12 +136,14 @@ 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++)
|
||||
colors.resize(aura->GetLEDCount());
|
||||
|
||||
for (std::size_t i = 0; i < aura->GetLEDCount(); i++)
|
||||
{
|
||||
aura_channels.push_back(aura->GetChannel(i));
|
||||
|
||||
@@ -152,18 +152,23 @@ RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
|
||||
new_led->name = aura->GetChannelName(i);
|
||||
|
||||
leds.push_back(*new_led);
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
unsigned char red = aura->GetLEDRed(i);
|
||||
unsigned char grn = aura->GetLEDGreen(i);
|
||||
unsigned char blu = aura->GetLEDBlue(i);
|
||||
|
||||
colors[i] = ToRGBColor(red, grn, blu);
|
||||
}
|
||||
|
||||
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])
|
||||
{
|
||||
@@ -181,7 +186,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])
|
||||
{
|
||||
@@ -200,4 +205,4 @@ RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,13 @@ class RGBController_Aura : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Aura(AuraController* aura_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();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
private:
|
||||
AuraController* aura;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -24,42 +24,24 @@ void RGBController_Corsair::SetCustomMode()
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Corsair::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
corsair->SetAllColors(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_Corsair::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
corsair->SetLEDColor(zones[zone].map[x][y], red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Corsair::SetLED(int led, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
corsair->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_Corsair::UpdateLEDs()
|
||||
{
|
||||
RGBColor color = colors[0];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
corsair->SetLEDColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_Corsair::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Corsair::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
RGBController_Corsair::RGBController_Corsair(CorsairController* corsair_ptr)
|
||||
@@ -67,6 +49,9 @@ RGBController_Corsair::RGBController_Corsair(CorsairController* corsair_ptr)
|
||||
corsair = corsair_ptr;
|
||||
|
||||
name = corsair->GetDeviceName();
|
||||
location = corsair->GetDeviceLocation();
|
||||
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
|
||||
mode corsair_modes[CORSAIR_NUMBER_MODES];
|
||||
|
||||
@@ -79,7 +64,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();
|
||||
|
||||
@@ -96,7 +81,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);
|
||||
}
|
||||
@@ -104,4 +89,4 @@ RGBController_Corsair::RGBController_Corsair(CorsairController* corsair_ptr)
|
||||
new_zone.map.push_back(zone_row);
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,13 @@ class RGBController_Corsair : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Corsair(CorsairController* corsair_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();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
private:
|
||||
CorsairController* corsair;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -56,53 +56,44 @@ void RGBController_CorsairPro::SetCustomMode()
|
||||
corsair->SetCustom();
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::SetAllLEDs(RGBColor color)
|
||||
void RGBController_CorsairPro::UpdateLEDs()
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
corsair->SetAllColors(red, grn, blu);
|
||||
corsair->ApplyColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(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 led = 0; led < colors.size(); led++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
corsair->SetLEDColor(zones[zone].map[x][y], red, grn, blu);
|
||||
}
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
corsair->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
|
||||
corsair->ApplyColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::SetLED(int led, RGBColor color)
|
||||
void RGBController_CorsairPro::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::UpdateSingleLED(int led)
|
||||
{
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
corsair->SetLEDColor(led, red, grn, blu);
|
||||
corsair->ApplyColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::UpdateLEDs()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair_ptr)
|
||||
{
|
||||
corsair = corsair_ptr;
|
||||
|
||||
name = corsair->GetDeviceName();
|
||||
location = corsair->GetDeviceLocation();
|
||||
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
|
||||
mode corsair_modes[CORSAIR_PRO_NUMBER_MODES];
|
||||
|
||||
@@ -122,14 +113,15 @@ RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair
|
||||
modes.push_back(corsair_modes[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < corsair->GetLEDCount(); i++)
|
||||
colors.resize(corsair->GetLEDCount());
|
||||
|
||||
for (unsigned int i = 0; i < corsair->GetLEDCount(); i++)
|
||||
{
|
||||
led* new_led = new led();
|
||||
|
||||
new_led->name = "Corsair Pro LED";
|
||||
|
||||
leds.push_back(*new_led);
|
||||
colors.push_back(0x00000000);
|
||||
}
|
||||
|
||||
zone new_zone;
|
||||
@@ -139,7 +131,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);
|
||||
}
|
||||
@@ -147,4 +139,4 @@ RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair
|
||||
new_zone.map.push_back(zone_row);
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,13 @@ class RGBController_CorsairPro : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CorsairPro(CorsairProController* corsair_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();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
private:
|
||||
CorsairProController* corsair;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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*/)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -101,41 +101,11 @@ void RGBController_E131::SetCustomMode()
|
||||
|
||||
}
|
||||
|
||||
void RGBController_E131::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_E131::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
colors[zones[zone].map[x][y]] = color;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_E131::SetLED(int led, RGBColor color)
|
||||
{
|
||||
colors[led] = color;
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
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 +113,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 +155,19 @@ 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]);
|
||||
e131_send(sockfd, &packets[packet_idx], &dest_addrs[packet_idx]);
|
||||
packets[packet_idx].frame.seq_number++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_E131::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_E131::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
@@ -37,13 +37,12 @@ class RGBController_E131 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_E131(std::vector<E131Device> device_list);
|
||||
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();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
private:
|
||||
std::vector<E131Device> devices;
|
||||
@@ -51,4 +50,4 @@ private:
|
||||
std::vector<e131_addr_t> dest_addrs;
|
||||
std::vector<unsigned int> universes;
|
||||
int sockfd;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
/*-----------------------------------------*\
|
||||
| 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);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set size of colors array |
|
||||
\*-------------------------------------------------*/
|
||||
unsigned int led_count = 0;
|
||||
for (unsigned int channel_idx = 0; channel_idx < HUE_2_NUM_CHANNELS; channel_idx++)
|
||||
{
|
||||
led_count += hue2->channel_leds[channel_idx];
|
||||
}
|
||||
colors.resize(led_count);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set zones and leds |
|
||||
\*-------------------------------------------------*/
|
||||
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++)
|
||||
{
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int RGBController_Hue2::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_Hue2::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Hue2::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Hue2::UpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx <= zones.size(); zone_idx++)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone_idx];
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
hue2->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Hue2::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone];
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
hue2->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Hue2::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned int channel = leds_channel[led];
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
hue2->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*-----------------------------------------*\
|
||||
| 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 UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
private:
|
||||
Hue2Controller* hue2;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
std::vector<unsigned int> zones_channel;
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_HuePlus.cpp |
|
||||
| RGBController_HuePlus.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for NZXT Hue+ |
|
||||
| |
|
||||
@@ -11,31 +11,70 @@
|
||||
|
||||
RGBController_HuePlus::RGBController_HuePlus(HuePlusController* hueplus_ptr)
|
||||
{
|
||||
strip = hueplus_ptr;
|
||||
hueplus = hueplus_ptr;
|
||||
|
||||
name = "LED Strip";
|
||||
name = "NZXT Hue+";
|
||||
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
|
||||
location = hueplus->GetLEDString();
|
||||
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
|
||||
for (int i = 0; i < strip->num_leds; i++)
|
||||
/*-------------------------------------------------*\
|
||||
| Set size of colors array |
|
||||
\*-------------------------------------------------*/
|
||||
unsigned int led_count = 0;
|
||||
for (unsigned int channel_idx = 0; channel_idx < HUE_PLUS_NUM_CHANNELS; channel_idx++)
|
||||
{
|
||||
colors.push_back(0x00000000);
|
||||
led new_led;
|
||||
new_led.name = "LED Strip";
|
||||
leds.push_back(new_led);
|
||||
led_count += hueplus->channel_leds[channel_idx];
|
||||
}
|
||||
colors.resize(led_count);
|
||||
|
||||
zone led_zone;
|
||||
led_zone.name = "LED Strip";
|
||||
std::vector<int> led_zone_map;
|
||||
for (int i = 0; i < strip->num_leds; i++)
|
||||
/*-------------------------------------------------*\
|
||||
| Set zones and leds |
|
||||
\*-------------------------------------------------*/
|
||||
unsigned int led_idx = 0;
|
||||
for (int channel_idx = 0; channel_idx < HUE_PLUS_NUM_CHANNELS; channel_idx++)
|
||||
{
|
||||
led_zone_map.push_back(i);
|
||||
if(hueplus->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+ 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 led_ch_idx = 0; led_ch_idx < hueplus->channel_leds[channel_idx]; led_ch_idx++)
|
||||
{
|
||||
char led_idx_string[3];
|
||||
sprintf(led_idx_string, "%d", led_ch_idx + 1);
|
||||
|
||||
led new_led;
|
||||
new_led.name = "Hue+ 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);
|
||||
}
|
||||
}
|
||||
led_zone.map.push_back(led_zone_map);
|
||||
zones.push_back(led_zone);
|
||||
}
|
||||
|
||||
int RGBController_HuePlus::GetMode()
|
||||
@@ -43,7 +82,7 @@ int RGBController_HuePlus::GetMode()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetMode(int mode)
|
||||
void RGBController_HuePlus::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -53,34 +92,65 @@ void RGBController_HuePlus::SetCustomMode()
|
||||
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetLED(int led, RGBColor color)
|
||||
{
|
||||
colors[led] = color;
|
||||
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::UpdateLEDs()
|
||||
{
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
for(std::size_t zone_idx = 0; zone_idx <= zones.size(); zone_idx++)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone_idx];
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
hueplus->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
unsigned int channel = zones_channel[zone];
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
hueplus->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned int channel = leds_channel[led];
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
if(channel_colors.size() > 0)
|
||||
{
|
||||
hueplus->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_HuePlus.h |
|
||||
| RGBController_HuePlus.h |
|
||||
| |
|
||||
| Generic RGB Interface for NZXT Hue+ |
|
||||
| |
|
||||
@@ -15,14 +15,15 @@ class RGBController_HuePlus : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HuePlus(HuePlusController* hueplus_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();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
private:
|
||||
HuePlusController* strip;
|
||||
};
|
||||
HuePlusController* hueplus;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
std::vector<unsigned int> zones_channel;
|
||||
};
|
||||
|
||||
@@ -21,45 +21,79 @@ void RGBController_HyperX::SetMode(int mode)
|
||||
|
||||
void RGBController_HyperX::SetCustomMode()
|
||||
{
|
||||
hyperx->SetMode(HYPERX_MODE_STATIC);
|
||||
}
|
||||
|
||||
void RGBController_HyperX::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
hyperx->SetAllColors(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_HyperX::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
hyperx->SetLEDColor(zones[zone].map[x][y], red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HyperX::SetLED(int led, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
hyperx->SetLEDColor(led, red, grn, blu);
|
||||
hyperx->SetMode(HYPERX_MODE_DIRECT);
|
||||
}
|
||||
|
||||
void RGBController_HyperX::UpdateLEDs()
|
||||
{
|
||||
|
||||
if(hyperx->GetMode() == HYPERX_MODE_DIRECT)
|
||||
{
|
||||
for (std::size_t zone = 0; zone < zones.size(); 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++)
|
||||
{
|
||||
int led = zones[zone].map[x][y];
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
hyperx->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
hyperx->SetEffectColor(red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HyperX::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
if(hyperx->GetMode() == HYPERX_MODE_DIRECT)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
int led = zones[zone].map[x][y];
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
hyperx->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
hyperx->SetEffectColor(red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HyperX::UpdateSingleLED(int led)
|
||||
{
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if(hyperx->GetMode() == HYPERX_MODE_DIRECT)
|
||||
{
|
||||
hyperx->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
hyperx->SetEffectColor(red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
RGBController_HyperX::RGBController_HyperX(HyperXController* hyperx_ptr)
|
||||
@@ -67,46 +101,62 @@ RGBController_HyperX::RGBController_HyperX(HyperXController* hyperx_ptr)
|
||||
hyperx = hyperx_ptr;
|
||||
|
||||
name = hyperx->GetDeviceName();
|
||||
location = hyperx->GetDeviceLocation();
|
||||
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
|
||||
mode hyperx_modes[HYPERX_NUMBER_MODES];
|
||||
|
||||
hyperx_modes[0].name = "Static";
|
||||
hyperx_modes[1].name = "Rainbow";
|
||||
hyperx_modes[2].name = "Comet";
|
||||
hyperx_modes[3].name = "Heartbeat";
|
||||
hyperx_modes[4].name = "Spectrum Cycle";
|
||||
hyperx_modes[5].name = "Breathing";
|
||||
hyperx_modes[6].name = "Bounce";
|
||||
hyperx_modes[7].name = "Blink";
|
||||
hyperx_modes[0].name = "Direct";
|
||||
hyperx_modes[1].name = "Static";
|
||||
hyperx_modes[2].name = "Rainbow";
|
||||
hyperx_modes[3].name = "Comet";
|
||||
hyperx_modes[4].name = "Heartbeat";
|
||||
hyperx_modes[5].name = "Spectrum Cycle";
|
||||
hyperx_modes[6].name = "Breathing";
|
||||
hyperx_modes[7].name = "Bounce";
|
||||
hyperx_modes[8].name = "Blink";
|
||||
|
||||
for (int i = 0; i < HYPERX_NUMBER_MODES; i++)
|
||||
{
|
||||
modes.push_back(hyperx_modes[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < hyperx->GetLEDCount(); i++)
|
||||
unsigned int led_idx = 0;
|
||||
|
||||
for(unsigned int slot = 0; slot < hyperx->GetSlotCount(); slot++)
|
||||
{
|
||||
led* new_led = new led();
|
||||
zone* new_zone = new zone;
|
||||
|
||||
new_led->name = "HyperX LED";
|
||||
char slot_idx_str[3];
|
||||
sprintf(slot_idx_str, "%d", slot);
|
||||
new_zone->name = "HyperX Slot ";
|
||||
new_zone->name.append(slot_idx_str);
|
||||
|
||||
leds.push_back(*new_led);
|
||||
colors.push_back(0x00000000);
|
||||
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 = "HyperX 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);
|
||||
}
|
||||
|
||||
zone new_zone;
|
||||
|
||||
new_zone.name = "HyperX Zone";
|
||||
new_zone.type = ZONE_TYPE_SINGLE;
|
||||
|
||||
std::vector<int> zone_row;
|
||||
|
||||
for (int i = 0; i < hyperx->GetLEDCount(); i++)
|
||||
{
|
||||
zone_row.push_back(i);
|
||||
}
|
||||
|
||||
new_zone.map.push_back(zone_row);
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,13 @@ class RGBController_HyperX : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HyperX(HyperXController* hyperx_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();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
private:
|
||||
HyperXController* hyperx;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -16,6 +16,8 @@ RGBController_LEDStrip::RGBController_LEDStrip(LEDStripController* ledstrip_ptr)
|
||||
|
||||
name = "LED Strip";
|
||||
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
@@ -44,7 +46,7 @@ int RGBController_LEDStrip::GetMode()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetMode(int mode)
|
||||
void RGBController_LEDStrip::SetMode(int /*mode*/)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -54,34 +56,17 @@ void RGBController_LEDStrip::SetCustomMode()
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetLED(int led, RGBColor color)
|
||||
{
|
||||
colors[led] = color;
|
||||
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::UpdateLEDs()
|
||||
{
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::UpdateSingleLED(int led)
|
||||
{
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@ class RGBController_LEDStrip : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LEDStrip(LEDStripController* ledstrip_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();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
|
||||
private:
|
||||
LEDStripController* strip;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ void RGBController_OpenRazer::SetMode(int mode)
|
||||
{
|
||||
char update_value = 1;
|
||||
|
||||
switch(type)
|
||||
switch(matrix_type)
|
||||
{
|
||||
case RAZER_TYPE_MATRIX_FRAME:
|
||||
case RAZER_TYPE_MATRIX_NOFRAME:
|
||||
@@ -92,7 +92,7 @@ void RGBController_OpenRazer::SetCustomMode()
|
||||
|
||||
void RGBController_OpenRazer::UpdateLEDs()
|
||||
{
|
||||
switch(type)
|
||||
switch(matrix_type)
|
||||
{
|
||||
case RAZER_TYPE_MATRIX_FRAME:
|
||||
case RAZER_TYPE_MATRIX_NOFRAME:
|
||||
@@ -100,13 +100,13 @@ 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;
|
||||
unsigned int row_offset = (row * matrix_cols);
|
||||
|
||||
if(type == RAZER_TYPE_MATRIX_FRAME)
|
||||
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
|
||||
{
|
||||
output_array_size = 3 + (matrix_cols* 3);
|
||||
output_offset = 3;
|
||||
@@ -119,14 +119,14 @@ void RGBController_OpenRazer::UpdateLEDs()
|
||||
|
||||
char output_array[output_array_size];
|
||||
|
||||
if(type == RAZER_TYPE_MATRIX_FRAME)
|
||||
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
|
||||
{
|
||||
output_array[0] = row;
|
||||
output_array[1] = 0;
|
||||
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]);
|
||||
@@ -134,12 +134,12 @@ void RGBController_OpenRazer::UpdateLEDs()
|
||||
output_array[(col * 3) + 2 + output_offset] = (char)RGBGetBValue(colors[color_idx]);
|
||||
}
|
||||
|
||||
if(type == RAZER_TYPE_MATRIX_FRAME)
|
||||
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
|
||||
{
|
||||
matrix_custom_frame.write(output_array, output_array_size);
|
||||
matrix_custom_frame.flush();
|
||||
}
|
||||
else if(type == RAZER_TYPE_MATRIX_NOFRAME)
|
||||
else if(matrix_type == RAZER_TYPE_MATRIX_NOFRAME)
|
||||
{
|
||||
matrix_effect_custom.write(output_array, output_array_size);
|
||||
matrix_effect_custom.flush();
|
||||
@@ -151,7 +151,7 @@ void RGBController_OpenRazer::UpdateLEDs()
|
||||
}
|
||||
}
|
||||
|
||||
if(type == RAZER_TYPE_MATRIX_FRAME)
|
||||
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
|
||||
{
|
||||
matrix_effect_custom.write(&update_value, 1);
|
||||
matrix_effect_custom.flush();
|
||||
@@ -187,33 +187,13 @@ void RGBController_OpenRazer::UpdateLEDs()
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetAllLEDs(RGBColor color)
|
||||
void RGBController_OpenRazer::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
for(int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
void RGBController_OpenRazer::UpdateSingleLED(int led)
|
||||
{
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
colors[zones[zone].map[x][y]] = color;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetLED(int led, RGBColor color)
|
||||
{
|
||||
colors[led] = color;
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
@@ -231,6 +211,34 @@ static std::string GetDeviceTypeString(std::string dev_path)
|
||||
return(ret_str);
|
||||
}
|
||||
|
||||
static std::string GetFirmwareVersionString(std::string dev_path)
|
||||
{
|
||||
// Read firmware_version for firmware version string
|
||||
std::string firm_ver_path = dev_path + "/firmware_version";
|
||||
std::ifstream firm_ver_file;
|
||||
std::string ret_str;
|
||||
|
||||
firm_ver_file.open(firm_ver_path);
|
||||
std::getline(firm_ver_file, ret_str);
|
||||
firm_ver_file.close();
|
||||
|
||||
return(ret_str);
|
||||
}
|
||||
|
||||
static std::string GetSerialNumberString(std::string dev_path)
|
||||
{
|
||||
// Read device_serial for serial number string
|
||||
std::string ser_num_path = dev_path + "/device_serial";
|
||||
std::ifstream ser_num_file;
|
||||
std::string ret_str;
|
||||
|
||||
ser_num_file.open(ser_num_path);
|
||||
std::getline(ser_num_file, ret_str);
|
||||
ser_num_file.close();
|
||||
|
||||
return(ret_str);
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetupMatrixDevice(std::string dev_path, unsigned int rows, unsigned int cols)
|
||||
{
|
||||
matrix_custom_frame.open(dev_path + "/matrix_custom_frame");
|
||||
@@ -246,11 +254,11 @@ void RGBController_OpenRazer::SetupMatrixDevice(std::string dev_path, unsigned i
|
||||
{
|
||||
if(!matrix_effect_custom)
|
||||
{
|
||||
type = RAZER_TYPE_MATRIX_STATIC;
|
||||
matrix_type = RAZER_TYPE_MATRIX_STATIC;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = RAZER_TYPE_MATRIX_NOFRAME;
|
||||
matrix_type = RAZER_TYPE_MATRIX_NOFRAME;
|
||||
}
|
||||
|
||||
matrix_rows = 1;
|
||||
@@ -258,7 +266,7 @@ void RGBController_OpenRazer::SetupMatrixDevice(std::string dev_path, unsigned i
|
||||
}
|
||||
else
|
||||
{
|
||||
type = RAZER_TYPE_MATRIX_FRAME;
|
||||
matrix_type = RAZER_TYPE_MATRIX_FRAME;
|
||||
|
||||
matrix_rows = rows;
|
||||
matrix_cols = cols;
|
||||
@@ -272,7 +280,7 @@ void RGBController_OpenRazer::SetupNonMatrixDevice(std::string dev_path)
|
||||
scroll_led_effect.open(dev_path + "/scroll_led_effect");
|
||||
scroll_led_rgb.open(dev_path + "/scroll_led_rgb");
|
||||
|
||||
type = RAZER_TYPE_NOMATRIX;
|
||||
matrix_type = RAZER_TYPE_NOMATRIX;
|
||||
}
|
||||
|
||||
RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
@@ -289,10 +297,30 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
\*-----------------------------------------------------------------*/
|
||||
name = GetDeviceTypeString(dev_path);
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Set the description to indicate this is an OpenRazer device |
|
||||
\*-----------------------------------------------------------------*/
|
||||
description = "OpenRazer Device";
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Set the device path as the location |
|
||||
\*-----------------------------------------------------------------*/
|
||||
location = dev_path;
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Get the serial number from the dev path |
|
||||
\*-----------------------------------------------------------------*/
|
||||
serial = GetSerialNumberString(dev_path);
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Get the firmware version from the dev path |
|
||||
\*-----------------------------------------------------------------*/
|
||||
version = GetFirmwareVersionString(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)
|
||||
{
|
||||
@@ -301,6 +329,11 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
\*---------------------------------------------------------*/
|
||||
device = i;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set device type |
|
||||
\*---------------------------------------------------------*/
|
||||
type = device_list[i]->type;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize modes |
|
||||
\*---------------------------------------------------------*/
|
||||
@@ -342,11 +375,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);
|
||||
@@ -367,4 +400,4 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
std::string name;
|
||||
device_type type;
|
||||
bool matrix_type;
|
||||
unsigned int rows;
|
||||
unsigned int cols;
|
||||
@@ -53,6 +54,7 @@ static const razer_zone blackwidow_chroma_zone =
|
||||
static const razer_device blackwidow_chroma_device =
|
||||
{
|
||||
"Razer BlackWidow Chroma",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
22,
|
||||
@@ -84,6 +86,7 @@ static const razer_zone blackwidow_chroma_te_zone =
|
||||
static const razer_device blackwidow_chroma_te_device =
|
||||
{
|
||||
"Razer BlackWidow Chroma Tournament Edition",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
22,
|
||||
@@ -115,6 +118,7 @@ static const razer_zone ornata_chroma_zone =
|
||||
static const razer_device ornata_chroma_device =
|
||||
{
|
||||
"Razer Ornata Chroma",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
22,
|
||||
@@ -146,6 +150,7 @@ static const razer_zone deathstalker_chroma_zone =
|
||||
static const razer_device deathstalker_chroma_device =
|
||||
{
|
||||
"Razer DeathStalker Chroma",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
1,
|
||||
12,
|
||||
@@ -181,6 +186,7 @@ static const razer_zone blade_stealth_zone =
|
||||
static const razer_device blade_stealth_device =
|
||||
{
|
||||
"Razer Blade Stealth",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
16,
|
||||
@@ -212,6 +218,7 @@ static const razer_zone blade_pro_late_2016_zone =
|
||||
static const razer_device blade_pro_late_2016_device =
|
||||
{
|
||||
"Razer Blade Pro (Late 2016)",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
25,
|
||||
@@ -243,6 +250,7 @@ static const razer_zone blade_pro_2017_zone =
|
||||
static const razer_device blade_pro_2017_device =
|
||||
{
|
||||
"Razer Blade Pro (2017)",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
25,
|
||||
@@ -314,6 +322,7 @@ static const razer_zone mamba_te_scroll_wheel_zone =
|
||||
static const razer_device mamba_te_device =
|
||||
{
|
||||
"Razer Mamba Tournament Edition",
|
||||
DEVICE_TYPE_MOUSE,
|
||||
true,
|
||||
1,
|
||||
16,
|
||||
@@ -393,6 +402,7 @@ static const razer_zone diamondback_chroma_scroll_wheel_zone =
|
||||
static const razer_device diamondback_chroma_device =
|
||||
{
|
||||
"Razer Diamondback Chroma",
|
||||
DEVICE_TYPE_MOUSE,
|
||||
true,
|
||||
1,
|
||||
21,
|
||||
@@ -436,6 +446,7 @@ static const razer_zone deathadder_chroma_scroll_wheel_zone =
|
||||
static const razer_device deathadder_chroma_device =
|
||||
{
|
||||
"Razer DeathAdder Chroma",
|
||||
DEVICE_TYPE_MOUSE,
|
||||
false,
|
||||
1,
|
||||
2,
|
||||
@@ -491,6 +502,7 @@ static const razer_zone naga_chroma_numpad_zone =
|
||||
static const razer_device naga_chroma_device =
|
||||
{
|
||||
"Razer Naga Chroma",
|
||||
DEVICE_TYPE_MOUSE,
|
||||
false,
|
||||
1,
|
||||
3,
|
||||
@@ -526,6 +538,7 @@ static const razer_zone orbweaver_chroma_zone =
|
||||
static const razer_device orbweaver_chroma_device =
|
||||
{
|
||||
"Razer Orbweaver Chroma",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
25,
|
||||
@@ -557,6 +570,7 @@ static const razer_zone tartarus_chroma_zone =
|
||||
static const razer_device tartarus_chroma_device =
|
||||
{
|
||||
"Razer Tartarus Chroma",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
1,
|
||||
1,
|
||||
@@ -592,6 +606,7 @@ static const razer_zone firefly_zone =
|
||||
static const razer_device firefly_device =
|
||||
{
|
||||
"Razer Firefly",
|
||||
DEVICE_TYPE_MOUSEMAT,
|
||||
true,
|
||||
1,
|
||||
15,
|
||||
@@ -623,6 +638,7 @@ static const razer_zone goliathus_extended_zone =
|
||||
static const razer_device goliathus_extended_device =
|
||||
{
|
||||
"Razer Goliathus Extended",
|
||||
DEVICE_TYPE_MOUSEMAT,
|
||||
true,
|
||||
1,
|
||||
1,
|
||||
@@ -658,6 +674,7 @@ static const razer_zone kraken_chroma_zone =
|
||||
static const razer_device kraken_chroma_device =
|
||||
{
|
||||
"Razer Kraken 7.1 Chroma",
|
||||
DEVICE_TYPE_HEADSET,
|
||||
true,
|
||||
1,
|
||||
1,
|
||||
@@ -689,6 +706,7 @@ static const razer_zone kraken_v2_zone =
|
||||
static const razer_device kraken_v2_device =
|
||||
{
|
||||
"Razer Kraken 7.1 V2",
|
||||
DEVICE_TYPE_HEADSET,
|
||||
true,
|
||||
1,
|
||||
1,
|
||||
@@ -736,6 +754,7 @@ static const razer_zone core_led_strip_zone =
|
||||
static const razer_device core_device =
|
||||
{
|
||||
"Razer Core",
|
||||
DEVICE_TYPE_UNKNOWN,
|
||||
true,
|
||||
1,
|
||||
9,
|
||||
@@ -767,6 +786,7 @@ static const razer_zone mug_holder_zone =
|
||||
static const razer_device mug_holder_device =
|
||||
{
|
||||
"Razer Chroma Mug Holder",
|
||||
DEVICE_TYPE_UNKNOWN,
|
||||
true,
|
||||
1,
|
||||
15,
|
||||
@@ -810,6 +830,7 @@ static const razer_zone chromahdk_zone =
|
||||
static const razer_device chromahdk_device =
|
||||
{
|
||||
"Razer Chroma HDK",
|
||||
DEVICE_TYPE_LEDSTRIP,
|
||||
true,
|
||||
4,
|
||||
16,
|
||||
@@ -899,13 +920,12 @@ public:
|
||||
|
||||
public:
|
||||
RGBController_OpenRazer(std::string dev_path);
|
||||
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();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
int device;
|
||||
|
||||
@@ -913,7 +933,7 @@ private:
|
||||
void SetupMatrixDevice(std::string dev_path, unsigned int rows, unsigned int cols);
|
||||
void SetupNonMatrixDevice(std::string dev_path);
|
||||
|
||||
unsigned int type;
|
||||
unsigned int matrix_type;
|
||||
unsigned int matrix_rows;
|
||||
unsigned int matrix_cols;
|
||||
|
||||
@@ -932,4 +952,4 @@ private:
|
||||
std::ofstream logo_led_rgb;
|
||||
std::ofstream scroll_led_effect;
|
||||
std::ofstream scroll_led_rgb;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/*-----------------------------------------*\
|
||||
| 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::UpdateLEDs()
|
||||
{
|
||||
if(viper->direct == true)
|
||||
{
|
||||
for(int led = 0; led < 5; led++)
|
||||
{
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
viper->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int led = 0; led < 5; led++)
|
||||
{
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
viper->SetLEDEffectColor(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_PatriotViper::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_PatriotViper::UpdateSingleLED(int led)
|
||||
{
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if(viper->direct == true)
|
||||
{
|
||||
viper->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
viper->SetLEDEffectColor(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
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,28 @@
|
||||
/*-----------------------------------------*\
|
||||
| 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 UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
private:
|
||||
PatriotViperController* viper;
|
||||
};
|
||||
@@ -0,0 +1,96 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Polychrome.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| ASRock ASR LED and Polychrome RGB Driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/15/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_Polychrome.h"
|
||||
|
||||
int RGBController_Polychrome::GetMode()
|
||||
{
|
||||
return(polychrome->GetMode());
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::SetMode(int mode)
|
||||
{
|
||||
polychrome->SetMode(mode);
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::SetCustomMode()
|
||||
{
|
||||
polychrome->SetMode(POLYCHROME_MODE_STATIC);
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::UpdateLEDs()
|
||||
{
|
||||
for (std::size_t led = 0; led < colors.size(); led++)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[led]);
|
||||
unsigned char grn = RGBGetGValue(colors[led]);
|
||||
unsigned char blu = RGBGetBValue(colors[led]);
|
||||
|
||||
polychrome->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
static const char* polychrome_zone_names[] =
|
||||
{
|
||||
"Motherboard"
|
||||
};
|
||||
|
||||
RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychrome_ptr)
|
||||
{
|
||||
polychrome = polychrome_ptr;
|
||||
|
||||
name = polychrome->GetDeviceName();
|
||||
|
||||
mode polychrome_modes[POLYCHROME_NUM_MODES];
|
||||
|
||||
polychrome_modes[0].name = "Static";
|
||||
polychrome_modes[1].name = "Breathing";
|
||||
polychrome_modes[2].name = "Flashing";
|
||||
|
||||
for (int i = 0; i < POLYCHROME_NUM_MODES; i++)
|
||||
{
|
||||
modes.push_back(polychrome_modes[i]);
|
||||
}
|
||||
|
||||
// Search through all LEDs and create zones for each channel type
|
||||
for (unsigned int i = 0; i < polychrome->GetLEDCount(); i++)
|
||||
{
|
||||
zone* new_zone = new zone();
|
||||
led* new_led = new led();
|
||||
|
||||
std::vector<int>* zone_row = new std::vector<int>();
|
||||
|
||||
// Set zone name to channel name
|
||||
new_zone->name = polychrome_zone_names[i];
|
||||
new_led->name = polychrome_zone_names[i];
|
||||
|
||||
zone_row->push_back(i);
|
||||
|
||||
// Aura devices can be either single or linear, never matrix
|
||||
// That means only one row is needed
|
||||
new_zone->map.push_back(*zone_row);
|
||||
|
||||
// Push new LED to LEDs vector
|
||||
leds.push_back(*new_led);
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
// Push new zone to zones vector
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Polychrome.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| ASRock ASR LED and Polychrome RGB Driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/15/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "PolychromeController.h"
|
||||
|
||||
class RGBController_Polychrome : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Polychrome(PolychromeController* polychrome_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
private:
|
||||
PolychromeController* polychrome;
|
||||
};
|
||||
@@ -0,0 +1,107 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_RGBFusion.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| Gigabyte RGB Fusion Driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/11/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_RGBFusion.h"
|
||||
|
||||
int RGBController_RGBFusion::GetMode()
|
||||
{
|
||||
return(rgb_fusion->GetMode());
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::SetMode(int mode)
|
||||
{
|
||||
rgb_fusion->SetMode(mode);
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::SetCustomMode()
|
||||
{
|
||||
rgb_fusion->SetMode(RGB_FUSION_MODE_STATIC);
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::UpdateLEDs()
|
||||
{
|
||||
for (std::size_t led = 0; led < colors.size(); led++)
|
||||
{
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
rgb_fusion->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
RGBColor color = colors[zone];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
rgb_fusion->SetLEDColor(zone, red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateZoneLEDs(led);
|
||||
}
|
||||
|
||||
static const char* rgb_fusion_zone_names[] =
|
||||
{
|
||||
"Motherboard",
|
||||
"RGB Header"
|
||||
};
|
||||
|
||||
RGBController_RGBFusion::RGBController_RGBFusion(RGBFusionController* rgb_fusion_ptr)
|
||||
{
|
||||
rgb_fusion = rgb_fusion_ptr;
|
||||
|
||||
name = rgb_fusion->GetDeviceName();
|
||||
description = "RGB Fusion 1.0";
|
||||
location = rgb_fusion->GetDeviceLocation();
|
||||
|
||||
type = DEVICE_TYPE_MOTHERBOARD;
|
||||
|
||||
mode rgb_fusion_modes[RGB_FUSION_NUMBER_MODES];
|
||||
|
||||
rgb_fusion_modes[0].name = "Static";
|
||||
rgb_fusion_modes[1].name = "Breathing";
|
||||
rgb_fusion_modes[2].name = "Flashing";
|
||||
|
||||
for (int i = 0; i < RGB_FUSION_NUMBER_MODES; i++)
|
||||
{
|
||||
modes.push_back(rgb_fusion_modes[i]);
|
||||
}
|
||||
|
||||
// Search through all LEDs and create zones for each channel type
|
||||
for (unsigned int i = 0; i < rgb_fusion->GetLEDCount(); i++)
|
||||
{
|
||||
zone* new_zone = new zone();
|
||||
led* new_led = new led();
|
||||
|
||||
std::vector<int>* zone_row = new std::vector<int>();
|
||||
|
||||
// Set zone name to channel name
|
||||
new_zone->name = rgb_fusion_zone_names[i];
|
||||
new_led->name = rgb_fusion_zone_names[i];
|
||||
|
||||
zone_row->push_back(i);
|
||||
|
||||
// Aura devices can be either single or linear, never matrix
|
||||
// That means only one row is needed
|
||||
new_zone->map.push_back(*zone_row);
|
||||
|
||||
// Push new LED to LEDs vector
|
||||
leds.push_back(*new_led);
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
// Push new zone to zones vector
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_RGBFusion.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| Gigabyte RGB Fusion Driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/11/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "RGBFusionController.h"
|
||||
|
||||
class RGBController_RGBFusion : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_RGBFusion(RGBFusionController* rgb_fusion_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
private:
|
||||
RGBFusionController* rgb_fusion;
|
||||
};
|
||||
@@ -22,9 +22,11 @@ RGBController_RazerChromaSDK::RGBController_RazerChromaSDK(unsigned int device_t
|
||||
|
||||
for (int i = 0; i < RAZER_NUM_DEVICES; i++)
|
||||
{
|
||||
if (device_list[i]->type == device_type)
|
||||
if (device_list[i]->razer_type == device_type)
|
||||
{
|
||||
name = device_list[i]->name;
|
||||
type = device_list[i]->type;
|
||||
location = "Razer Chroma SDK";
|
||||
|
||||
for (int zone_id = 0; zone_id < RAZER_MAX_ZONES; zone_id++)
|
||||
{
|
||||
@@ -83,39 +85,9 @@ void RGBController_RazerChromaSDK::SetCustomMode()
|
||||
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
colors[zones[zone].map[x][y]] = color;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::SetLED(int led, RGBColor color)
|
||||
{
|
||||
colors[led] = color;
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::UpdateLEDs()
|
||||
{
|
||||
switch (device->type)
|
||||
switch (device->razer_type)
|
||||
{
|
||||
case RAZER_GENERIC_MOUSE:
|
||||
{
|
||||
@@ -186,4 +158,14 @@ void RGBController_RazerChromaSDK::UpdateLEDs()
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
std::string name;
|
||||
unsigned int razer_type;
|
||||
unsigned int type;
|
||||
const razer_zone* zones[RAZER_MAX_ZONES];
|
||||
} razer_device;
|
||||
@@ -136,6 +137,7 @@ static const razer_device mouse_device =
|
||||
{
|
||||
"Razer Generic Mouse",
|
||||
RAZER_GENERIC_MOUSE,
|
||||
DEVICE_TYPE_MOUSE,
|
||||
{
|
||||
&mouse_left_zone,
|
||||
&mouse_right_zone,
|
||||
@@ -164,6 +166,7 @@ static const razer_device mousepad_device =
|
||||
{
|
||||
"Razer Generic Mousepad",
|
||||
RAZER_GENERIC_MOUSEPAD,
|
||||
DEVICE_TYPE_MOUSE,
|
||||
{
|
||||
&mousepad_zone,
|
||||
NULL,
|
||||
@@ -204,6 +207,7 @@ static const razer_device chromahdk_device =
|
||||
{
|
||||
"Razer Chroma HDK",
|
||||
RAZER_CHROMA_HDK,
|
||||
DEVICE_TYPE_LEDSTRIP,
|
||||
{
|
||||
&chromahdk_zone,
|
||||
&chromahdk_zone,
|
||||
@@ -225,13 +229,12 @@ class RGBController_RazerChromaSDK : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_RazerChromaSDK(unsigned int device_type, HMODULE* hModule);
|
||||
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();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
private:
|
||||
const razer_device* device;
|
||||
@@ -242,4 +245,4 @@ private:
|
||||
static CREATEMOUSEPADEFFECT CreateMousepadEffect;
|
||||
static CREATEHEADSETEFFECT CreateHeadsetEffect;
|
||||
static CREATECHROMALINKEFFECT CreateChromaLinkEffect;
|
||||
};
|
||||
};
|
||||
|
||||
Vendored
+1
-1
Submodule dependencies/libe131 updated: 0fc009f1f6...930956795a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+61
@@ -0,0 +1,61 @@
|
||||
libusb 1.0 Windows binary snapshot - README
|
||||
|
||||
*********************************************************************
|
||||
* The latest version of this snapshot can always be downloaded at: *
|
||||
* https://sourceforge.net/projects/libusb/files/ *
|
||||
*********************************************************************
|
||||
|
||||
o Visual Studio:
|
||||
- Open existing or create a new project for your application
|
||||
- Copy libusb.h, from the include\libusb-1.0\ directory, into your project and
|
||||
make sure that the location where the file reside appears in the 'Additional
|
||||
Include Directories' section (Configuration Properties -> C/C++ -> General).
|
||||
- Copy the relevant .lib file from MS32\ or MS64\ and add 'libusb-1.0.lib' to
|
||||
your 'Additional Dependencies' (Configuration Properties -> Linker -> Input)
|
||||
Also make sure that the directory where libusb-1.0.lib resides is added to
|
||||
'Additional Library Directories' (Configuration Properties -> Linker
|
||||
-> General)
|
||||
- If you use the static version of the libusb library, make sure that
|
||||
'Runtime Library' is set to 'Multi-threaded DLL (/MD)' (Configuration
|
||||
Properties -> C/C++ -> Code Generation).
|
||||
NB: If your application requires /MT (Multi-threaded/libCMT), you need to
|
||||
recompile a static libusb 1.0 library from source.
|
||||
- Compile and run your application. If you use the DLL version of libusb-1.0,
|
||||
remember that you need to have a copy of the DLL either in the runtime
|
||||
directory or in system32
|
||||
|
||||
o WDK/DDK:
|
||||
- The following is an example of a sources files that you can use to compile
|
||||
a libusb 1.0 based console application. In this sample ..\libusb\ is the
|
||||
directory where you would have copied libusb.h as well as the relevant
|
||||
libusb-1.0.lib
|
||||
|
||||
TARGETNAME=your_app
|
||||
TARGETTYPE=PROGRAM
|
||||
USE_MSVCRT=1
|
||||
UMTYPE=console
|
||||
INCLUDES=..\libusb;$(DDK_INC_PATH)
|
||||
TARGETLIBS=..\libusb\libusb-1.0.lib
|
||||
SOURCES=your_app.c
|
||||
|
||||
- Note that if you plan to use libCMT instead of MSVCRT (USE_LIBCMT=1 instead
|
||||
of USE_MSVCRT=1), you will need to recompile libusb to use libCMT. This can
|
||||
easily be achieved, in the DDK environment, by running 'ddk_build /MT'
|
||||
|
||||
o MinGW/cygwin
|
||||
- Copy libusb.h, from include/libusb-1.0/ to your default include directory,
|
||||
and copy the MinGW32/ or MinGW64/ .a files to your default library directory.
|
||||
Or, if you don't want to use the default locations, make sure that you feed
|
||||
the relevant -I and -L options to the compiler.
|
||||
- Add the '-lusb-1.0' linker option when compiling.
|
||||
|
||||
o Additional information:
|
||||
- The libusb 1.0 API documentation can be accessed at:
|
||||
http://api.libusb.info
|
||||
- For some libusb samples (including source), please have a look in examples/
|
||||
- For additional information on the libusb 1.0 Windows backend please visit:
|
||||
http://windows.libusb.info
|
||||
- The MinGW and MS generated DLLs are fully interchangeable, provided that you
|
||||
use the import libs provided or generate one from the .def also provided.
|
||||
- If you find any issue, please visit http://libusb.info/ and check the
|
||||
Support section
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+831
@@ -0,0 +1,831 @@
|
||||
/*
|
||||
* Copyright © 2001 Stephen Williams ([email protected])
|
||||
* Copyright © 2001-2002 David Brownell ([email protected])
|
||||
* Copyright © 2008 Roger Williams ([email protected])
|
||||
* Copyright © 2012 Pete Batard ([email protected])
|
||||
* Copyright © 2013 Federico Manzan ([email protected])
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
* General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libusb.h"
|
||||
#include "ezusb.h"
|
||||
|
||||
extern void logerror(const char *format, ...)
|
||||
__attribute__ ((format(printf, 1, 2)));
|
||||
|
||||
/*
|
||||
* This file contains functions for uploading firmware into Cypress
|
||||
* EZ-USB microcontrollers. These chips use control endpoint 0 and vendor
|
||||
* specific commands to support writing into the on-chip SRAM. They also
|
||||
* support writing into the CPUCS register, which is how we reset the
|
||||
* processor after loading firmware (including the reset vector).
|
||||
*
|
||||
* These Cypress devices are 8-bit 8051 based microcontrollers with
|
||||
* special support for USB I/O. They come in several packages, and
|
||||
* some can be set up with external memory when device costs allow.
|
||||
* Note that the design was originally by AnchorChips, so you may find
|
||||
* references to that vendor (which was later merged into Cypress).
|
||||
* The Cypress FX parts are largely compatible with the Anchorhip ones.
|
||||
*/
|
||||
|
||||
int verbose = 1;
|
||||
|
||||
/*
|
||||
* return true if [addr,addr+len] includes external RAM
|
||||
* for Anchorchips EZ-USB or Cypress EZ-USB FX
|
||||
*/
|
||||
static bool fx_is_external(uint32_t addr, size_t len)
|
||||
{
|
||||
/* with 8KB RAM, 0x0000-0x1b3f can be written
|
||||
* we can't tell if it's a 4KB device here
|
||||
*/
|
||||
if (addr <= 0x1b3f)
|
||||
return ((addr + len) > 0x1b40);
|
||||
|
||||
/* there may be more RAM; unclear if we can write it.
|
||||
* some bulk buffers may be unused, 0x1b3f-0x1f3f
|
||||
* firmware can set ISODISAB for 2KB at 0x2000-0x27ff
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* return true if [addr,addr+len] includes external RAM
|
||||
* for Cypress EZ-USB FX2
|
||||
*/
|
||||
static bool fx2_is_external(uint32_t addr, size_t len)
|
||||
{
|
||||
/* 1st 8KB for data/code, 0x0000-0x1fff */
|
||||
if (addr <= 0x1fff)
|
||||
return ((addr + len) > 0x2000);
|
||||
|
||||
/* and 512 for data, 0xe000-0xe1ff */
|
||||
else if (addr >= 0xe000 && addr <= 0xe1ff)
|
||||
return ((addr + len) > 0xe200);
|
||||
|
||||
/* otherwise, it's certainly external */
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* return true if [addr,addr+len] includes external RAM
|
||||
* for Cypress EZ-USB FX2LP
|
||||
*/
|
||||
static bool fx2lp_is_external(uint32_t addr, size_t len)
|
||||
{
|
||||
/* 1st 16KB for data/code, 0x0000-0x3fff */
|
||||
if (addr <= 0x3fff)
|
||||
return ((addr + len) > 0x4000);
|
||||
|
||||
/* and 512 for data, 0xe000-0xe1ff */
|
||||
else if (addr >= 0xe000 && addr <= 0xe1ff)
|
||||
return ((addr + len) > 0xe200);
|
||||
|
||||
/* otherwise, it's certainly external */
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
* These are the requests (bRequest) that the bootstrap loader is expected
|
||||
* to recognize. The codes are reserved by Cypress, and these values match
|
||||
* what EZ-USB hardware, or "Vend_Ax" firmware (2nd stage loader) uses.
|
||||
* Cypress' "a3load" is nice because it supports both FX and FX2, although
|
||||
* it doesn't have the EEPROM support (subset of "Vend_Ax").
|
||||
*/
|
||||
#define RW_INTERNAL 0xA0 /* hardware implements this one */
|
||||
#define RW_MEMORY 0xA3
|
||||
|
||||
/*
|
||||
* Issues the specified vendor-specific write request.
|
||||
*/
|
||||
static int ezusb_write(libusb_device_handle *device, const char *label,
|
||||
uint8_t opcode, uint32_t addr, const unsigned char *data, size_t len)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (verbose > 1)
|
||||
logerror("%s, addr 0x%08x len %4u (0x%04x)\n", label, addr, (unsigned)len, (unsigned)len);
|
||||
status = libusb_control_transfer(device,
|
||||
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
|
||||
opcode, addr & 0xFFFF, addr >> 16,
|
||||
(unsigned char*)data, (uint16_t)len, 1000);
|
||||
if (status != (signed)len) {
|
||||
if (status < 0)
|
||||
logerror("%s: %s\n", label, libusb_error_name(status));
|
||||
else
|
||||
logerror("%s ==> %d\n", label, status);
|
||||
}
|
||||
return (status < 0) ? -EIO : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Issues the specified vendor-specific read request.
|
||||
*/
|
||||
static int ezusb_read(libusb_device_handle *device, const char *label,
|
||||
uint8_t opcode, uint32_t addr, const unsigned char *data, size_t len)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (verbose > 1)
|
||||
logerror("%s, addr 0x%08x len %4u (0x%04x)\n", label, addr, (unsigned)len, (unsigned)len);
|
||||
status = libusb_control_transfer(device,
|
||||
LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
|
||||
opcode, addr & 0xFFFF, addr >> 16,
|
||||
(unsigned char*)data, (uint16_t)len, 1000);
|
||||
if (status != (signed)len) {
|
||||
if (status < 0)
|
||||
logerror("%s: %s\n", label, libusb_error_name(status));
|
||||
else
|
||||
logerror("%s ==> %d\n", label, status);
|
||||
}
|
||||
return (status < 0) ? -EIO : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Modifies the CPUCS register to stop or reset the CPU.
|
||||
* Returns false on error.
|
||||
*/
|
||||
static bool ezusb_cpucs(libusb_device_handle *device, uint32_t addr, bool doRun)
|
||||
{
|
||||
int status;
|
||||
uint8_t data = doRun ? 0x00 : 0x01;
|
||||
|
||||
if (verbose)
|
||||
logerror("%s\n", data ? "stop CPU" : "reset CPU");
|
||||
status = libusb_control_transfer(device,
|
||||
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
|
||||
RW_INTERNAL, addr & 0xFFFF, addr >> 16,
|
||||
&data, 1, 1000);
|
||||
if ((status != 1) &&
|
||||
/* We may get an I/O error from libusb as the device disappears */
|
||||
((!doRun) || (status != LIBUSB_ERROR_IO)))
|
||||
{
|
||||
const char *mesg = "can't modify CPUCS";
|
||||
if (status < 0)
|
||||
logerror("%s: %s\n", mesg, libusb_error_name(status));
|
||||
else
|
||||
logerror("%s\n", mesg);
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Send an FX3 jumpt to address command
|
||||
* Returns false on error.
|
||||
*/
|
||||
static bool ezusb_fx3_jump(libusb_device_handle *device, uint32_t addr)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (verbose)
|
||||
logerror("transfer execution to Program Entry at 0x%08x\n", addr);
|
||||
status = libusb_control_transfer(device,
|
||||
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
|
||||
RW_INTERNAL, addr & 0xFFFF, addr >> 16,
|
||||
NULL, 0, 1000);
|
||||
/* We may get an I/O error from libusb as the device disappears */
|
||||
if ((status != 0) && (status != LIBUSB_ERROR_IO))
|
||||
{
|
||||
const char *mesg = "failed to send jump command";
|
||||
if (status < 0)
|
||||
logerror("%s: %s\n", mesg, libusb_error_name(status));
|
||||
else
|
||||
logerror("%s\n", mesg);
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
* Parse an Intel HEX image file and invoke the poke() function on the
|
||||
* various segments to implement policies such as writing to RAM (with
|
||||
* a one or two stage loader setup, depending on the firmware) or to
|
||||
* EEPROM (two stages required).
|
||||
*
|
||||
* image - the hex image file
|
||||
* context - for use by poke()
|
||||
* is_external - if non-null, used to check which segments go into
|
||||
* external memory (writable only by software loader)
|
||||
* poke - called with each memory segment; errors indicated
|
||||
* by returning negative values.
|
||||
*
|
||||
* Caller is responsible for halting CPU as needed, such as when
|
||||
* overwriting a second stage loader.
|
||||
*/
|
||||
static int parse_ihex(FILE *image, void *context,
|
||||
bool (*is_external)(uint32_t addr, size_t len),
|
||||
int (*poke) (void *context, uint32_t addr, bool external,
|
||||
const unsigned char *data, size_t len))
|
||||
{
|
||||
unsigned char data[1023];
|
||||
uint32_t data_addr = 0;
|
||||
size_t data_len = 0;
|
||||
int rc;
|
||||
int first_line = 1;
|
||||
bool external = false;
|
||||
|
||||
/* Read the input file as an IHEX file, and report the memory segments
|
||||
* as we go. Each line holds a max of 16 bytes, but uploading is
|
||||
* faster (and EEPROM space smaller) if we merge those lines into larger
|
||||
* chunks. Most hex files keep memory segments together, which makes
|
||||
* such merging all but free. (But it may still be worth sorting the
|
||||
* hex files to make up for undesirable behavior from tools.)
|
||||
*
|
||||
* Note that EEPROM segments max out at 1023 bytes; the upload protocol
|
||||
* allows segments of up to 64 KBytes (more than a loader could handle).
|
||||
*/
|
||||
for (;;) {
|
||||
char buf[512], *cp;
|
||||
char tmp, type;
|
||||
size_t len;
|
||||
unsigned idx, off;
|
||||
|
||||
cp = fgets(buf, sizeof(buf), image);
|
||||
if (cp == NULL) {
|
||||
logerror("EOF without EOF record!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* EXTENSION: "# comment-till-end-of-line", for copyrights etc */
|
||||
if (buf[0] == '#')
|
||||
continue;
|
||||
|
||||
if (buf[0] != ':') {
|
||||
logerror("not an ihex record: %s", buf);
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* ignore any newline */
|
||||
cp = strchr(buf, '\n');
|
||||
if (cp)
|
||||
*cp = 0;
|
||||
|
||||
if (verbose >= 3)
|
||||
logerror("** LINE: %s\n", buf);
|
||||
|
||||
/* Read the length field (up to 16 bytes) */
|
||||
tmp = buf[3];
|
||||
buf[3] = 0;
|
||||
len = strtoul(buf+1, NULL, 16);
|
||||
buf[3] = tmp;
|
||||
|
||||
/* Read the target offset (address up to 64KB) */
|
||||
tmp = buf[7];
|
||||
buf[7] = 0;
|
||||
off = (int)strtoul(buf+3, NULL, 16);
|
||||
buf[7] = tmp;
|
||||
|
||||
/* Initialize data_addr */
|
||||
if (first_line) {
|
||||
data_addr = off;
|
||||
first_line = 0;
|
||||
}
|
||||
|
||||
/* Read the record type */
|
||||
tmp = buf[9];
|
||||
buf[9] = 0;
|
||||
type = (char)strtoul(buf+7, NULL, 16);
|
||||
buf[9] = tmp;
|
||||
|
||||
/* If this is an EOF record, then make it so. */
|
||||
if (type == 1) {
|
||||
if (verbose >= 2)
|
||||
logerror("EOF on hexfile\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (type != 0) {
|
||||
logerror("unsupported record type: %u\n", type);
|
||||
return -3;
|
||||
}
|
||||
|
||||
if ((len * 2) + 11 > strlen(buf)) {
|
||||
logerror("record too short?\n");
|
||||
return -4;
|
||||
}
|
||||
|
||||
/* FIXME check for _physically_ contiguous not just virtually
|
||||
* e.g. on FX2 0x1f00-0x2100 includes both on-chip and external
|
||||
* memory so it's not really contiguous */
|
||||
|
||||
/* flush the saved data if it's not contiguous,
|
||||
* or when we've buffered as much as we can.
|
||||
*/
|
||||
if (data_len != 0
|
||||
&& (off != (data_addr + data_len)
|
||||
/* || !merge */
|
||||
|| (data_len + len) > sizeof(data))) {
|
||||
if (is_external)
|
||||
external = is_external(data_addr, data_len);
|
||||
rc = poke(context, data_addr, external, data, data_len);
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
data_addr = off;
|
||||
data_len = 0;
|
||||
}
|
||||
|
||||
/* append to saved data, flush later */
|
||||
for (idx = 0, cp = buf+9 ; idx < len ; idx += 1, cp += 2) {
|
||||
tmp = cp[2];
|
||||
cp[2] = 0;
|
||||
data[data_len + idx] = (uint8_t)strtoul(cp, NULL, 16);
|
||||
cp[2] = tmp;
|
||||
}
|
||||
data_len += len;
|
||||
}
|
||||
|
||||
|
||||
/* flush any data remaining */
|
||||
if (data_len != 0) {
|
||||
if (is_external)
|
||||
external = is_external(data_addr, data_len);
|
||||
rc = poke(context, data_addr, external, data, data_len);
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse a binary image file and write it as is to the target.
|
||||
* Applies to Cypress BIX images for RAM or Cypress IIC images
|
||||
* for EEPROM.
|
||||
*
|
||||
* image - the BIX image file
|
||||
* context - for use by poke()
|
||||
* is_external - if non-null, used to check which segments go into
|
||||
* external memory (writable only by software loader)
|
||||
* poke - called with each memory segment; errors indicated
|
||||
* by returning negative values.
|
||||
*
|
||||
* Caller is responsible for halting CPU as needed, such as when
|
||||
* overwriting a second stage loader.
|
||||
*/
|
||||
static int parse_bin(FILE *image, void *context,
|
||||
bool (*is_external)(uint32_t addr, size_t len), int (*poke)(void *context,
|
||||
uint32_t addr, bool external, const unsigned char *data, size_t len))
|
||||
{
|
||||
unsigned char data[4096];
|
||||
uint32_t data_addr = 0;
|
||||
size_t data_len = 0;
|
||||
int rc;
|
||||
bool external = false;
|
||||
|
||||
for (;;) {
|
||||
data_len = fread(data, 1, 4096, image);
|
||||
if (data_len == 0)
|
||||
break;
|
||||
if (is_external)
|
||||
external = is_external(data_addr, data_len);
|
||||
rc = poke(context, data_addr, external, data, data_len);
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
data_addr += (uint32_t)data_len;
|
||||
}
|
||||
return feof(image)?0:-1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse a Cypress IIC image file and invoke the poke() function on the
|
||||
* various segments for writing to RAM
|
||||
*
|
||||
* image - the IIC image file
|
||||
* context - for use by poke()
|
||||
* is_external - if non-null, used to check which segments go into
|
||||
* external memory (writable only by software loader)
|
||||
* poke - called with each memory segment; errors indicated
|
||||
* by returning negative values.
|
||||
*
|
||||
* Caller is responsible for halting CPU as needed, such as when
|
||||
* overwriting a second stage loader.
|
||||
*/
|
||||
static int parse_iic(FILE *image, void *context,
|
||||
bool (*is_external)(uint32_t addr, size_t len),
|
||||
int (*poke)(void *context, uint32_t addr, bool external, const unsigned char *data, size_t len))
|
||||
{
|
||||
unsigned char data[4096];
|
||||
uint32_t data_addr = 0;
|
||||
size_t data_len = 0, read_len;
|
||||
uint8_t block_header[4];
|
||||
int rc;
|
||||
bool external = false;
|
||||
long file_size, initial_pos;
|
||||
|
||||
initial_pos = ftell(image);
|
||||
if (initial_pos < 0)
|
||||
return -1;
|
||||
|
||||
if (fseek(image, 0L, SEEK_END) != 0)
|
||||
return -1;
|
||||
file_size = ftell(image);
|
||||
if (fseek(image, initial_pos, SEEK_SET) != 0)
|
||||
return -1;
|
||||
for (;;) {
|
||||
/* Ignore the trailing reset IIC data (5 bytes) */
|
||||
if (ftell(image) >= (file_size - 5))
|
||||
break;
|
||||
if (fread(&block_header, 1, sizeof(block_header), image) != 4) {
|
||||
logerror("unable to read IIC block header\n");
|
||||
return -1;
|
||||
}
|
||||
data_len = (block_header[0] << 8) + block_header[1];
|
||||
data_addr = (block_header[2] << 8) + block_header[3];
|
||||
if (data_len > sizeof(data)) {
|
||||
/* If this is ever reported as an error, switch to using malloc/realloc */
|
||||
logerror("IIC data block too small - please report this error to libusb.info\n");
|
||||
return -1;
|
||||
}
|
||||
read_len = fread(data, 1, data_len, image);
|
||||
if (read_len != data_len) {
|
||||
logerror("read error\n");
|
||||
return -1;
|
||||
}
|
||||
if (is_external)
|
||||
external = is_external(data_addr, data_len);
|
||||
rc = poke(context, data_addr, external, data, data_len);
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* the parse call will be selected according to the image type */
|
||||
static int (*parse[IMG_TYPE_MAX])(FILE *image, void *context, bool (*is_external)(uint32_t addr, size_t len),
|
||||
int (*poke)(void *context, uint32_t addr, bool external, const unsigned char *data, size_t len))
|
||||
= { parse_ihex, parse_iic, parse_bin };
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
* For writing to RAM using a first (hardware) or second (software)
|
||||
* stage loader and 0xA0 or 0xA3 vendor requests
|
||||
*/
|
||||
typedef enum {
|
||||
_undef = 0,
|
||||
internal_only, /* hardware first-stage loader */
|
||||
skip_internal, /* first phase, second-stage loader */
|
||||
skip_external /* second phase, second-stage loader */
|
||||
} ram_mode;
|
||||
|
||||
struct ram_poke_context {
|
||||
libusb_device_handle *device;
|
||||
ram_mode mode;
|
||||
size_t total, count;
|
||||
};
|
||||
|
||||
#define RETRY_LIMIT 5
|
||||
|
||||
static int ram_poke(void *context, uint32_t addr, bool external,
|
||||
const unsigned char *data, size_t len)
|
||||
{
|
||||
struct ram_poke_context *ctx = (struct ram_poke_context*)context;
|
||||
int rc;
|
||||
unsigned retry = 0;
|
||||
|
||||
switch (ctx->mode) {
|
||||
case internal_only: /* CPU should be stopped */
|
||||
if (external) {
|
||||
logerror("can't write %u bytes external memory at 0x%08x\n",
|
||||
(unsigned)len, addr);
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
case skip_internal: /* CPU must be running */
|
||||
if (!external) {
|
||||
if (verbose >= 2) {
|
||||
logerror("SKIP on-chip RAM, %u bytes at 0x%08x\n",
|
||||
(unsigned)len, addr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case skip_external: /* CPU should be stopped */
|
||||
if (external) {
|
||||
if (verbose >= 2) {
|
||||
logerror("SKIP external RAM, %u bytes at 0x%08x\n",
|
||||
(unsigned)len, addr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case _undef:
|
||||
default:
|
||||
logerror("bug\n");
|
||||
return -EDOM;
|
||||
}
|
||||
|
||||
ctx->total += len;
|
||||
ctx->count++;
|
||||
|
||||
/* Retry this till we get a real error. Control messages are not
|
||||
* NAKed (just dropped) so time out means is a real problem.
|
||||
*/
|
||||
while ((rc = ezusb_write(ctx->device,
|
||||
external ? "write external" : "write on-chip",
|
||||
external ? RW_MEMORY : RW_INTERNAL,
|
||||
addr, data, len)) < 0
|
||||
&& retry < RETRY_LIMIT) {
|
||||
if (rc != LIBUSB_ERROR_TIMEOUT)
|
||||
break;
|
||||
retry += 1;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Load a Cypress Image file into target RAM.
|
||||
* See http://www.cypress.com/?docID=41351 (AN76405 PDF) for more info.
|
||||
*/
|
||||
static int fx3_load_ram(libusb_device_handle *device, const char *path)
|
||||
{
|
||||
uint32_t dCheckSum, dExpectedCheckSum, dAddress, i, dLen, dLength;
|
||||
uint32_t* dImageBuf;
|
||||
unsigned char *bBuf, hBuf[4], blBuf[4], rBuf[4096];
|
||||
FILE *image;
|
||||
int ret = 0;
|
||||
|
||||
image = fopen(path, "rb");
|
||||
if (image == NULL) {
|
||||
logerror("unable to open '%s' for input\n", path);
|
||||
return -2;
|
||||
} else if (verbose)
|
||||
logerror("open firmware image %s for RAM upload\n", path);
|
||||
|
||||
// Read header
|
||||
if (fread(hBuf, sizeof(char), sizeof(hBuf), image) != sizeof(hBuf)) {
|
||||
logerror("could not read image header");
|
||||
ret = -3;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
// check "CY" signature byte and format
|
||||
if ((hBuf[0] != 'C') || (hBuf[1] != 'Y')) {
|
||||
logerror("image doesn't have a CYpress signature\n");
|
||||
ret = -3;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
// Check bImageType
|
||||
switch(hBuf[3]) {
|
||||
case 0xB0:
|
||||
if (verbose)
|
||||
logerror("normal FW binary %s image with checksum\n", (hBuf[2]&0x01)?"data":"executable");
|
||||
break;
|
||||
case 0xB1:
|
||||
logerror("security binary image is not currently supported\n");
|
||||
ret = -3;
|
||||
goto exit;
|
||||
case 0xB2:
|
||||
logerror("VID:PID image is not currently supported\n");
|
||||
ret = -3;
|
||||
goto exit;
|
||||
default:
|
||||
logerror("invalid image type 0x%02X\n", hBuf[3]);
|
||||
ret = -3;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
// Read the bootloader version
|
||||
if (verbose) {
|
||||
if ((ezusb_read(device, "read bootloader version", RW_INTERNAL, 0xFFFF0020, blBuf, 4) < 0)) {
|
||||
logerror("Could not read bootloader version\n");
|
||||
ret = -8;
|
||||
goto exit;
|
||||
}
|
||||
logerror("FX3 bootloader version: 0x%02X%02X%02X%02X\n", blBuf[3], blBuf[2], blBuf[1], blBuf[0]);
|
||||
}
|
||||
|
||||
dCheckSum = 0;
|
||||
if (verbose)
|
||||
logerror("writing image...\n");
|
||||
while (1) {
|
||||
if ((fread(&dLength, sizeof(uint32_t), 1, image) != 1) || // read dLength
|
||||
(fread(&dAddress, sizeof(uint32_t), 1, image) != 1)) { // read dAddress
|
||||
logerror("could not read image");
|
||||
ret = -3;
|
||||
goto exit;
|
||||
}
|
||||
if (dLength == 0)
|
||||
break; // done
|
||||
|
||||
// coverity[tainted_data]
|
||||
dImageBuf = (uint32_t*)calloc(dLength, sizeof(uint32_t));
|
||||
if (dImageBuf == NULL) {
|
||||
logerror("could not allocate buffer for image chunk\n");
|
||||
ret = -4;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
// read sections
|
||||
if (fread(dImageBuf, sizeof(uint32_t), dLength, image) != dLength) {
|
||||
logerror("could not read image");
|
||||
free(dImageBuf);
|
||||
ret = -3;
|
||||
goto exit;
|
||||
}
|
||||
for (i = 0; i < dLength; i++)
|
||||
dCheckSum += dImageBuf[i];
|
||||
dLength <<= 2; // convert to Byte length
|
||||
bBuf = (unsigned char*) dImageBuf;
|
||||
|
||||
while (dLength > 0) {
|
||||
dLen = 4096; // 4K max
|
||||
if (dLen > dLength)
|
||||
dLen = dLength;
|
||||
if ((ezusb_write(device, "write firmware", RW_INTERNAL, dAddress, bBuf, dLen) < 0) ||
|
||||
(ezusb_read(device, "read firmware", RW_INTERNAL, dAddress, rBuf, dLen) < 0)) {
|
||||
logerror("R/W error\n");
|
||||
free(dImageBuf);
|
||||
ret = -5;
|
||||
goto exit;
|
||||
}
|
||||
// Verify data: rBuf with bBuf
|
||||
for (i = 0; i < dLen; i++) {
|
||||
if (rBuf[i] != bBuf[i]) {
|
||||
logerror("verify error");
|
||||
free(dImageBuf);
|
||||
ret = -6;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
dLength -= dLen;
|
||||
bBuf += dLen;
|
||||
dAddress += dLen;
|
||||
}
|
||||
free(dImageBuf);
|
||||
}
|
||||
|
||||
// read pre-computed checksum data
|
||||
if ((fread(&dExpectedCheckSum, sizeof(uint32_t), 1, image) != 1) ||
|
||||
(dCheckSum != dExpectedCheckSum)) {
|
||||
logerror("checksum error\n");
|
||||
ret = -7;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
// transfer execution to Program Entry
|
||||
if (!ezusb_fx3_jump(device, dAddress)) {
|
||||
ret = -6;
|
||||
}
|
||||
|
||||
exit:
|
||||
fclose(image);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Load a firmware file into target RAM. device is the open libusb
|
||||
* device, and the path is the name of the source file. Open the file,
|
||||
* parse the bytes, and write them in one or two phases.
|
||||
*
|
||||
* If stage == 0, this uses the first stage loader, built into EZ-USB
|
||||
* hardware but limited to writing on-chip memory or CPUCS. Everything
|
||||
* is written during one stage, unless there's an error such as the image
|
||||
* holding data that needs to be written to external memory.
|
||||
*
|
||||
* Otherwise, things are written in two stages. First the external
|
||||
* memory is written, expecting a second stage loader to have already
|
||||
* been loaded. Then file is re-parsed and on-chip memory is written.
|
||||
*/
|
||||
int ezusb_load_ram(libusb_device_handle *device, const char *path, int fx_type, int img_type, int stage)
|
||||
{
|
||||
FILE *image;
|
||||
uint32_t cpucs_addr;
|
||||
bool (*is_external)(uint32_t off, size_t len);
|
||||
struct ram_poke_context ctx;
|
||||
int status;
|
||||
uint8_t iic_header[8] = { 0 };
|
||||
int ret = 0;
|
||||
|
||||
if (fx_type == FX_TYPE_FX3)
|
||||
return fx3_load_ram(device, path);
|
||||
|
||||
image = fopen(path, "rb");
|
||||
if (image == NULL) {
|
||||
logerror("%s: unable to open for input.\n", path);
|
||||
return -2;
|
||||
} else if (verbose > 1)
|
||||
logerror("open firmware image %s for RAM upload\n", path);
|
||||
|
||||
if (img_type == IMG_TYPE_IIC) {
|
||||
if ( (fread(iic_header, 1, sizeof(iic_header), image) != sizeof(iic_header))
|
||||
|| (((fx_type == FX_TYPE_FX2LP) || (fx_type == FX_TYPE_FX2)) && (iic_header[0] != 0xC2))
|
||||
|| ((fx_type == FX_TYPE_AN21) && (iic_header[0] != 0xB2))
|
||||
|| ((fx_type == FX_TYPE_FX1) && (iic_header[0] != 0xB6)) ) {
|
||||
logerror("IIC image does not contain executable code - cannot load to RAM.\n");
|
||||
ret = -1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* EZ-USB original/FX and FX2 devices differ, apart from the 8051 core */
|
||||
switch(fx_type) {
|
||||
case FX_TYPE_FX2LP:
|
||||
cpucs_addr = 0xe600;
|
||||
is_external = fx2lp_is_external;
|
||||
break;
|
||||
case FX_TYPE_FX2:
|
||||
cpucs_addr = 0xe600;
|
||||
is_external = fx2_is_external;
|
||||
break;
|
||||
default:
|
||||
cpucs_addr = 0x7f92;
|
||||
is_external = fx_is_external;
|
||||
break;
|
||||
}
|
||||
|
||||
/* use only first stage loader? */
|
||||
if (stage == 0) {
|
||||
ctx.mode = internal_only;
|
||||
|
||||
/* if required, halt the CPU while we overwrite its code/data */
|
||||
if (cpucs_addr && !ezusb_cpucs(device, cpucs_addr, false))
|
||||
{
|
||||
ret = -1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* 2nd stage, first part? loader was already uploaded */
|
||||
} else {
|
||||
ctx.mode = skip_internal;
|
||||
|
||||
/* let CPU run; overwrite the 2nd stage loader later */
|
||||
if (verbose)
|
||||
logerror("2nd stage: write external memory\n");
|
||||
}
|
||||
|
||||
/* scan the image, first (maybe only) time */
|
||||
ctx.device = device;
|
||||
ctx.total = ctx.count = 0;
|
||||
status = parse[img_type](image, &ctx, is_external, ram_poke);
|
||||
if (status < 0) {
|
||||
logerror("unable to upload %s\n", path);
|
||||
ret = status;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* second part of 2nd stage: rescan */
|
||||
// TODO: what should we do for non HEX images there?
|
||||
if (stage) {
|
||||
ctx.mode = skip_external;
|
||||
|
||||
/* if needed, halt the CPU while we overwrite the 1st stage loader */
|
||||
if (cpucs_addr && !ezusb_cpucs(device, cpucs_addr, false))
|
||||
{
|
||||
ret = -1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* at least write the interrupt vectors (at 0x0000) for reset! */
|
||||
rewind(image);
|
||||
if (verbose)
|
||||
logerror("2nd stage: write on-chip memory\n");
|
||||
status = parse_ihex(image, &ctx, is_external, ram_poke);
|
||||
if (status < 0) {
|
||||
logerror("unable to completely upload %s\n", path);
|
||||
ret = status;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose && (ctx.count != 0)) {
|
||||
logerror("... WROTE: %d bytes, %d segments, avg %d\n",
|
||||
(int)ctx.total, (int)ctx.count, (int)(ctx.total/ctx.count));
|
||||
}
|
||||
|
||||
/* if required, reset the CPU so it runs what we just uploaded */
|
||||
if (cpucs_addr && !ezusb_cpucs(device, cpucs_addr, true))
|
||||
ret = -1;
|
||||
|
||||
exit:
|
||||
fclose(image);
|
||||
return ret;
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
#ifndef ezusb_H
|
||||
#define ezusb_H
|
||||
/*
|
||||
* Copyright © 2001 Stephen Williams ([email protected])
|
||||
* Copyright © 2002 David Brownell ([email protected])
|
||||
* Copyright © 2013 Federico Manzan ([email protected])
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
* General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(_MSC_VER)
|
||||
#include <stdbool.h>
|
||||
#else
|
||||
#define __attribute__(x)
|
||||
#if !defined(bool)
|
||||
#define bool int
|
||||
#endif
|
||||
#if !defined(true)
|
||||
#define true (1 == 1)
|
||||
#endif
|
||||
#if !defined(false)
|
||||
#define false (!true)
|
||||
#endif
|
||||
#if defined(_PREFAST_)
|
||||
#pragma warning(disable:28193)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define FX_TYPE_UNDEFINED -1
|
||||
#define FX_TYPE_AN21 0 /* Original AnchorChips parts */
|
||||
#define FX_TYPE_FX1 1 /* Updated Cypress versions */
|
||||
#define FX_TYPE_FX2 2 /* USB 2.0 versions */
|
||||
#define FX_TYPE_FX2LP 3 /* Updated FX2 */
|
||||
#define FX_TYPE_FX3 4 /* USB 3.0 versions */
|
||||
#define FX_TYPE_MAX 5
|
||||
#define FX_TYPE_NAMES { "an21", "fx", "fx2", "fx2lp", "fx3" }
|
||||
|
||||
#define IMG_TYPE_UNDEFINED -1
|
||||
#define IMG_TYPE_HEX 0 /* Intel HEX */
|
||||
#define IMG_TYPE_IIC 1 /* Cypress 8051 IIC */
|
||||
#define IMG_TYPE_BIX 2 /* Cypress 8051 BIX */
|
||||
#define IMG_TYPE_IMG 3 /* Cypress IMG format */
|
||||
#define IMG_TYPE_MAX 4
|
||||
#define IMG_TYPE_NAMES { "Intel HEX", "Cypress 8051 IIC", "Cypress 8051 BIX", "Cypress IMG format" }
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Automatically identified devices (VID, PID, type, designation).
|
||||
* TODO: Could use some validation. Also where's the FX2?
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t vid;
|
||||
uint16_t pid;
|
||||
int type;
|
||||
const char* designation;
|
||||
} fx_known_device;
|
||||
|
||||
#define FX_KNOWN_DEVICES { \
|
||||
{ 0x0547, 0x2122, FX_TYPE_AN21, "Cypress EZ-USB (2122S)" },\
|
||||
{ 0x0547, 0x2125, FX_TYPE_AN21, "Cypress EZ-USB (2121S/2125S)" },\
|
||||
{ 0x0547, 0x2126, FX_TYPE_AN21, "Cypress EZ-USB (2126S)" },\
|
||||
{ 0x0547, 0x2131, FX_TYPE_AN21, "Cypress EZ-USB (2131Q/2131S/2135S)" },\
|
||||
{ 0x0547, 0x2136, FX_TYPE_AN21, "Cypress EZ-USB (2136S)" },\
|
||||
{ 0x0547, 0x2225, FX_TYPE_AN21, "Cypress EZ-USB (2225)" },\
|
||||
{ 0x0547, 0x2226, FX_TYPE_AN21, "Cypress EZ-USB (2226)" },\
|
||||
{ 0x0547, 0x2235, FX_TYPE_AN21, "Cypress EZ-USB (2235)" },\
|
||||
{ 0x0547, 0x2236, FX_TYPE_AN21, "Cypress EZ-USB (2236)" },\
|
||||
{ 0x04b4, 0x6473, FX_TYPE_FX1, "Cypress EZ-USB FX1" },\
|
||||
{ 0x04b4, 0x8613, FX_TYPE_FX2LP, "Cypress EZ-USB FX2LP (68013A/68014A/68015A/68016A)" }, \
|
||||
{ 0x04b4, 0x00f3, FX_TYPE_FX3, "Cypress FX3" },\
|
||||
}
|
||||
|
||||
/*
|
||||
* This function uploads the firmware from the given file into RAM.
|
||||
* Stage == 0 means this is a single stage load (or the first of
|
||||
* two stages). Otherwise it's the second of two stages; the
|
||||
* caller having preloaded the second stage loader.
|
||||
*
|
||||
* The target processor is reset at the end of this upload.
|
||||
*/
|
||||
extern int ezusb_load_ram(libusb_device_handle *device,
|
||||
const char *path, int fx_type, int img_type, int stage);
|
||||
|
||||
/*
|
||||
* This function uploads the firmware from the given file into EEPROM.
|
||||
* This uses the right CPUCS address to terminate the EEPROM load with
|
||||
* a reset command where FX parts behave differently than FX2 ones.
|
||||
* The configuration byte is as provided here (zero for an21xx parts)
|
||||
* and the EEPROM type is set so that the microcontroller will boot
|
||||
* from it.
|
||||
*
|
||||
* The caller must have preloaded a second stage loader that knows
|
||||
* how to respond to the EEPROM write request.
|
||||
*/
|
||||
extern int ezusb_load_eeprom(libusb_device_handle *device,
|
||||
const char *path, int fx_type, int img_type, int config);
|
||||
|
||||
/* Verbosity level (default 1). Can be increased or decreased with options v/q */
|
||||
extern int verbose;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user