Publish curated LumaOps source from c85ee9ef8f1454f5c305398902afbb9e6738de40
Managed validation / full (push) Failing after 8s

This commit is contained in:
Public Source Publisher committed 2026-09-30 00:26:45 +00:00
1 parent 91f8b3e3c1
commit def7920856
2271 files changed
+501225 -501178

No files matched your search

@@ -1,402 +1,402 @@
/*---------------------------------------------------------*\
| LianLiUniHubALController.cpp |
| |
| Driver for Lian Li AL Uni Hub |
| |
| Oliver P 26 Apr 2022 |
| Credit to Luca Lovisa for original work |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <string.h>
#include "LianLiUniHubALController.h"
#include "StringUtils.h"
using namespace std::chrono_literals;
LianLiUniHubALController::LianLiUniHubALController(hid_device* dev_handle, const char* path, unsigned short pid, std::string dev_name)
{
dev = dev_handle;
dev_pid = pid;
location = path;
name = dev_name;
}
LianLiUniHubALController::~LianLiUniHubALController()
{
hid_close(dev);
}
std::string LianLiUniHubALController::GetDeviceLocation()
{
return("HID: " + location);
}
std::string LianLiUniHubALController::GetFirmwareVersionString()
{
wchar_t product_string[40];
int ret = hid_get_product_string(dev, product_string, 40);
if (ret != 0)
{
return ("");
}
std::string return_string = StringUtils::wstring_to_string(product_string);
return(return_string.substr(return_string.find_last_of("-")+1,4).c_str());
}
std::string LianLiUniHubALController::GetName()
{
return(name);
}
std::string LianLiUniHubALController::GetSerialString()
{
wchar_t serial_string[20];
int ret = hid_get_serial_number_string(dev, serial_string, 20);
if (ret != 0)
{
return ("");
}
std::string return_string = StringUtils::wstring_to_string(serial_string);
return(return_string);
}
void LianLiUniHubALController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors, float brightness)
{
unsigned char fan_led_data[96];
unsigned char edge_led_data[144];
int fan_idx = 0;
int mod_led_idx;
int cur_led_idx;
if(num_colors == 0)
{
return; // Do nothing, channel isn't in use
}
for(unsigned int led_idx = 0; led_idx < num_colors; led_idx++)
{
mod_led_idx = (led_idx % 20);
if((mod_led_idx == 0) && (led_idx != 0))
{
fan_idx++;
}
/*---------------------------------------------------------*\
| Limiter to protect LEDs |
\*---------------------------------------------------------*/
if(UNIHUB_AL_LED_LIMITER && RGBGetRValue(colors[led_idx]) > 153 && (RGBGetRValue(colors[led_idx]) == RGBGetBValue(colors[led_idx])) && (RGBGetRValue(colors[led_idx]) == RGBGetGValue(colors[led_idx])) )
{
colors[led_idx] = ToRGBColor(153,153,153);
}
if(mod_led_idx < 8) // Fan LEDs, 8 LEDs per fan
{
//Determine current position of led_data array from colors array
cur_led_idx = ((mod_led_idx + (fan_idx * 8)) * 3);
fan_led_data[cur_led_idx + 0] = (unsigned char)(RGBGetRValue(colors[led_idx]) * brightness);
fan_led_data[cur_led_idx + 1] = (unsigned char)(RGBGetBValue(colors[led_idx]) * brightness);
fan_led_data[cur_led_idx + 2] = (unsigned char)(RGBGetGValue(colors[led_idx]) * brightness);
}
else // Edge LEDs, 12 LEDs per fan
{
//Determine current position of led_data array from colors array
cur_led_idx = (((mod_led_idx - 8) + (fan_idx * 12)) * 3);
edge_led_data[cur_led_idx + 0] = (unsigned char)(RGBGetRValue(colors[led_idx]) * brightness);
edge_led_data[cur_led_idx + 1] = (unsigned char)(RGBGetBValue(colors[led_idx]) * brightness);
edge_led_data[cur_led_idx + 2] = (unsigned char)(RGBGetGValue(colors[led_idx]) * brightness);
}
}
/*---------------------------------------------------------*\
| Send fan LED data |
\*---------------------------------------------------------*/
SendStartAction
(
channel, // Current channel
(fan_idx + 1) // Number of fans
);
SendColorData
(
channel, // Channel
0, // 0 = Fan, 1 = Edge
(fan_idx + 1)*8,
fan_led_data
);
SendCommitAction
(
channel, // Channel
0, // 0 = Fan, 1 = Edge
UNIHUB_AL_LED_MODE_STATIC_COLOR, // Effect
UNIHUB_AL_LED_SPEED_000, // Speed
UNIHUB_AL_LED_DIRECTION_LTR, // Direction
UNIHUB_AL_LED_BRIGHTNESS_100 // Brightness
);
/*---------------------------------------------------------*\
| Send edge LED data |
\*---------------------------------------------------------*/
SendStartAction
(
channel, // Current channel
(fan_idx + 1) // Number of fans
);
SendColorData
(
channel, // Channel
1, // 0 = Fan, 1 = Edge
(fan_idx + 1)*12,
edge_led_data
);
SendCommitAction
(
channel, // Channel
1, // 0 = Fan, 1 = Edge
UNIHUB_AL_LED_MODE_STATIC_COLOR, // Effect
UNIHUB_AL_LED_SPEED_000, // Speed
UNIHUB_AL_LED_DIRECTION_LTR, // Direction
UNIHUB_AL_LED_BRIGHTNESS_100 // Brightness
);
}
void LianLiUniHubALController::SetChannelMode(unsigned char channel, unsigned int mode_value, std::vector<RGBColor> colors, unsigned int num_colors, unsigned int num_fans, bool upd_both_fan_edge, unsigned int brightness, unsigned int speed, unsigned int direction)
{
static unsigned int brightness_code[5] =
{
UNIHUB_AL_LED_BRIGHTNESS_000,
UNIHUB_AL_LED_BRIGHTNESS_025,
UNIHUB_AL_LED_BRIGHTNESS_050,
UNIHUB_AL_LED_BRIGHTNESS_075,
UNIHUB_AL_LED_BRIGHTNESS_100
};
static unsigned int speed_code[5] =
{
UNIHUB_AL_LED_SPEED_000,
UNIHUB_AL_LED_SPEED_025,
UNIHUB_AL_LED_SPEED_050,
UNIHUB_AL_LED_SPEED_075,
UNIHUB_AL_LED_SPEED_100
};
unsigned char fan_led_data[96];
unsigned char edge_led_data[144];
int cur_led_idx;
float brightness_scale;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(fan_led_data, 0x00, sizeof(fan_led_data));
memset(edge_led_data, 0x00, sizeof(edge_led_data));
if(num_colors) // Update led_data if there's colors
{
switch(mode_value)
{
case UNIHUB_AL_LED_MODE_STATIC_COLOR: // Static mode requires a full data array
case UNIHUB_AL_LED_MODE_BREATHING:
brightness_scale = static_cast<float>(brightness)/4;
for(unsigned int i = 0; i < 4; i++)
{
/*---------------------------------------------------------*\
| Limiter to protect LEDs |
\*---------------------------------------------------------*/
if(UNIHUB_AL_LED_LIMITER && RGBGetRValue(colors[i]) > 153 && (RGBGetRValue(colors[i]) == RGBGetBValue(colors[i])) && (RGBGetRValue(colors[i]) == RGBGetGValue(colors[i])) )
{
colors[i] = ToRGBColor(153,153,153);
}
for(unsigned int led_idx = 0; led_idx < 22; led_idx += 3)
{
cur_led_idx = (i * 8 * 3) + led_idx;
fan_led_data[cur_led_idx + 0] = (unsigned char)(RGBGetRValue(colors[i]) * brightness_scale);
fan_led_data[cur_led_idx + 1] = (unsigned char)(RGBGetBValue(colors[i]) * brightness_scale);
fan_led_data[cur_led_idx + 2] = (unsigned char)(RGBGetGValue(colors[i]) * brightness_scale);
}
for(unsigned int led_idx = 0; led_idx < 34; led_idx += 3)
{
cur_led_idx = (i * 12 * 3) + led_idx;
edge_led_data[cur_led_idx + 0] = (unsigned char)(RGBGetRValue(colors[i]) * brightness_scale);
edge_led_data[cur_led_idx + 1] = (unsigned char)(RGBGetBValue(colors[i]) * brightness_scale);
edge_led_data[cur_led_idx + 2] = (unsigned char)(RGBGetGValue(colors[i]) * brightness_scale);
}
}
break;
default:
colors.resize(4);
for(unsigned int i = num_colors; i < 4; i++)
{
colors[i] = 0x00;
}
// needs a 48 length array of 4 colors, even if less are defined
for(unsigned int i = 0; i < 4; i++)
{
for(unsigned int j = 0; j < 4; j++)
{
cur_led_idx = (i * 12) + (j * 3);
fan_led_data[cur_led_idx + 0] = RGBGetRValue(colors[j]);
fan_led_data[cur_led_idx + 1] = RGBGetBValue(colors[j]);
fan_led_data[cur_led_idx + 2] = RGBGetGValue(colors[j]);
}
}
break;
}
}
SendStartAction
(
channel, // Current channel
(num_fans + 1) // Number of fans
);
SendColorData
(
channel, // Channel
0, // 0 = Fan, 1 = Edge
(num_fans + 1)*8,
fan_led_data // Data
);
SendCommitAction
(
channel, // Channel
0, // 0 = Fan, 1 = Edge
mode_value, // Effect
speed_code[speed], // Speed
direction, // Direction
brightness_code[brightness] // Brightness
);
if(upd_both_fan_edge)
{
SendStartAction
(
channel, // Current channel
(num_fans + 1) // Number of fans
);
SendColorData
(
channel, // Channel
1, // 0 = Fan, 1 = Edge
(num_fans + 1)*12,
edge_led_data
);
SendCommitAction
(
channel, // Channel
1, // 0 = Fan, 1 = Edge
mode_value, // Effect
speed_code[speed], // Speed
direction, // Direction
brightness_code[brightness] // Brightness
);
}
}
void LianLiUniHubALController::SendStartAction(unsigned char channel, unsigned int num_fans)
{
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = UNIHUB_AL_TRANSACTION_ID;
usb_buf[0x01] = 0x10;
usb_buf[0x02] = 0x40;
usb_buf[0x03] = channel + 1;
usb_buf[0x04] = num_fans;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 65);
std::this_thread::sleep_for(5ms);
}
void LianLiUniHubALController::SendColorData(unsigned char channel, unsigned int fan_or_edge, unsigned int num_leds, unsigned char* led_data)
{
/*---------------------------------------------------------*\
| Send edge LED data |
\*---------------------------------------------------------*/
unsigned char usb_buf[146];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = UNIHUB_AL_TRANSACTION_ID;
usb_buf[0x01] = 0x30 + fan_or_edge + (channel * 2); // Channel+device (30 = channel 1 edge, 31 = channel 1 edge, 32 = channel 2 fan, 33 = channel 2 edge, etc.)
/*-----------------------------------------------------*\
| Copy in color data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x02], led_data, num_leds * 3);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 146);
std::this_thread::sleep_for(5ms);
}
void LianLiUniHubALController::SendCommitAction(unsigned char channel, unsigned int fan_or_edge, unsigned char effect, unsigned char speed, unsigned int direction, unsigned int brightness)
{
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = UNIHUB_AL_TRANSACTION_ID;
usb_buf[0x01] = 0x10 + fan_or_edge + (channel*2); // Channel+device (10 = channel 1 fan, 11 = channel 1 edge, 12 = channel 2 fan, 13 = chanell 2 edge, etc.)
usb_buf[0x02] = effect; // Effect
usb_buf[0x03] = speed; // Speed, 02=0%, 01=25%, 00=50%, ff=75%, fe=100%
usb_buf[0x04] = direction; // Direction, right=00, left=01
usb_buf[0x05] = brightness; // Brightness, 0=100%, 1= 75%, 2 = 50%, 3 = 25%, 8 = 0%
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 65);
std::this_thread::sleep_for(5ms);
}
/*---------------------------------------------------------*\
| LianLiUniHubALController.cpp |
| |
| Driver for Lian Li AL Uni Hub |
| |
| Oliver P 26 Apr 2022 |
| Credit to Luca Lovisa for original work |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <string.h>
#include "LianLiUniHubALController.h"
#include "StringUtils.h"
using namespace std::chrono_literals;
LianLiUniHubALController::LianLiUniHubALController(hid_device* dev_handle, const char* path, unsigned short pid, std::string dev_name)
{
dev = dev_handle;
dev_pid = pid;
location = path;
name = dev_name;
}
LianLiUniHubALController::~LianLiUniHubALController()
{
hid_close(dev);
}
std::string LianLiUniHubALController::GetDeviceLocation()
{
return("HID: " + location);
}
std::string LianLiUniHubALController::GetFirmwareVersionString()
{
wchar_t product_string[40];
int ret = hid_get_product_string(dev, product_string, 40);
if (ret != 0)
{
return ("");
}
std::string return_string = StringUtils::wstring_to_string(product_string);
return(return_string.substr(return_string.find_last_of("-")+1,4).c_str());
}
std::string LianLiUniHubALController::GetName()
{
return(name);
}
std::string LianLiUniHubALController::GetSerialString()
{
wchar_t serial_string[20];
int ret = hid_get_serial_number_string(dev, serial_string, 20);
if (ret != 0)
{
return ("");
}
std::string return_string = StringUtils::wstring_to_string(serial_string);
return(return_string);
}
void LianLiUniHubALController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors, float brightness)
{
unsigned char fan_led_data[96];
unsigned char edge_led_data[144];
int fan_idx = 0;
int mod_led_idx;
int cur_led_idx;
if(num_colors == 0)
{
return; // Do nothing, channel isn't in use
}
for(unsigned int led_idx = 0; led_idx < num_colors; led_idx++)
{
mod_led_idx = (led_idx % 20);
if((mod_led_idx == 0) && (led_idx != 0))
{
fan_idx++;
}
/*---------------------------------------------------------*\
| Limiter to protect LEDs |
\*---------------------------------------------------------*/
if(UNIHUB_AL_LED_LIMITER && RGBGetRValue(colors[led_idx]) > 153 && (RGBGetRValue(colors[led_idx]) == RGBGetBValue(colors[led_idx])) && (RGBGetRValue(colors[led_idx]) == RGBGetGValue(colors[led_idx])) )
{
colors[led_idx] = ToRGBColor(153,153,153);
}
if(mod_led_idx < 8) // Fan LEDs, 8 LEDs per fan
{
//Determine current position of led_data array from colors array
cur_led_idx = ((mod_led_idx + (fan_idx * 8)) * 3);
fan_led_data[cur_led_idx + 0] = (unsigned char)(RGBGetRValue(colors[led_idx]) * brightness);
fan_led_data[cur_led_idx + 1] = (unsigned char)(RGBGetBValue(colors[led_idx]) * brightness);
fan_led_data[cur_led_idx + 2] = (unsigned char)(RGBGetGValue(colors[led_idx]) * brightness);
}
else // Edge LEDs, 12 LEDs per fan
{
//Determine current position of led_data array from colors array
cur_led_idx = (((mod_led_idx - 8) + (fan_idx * 12)) * 3);
edge_led_data[cur_led_idx + 0] = (unsigned char)(RGBGetRValue(colors[led_idx]) * brightness);
edge_led_data[cur_led_idx + 1] = (unsigned char)(RGBGetBValue(colors[led_idx]) * brightness);
edge_led_data[cur_led_idx + 2] = (unsigned char)(RGBGetGValue(colors[led_idx]) * brightness);
}
}
/*---------------------------------------------------------*\
| Send fan LED data |
\*---------------------------------------------------------*/
SendStartAction
(
channel, // Current channel
(fan_idx + 1) // Number of fans
);
SendColorData
(
channel, // Channel
0, // 0 = Fan, 1 = Edge
(fan_idx + 1)*8,
fan_led_data
);
SendCommitAction
(
channel, // Channel
0, // 0 = Fan, 1 = Edge
UNIHUB_AL_LED_MODE_STATIC_COLOR, // Effect
UNIHUB_AL_LED_SPEED_000, // Speed
UNIHUB_AL_LED_DIRECTION_LTR, // Direction
UNIHUB_AL_LED_BRIGHTNESS_100 // Brightness
);
/*---------------------------------------------------------*\
| Send edge LED data |
\*---------------------------------------------------------*/
SendStartAction
(
channel, // Current channel
(fan_idx + 1) // Number of fans
);
SendColorData
(
channel, // Channel
1, // 0 = Fan, 1 = Edge
(fan_idx + 1)*12,
edge_led_data
);
SendCommitAction
(
channel, // Channel
1, // 0 = Fan, 1 = Edge
UNIHUB_AL_LED_MODE_STATIC_COLOR, // Effect
UNIHUB_AL_LED_SPEED_000, // Speed
UNIHUB_AL_LED_DIRECTION_LTR, // Direction
UNIHUB_AL_LED_BRIGHTNESS_100 // Brightness
);
}
void LianLiUniHubALController::SetChannelMode(unsigned char channel, unsigned int mode_value, std::vector<RGBColor> colors, unsigned int num_colors, unsigned int num_fans, bool upd_both_fan_edge, unsigned int brightness, unsigned int speed, unsigned int direction)
{
static unsigned int brightness_code[5] =
{
UNIHUB_AL_LED_BRIGHTNESS_000,
UNIHUB_AL_LED_BRIGHTNESS_025,
UNIHUB_AL_LED_BRIGHTNESS_050,
UNIHUB_AL_LED_BRIGHTNESS_075,
UNIHUB_AL_LED_BRIGHTNESS_100
};
static unsigned int speed_code[5] =
{
UNIHUB_AL_LED_SPEED_000,
UNIHUB_AL_LED_SPEED_025,
UNIHUB_AL_LED_SPEED_050,
UNIHUB_AL_LED_SPEED_075,
UNIHUB_AL_LED_SPEED_100
};
unsigned char fan_led_data[96];
unsigned char edge_led_data[144];
int cur_led_idx;
float brightness_scale;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(fan_led_data, 0x00, sizeof(fan_led_data));
memset(edge_led_data, 0x00, sizeof(edge_led_data));
if(num_colors) // Update led_data if there's colors
{
switch(mode_value)
{
case UNIHUB_AL_LED_MODE_STATIC_COLOR: // Static mode requires a full data array
case UNIHUB_AL_LED_MODE_BREATHING:
brightness_scale = static_cast<float>(brightness)/4;
for(unsigned int i = 0; i < 4; i++)
{
/*---------------------------------------------------------*\
| Limiter to protect LEDs |
\*---------------------------------------------------------*/
if(UNIHUB_AL_LED_LIMITER && RGBGetRValue(colors[i]) > 153 && (RGBGetRValue(colors[i]) == RGBGetBValue(colors[i])) && (RGBGetRValue(colors[i]) == RGBGetGValue(colors[i])) )
{
colors[i] = ToRGBColor(153,153,153);
}
for(unsigned int led_idx = 0; led_idx < 22; led_idx += 3)
{
cur_led_idx = (i * 8 * 3) + led_idx;
fan_led_data[cur_led_idx + 0] = (unsigned char)(RGBGetRValue(colors[i]) * brightness_scale);
fan_led_data[cur_led_idx + 1] = (unsigned char)(RGBGetBValue(colors[i]) * brightness_scale);
fan_led_data[cur_led_idx + 2] = (unsigned char)(RGBGetGValue(colors[i]) * brightness_scale);
}
for(unsigned int led_idx = 0; led_idx < 34; led_idx += 3)
{
cur_led_idx = (i * 12 * 3) + led_idx;
edge_led_data[cur_led_idx + 0] = (unsigned char)(RGBGetRValue(colors[i]) * brightness_scale);
edge_led_data[cur_led_idx + 1] = (unsigned char)(RGBGetBValue(colors[i]) * brightness_scale);
edge_led_data[cur_led_idx + 2] = (unsigned char)(RGBGetGValue(colors[i]) * brightness_scale);
}
}
break;
default:
colors.resize(4);
for(unsigned int i = num_colors; i < 4; i++)
{
colors[i] = 0x00;
}
// needs a 48 length array of 4 colors, even if less are defined
for(unsigned int i = 0; i < 4; i++)
{
for(unsigned int j = 0; j < 4; j++)
{
cur_led_idx = (i * 12) + (j * 3);
fan_led_data[cur_led_idx + 0] = RGBGetRValue(colors[j]);
fan_led_data[cur_led_idx + 1] = RGBGetBValue(colors[j]);
fan_led_data[cur_led_idx + 2] = RGBGetGValue(colors[j]);
}
}
break;
}
}
SendStartAction
(
channel, // Current channel
(num_fans + 1) // Number of fans
);
SendColorData
(
channel, // Channel
0, // 0 = Fan, 1 = Edge
(num_fans + 1)*8,
fan_led_data // Data
);
SendCommitAction
(
channel, // Channel
0, // 0 = Fan, 1 = Edge
mode_value, // Effect
speed_code[speed], // Speed
direction, // Direction
brightness_code[brightness] // Brightness
);
if(upd_both_fan_edge)
{
SendStartAction
(
channel, // Current channel
(num_fans + 1) // Number of fans
);
SendColorData
(
channel, // Channel
1, // 0 = Fan, 1 = Edge
(num_fans + 1)*12,
edge_led_data
);
SendCommitAction
(
channel, // Channel
1, // 0 = Fan, 1 = Edge
mode_value, // Effect
speed_code[speed], // Speed
direction, // Direction
brightness_code[brightness] // Brightness
);
}
}
void LianLiUniHubALController::SendStartAction(unsigned char channel, unsigned int num_fans)
{
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = UNIHUB_AL_TRANSACTION_ID;
usb_buf[0x01] = 0x10;
usb_buf[0x02] = 0x40;
usb_buf[0x03] = channel + 1;
usb_buf[0x04] = num_fans;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 65);
std::this_thread::sleep_for(5ms);
}
void LianLiUniHubALController::SendColorData(unsigned char channel, unsigned int fan_or_edge, unsigned int num_leds, unsigned char* led_data)
{
/*---------------------------------------------------------*\
| Send edge LED data |
\*---------------------------------------------------------*/
unsigned char usb_buf[146];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = UNIHUB_AL_TRANSACTION_ID;
usb_buf[0x01] = 0x30 + fan_or_edge + (channel * 2); // Channel+device (30 = channel 1 edge, 31 = channel 1 edge, 32 = channel 2 fan, 33 = channel 2 edge, etc.)
/*-----------------------------------------------------*\
| Copy in color data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x02], led_data, num_leds * 3);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 146);
std::this_thread::sleep_for(5ms);
}
void LianLiUniHubALController::SendCommitAction(unsigned char channel, unsigned int fan_or_edge, unsigned char effect, unsigned char speed, unsigned int direction, unsigned int brightness)
{
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = UNIHUB_AL_TRANSACTION_ID;
usb_buf[0x01] = 0x10 + fan_or_edge + (channel*2); // Channel+device (10 = channel 1 fan, 11 = channel 1 edge, 12 = channel 2 fan, 13 = chanell 2 edge, etc.)
usb_buf[0x02] = effect; // Effect
usb_buf[0x03] = speed; // Speed, 02=0%, 01=25%, 00=50%, ff=75%, fe=100%
usb_buf[0x04] = direction; // Direction, right=00, left=01
usb_buf[0x05] = brightness; // Brightness, 0=100%, 1= 75%, 2 = 50%, 3 = 25%, 8 = 0%
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 65);
std::this_thread::sleep_for(5ms);
}
@@ -1,217 +1,217 @@
/*---------------------------------------------------------*\
| LianLiUniHubALController.h |
| |
| Driver for Lian Li AL Uni Hub |
| |
| Oliver P 26 Apr 2022 |
| Credit to Luca Lovisa for original work |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <string>
#include <hidapi.h>
#include "RGBController.h"
/*----------------------------------------------------------------------------*\
| Global definitions. |
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
| Definitions related to zone Sizes |
\*----------------------------------------------------------------------------*/
enum
{
UNIHUB_AL_CHANNEL_COUNT = 0x04, /* Channel count */
UNIHUB_AL_CHAN_FANLED_COUNT = 0x20, /* Max-LED per channel count - 32 */
UNIHUB_AL_CHAN_EDGELED_COUNT = 0x30, /* Max-LED per channel count - 48 */
UNIHUB_AL_CHAN_LED_COUNT = 0x50, /* Max-LED per channel count - 80 */
};
/*----------------------------------------------------------------------------*\
| Definitions related to LED configuration. |
\*----------------------------------------------------------------------------*/
// Used for sync'd mode between Fan and Edge
enum
{
UNIHUB_AL_LED_MODE_RAINBOW = 0x28, /* Rainbow mode - Calls Fan only */
UNIHUB_AL_LED_MODE_RAINBOW_MORPH = 0x35, /* Rainbow Morph mode - Calls Fan only */
UNIHUB_AL_LED_MODE_STATIC_COLOR = 0x01, /* Static Color mode */
UNIHUB_AL_LED_MODE_BREATHING = 0x02, /* Breathing mode */
UNIHUB_AL_LED_MODE_TAICHI = 0x2C, /* Neon mode - Calls Fan only */
UNIHUB_AL_LED_MODE_COLOR_CYCLE = 0x2B, /* Color Cycle mode - Calls Fan only */
UNIHUB_AL_LED_MODE_RUNWAY = 0x1A, /* Runway mode */
UNIHUB_AL_LED_MODE_METEOR = 0x19, /* Meteor mode */
UNIHUB_AL_LED_MODE_WARNING = 0x2D, /* Warning mode - Calls Fan only */
UNIHUB_AL_LED_MODE_VOICE = 0x2E, /* Voice mode - Calls Fan only */
UNIHUB_AL_LED_MODE_SPINNING_TEACUP = 0x38, /* Spinning Teacup mode - Calls Fan only */
UNIHUB_AL_LED_MODE_TORNADO = 0x36, /* Tornado mode - Calls Fan only */
UNIHUB_AL_LED_MODE_MIXING = 0x2F, /* Mixing mode - Calls Fan only */
UNIHUB_AL_LED_MODE_STACK = 0x30, /* Stack mode - Calls Fan only */
UNIHUB_AL_LED_MODE_STAGGGERED = 0x37, /* Stagggered mode - Calls Fan only */
UNIHUB_AL_LED_MODE_TIDE = 0x31, /* Tide mode - Calls Fan only */
UNIHUB_AL_LED_MODE_SCAN = 0x32, /* Scan mode - Calls Fan only */
UNIHUB_AL_LED_MODE_CONTEST = 0x33, /* Contest mode - Calls Fan only */
};
enum
{
UNIHUB_AL_LED_SPEED_000 = 0x02, /* Very slow speed */
UNIHUB_AL_LED_SPEED_025 = 0x01, /* Rather slow speed */
UNIHUB_AL_LED_SPEED_050 = 0x00, /* Medium speed */
UNIHUB_AL_LED_SPEED_075 = 0xFF, /* Rather fast speed */
UNIHUB_AL_LED_SPEED_100 = 0xFE, /* Very fast speed */
};
enum
{
UNIHUB_AL_LED_DIRECTION_LTR = 0x00, /* Left-to-Right direction */
UNIHUB_AL_LED_DIRECTION_RTL = 0x01, /* Right-to-Left direction */
};
enum
{
UNIHUB_AL_LED_BRIGHTNESS_000 = 0x08, /* Very dark (off) */
UNIHUB_AL_LED_BRIGHTNESS_025 = 0x03, /* Rather dark */
UNIHUB_AL_LED_BRIGHTNESS_050 = 0x02, /* Medium bright */
UNIHUB_AL_LED_BRIGHTNESS_075 = 0x01, /* Rather bright */
UNIHUB_AL_LED_BRIGHTNESS_100 = 0x00, /* Very bright */
};
enum
{
UNIHUB_AL_LED_LIMITER = 0x01 /* Limit the color white to 999999 as per manufacturer limits */
};
/*----------------------------------------------------------------------------*\
| Definitions related to packet configuration. |
\*----------------------------------------------------------------------------*/
enum
{
UNIHUB_AL_TRANSACTION_ID = 0xE0, /* Command value to start all packets */
};
/*----------------------------------------------------------------------------*\
| Uni Hub AL controller. |
\*----------------------------------------------------------------------------*/
class LianLiUniHubALController
{
public:
LianLiUniHubALController(hid_device* dev_handle, const char* path, unsigned short pid, std::string dev_name);
~LianLiUniHubALController();
std::string GetDeviceLocation();
std::string GetFirmwareVersionString();
std::string GetName();
std::string GetSerialString();
void SetChannelMode
(
unsigned char channel,
unsigned int mode_value,
std::vector<RGBColor> colors, // Not a pointer because the copy gets resized
unsigned int num_colors,
unsigned int num_fans,
bool upd_both_fan_edge,
unsigned int brightness,
unsigned int speed,
unsigned int direction
);
void SetChannelLEDs
(
unsigned char channel,
RGBColor * colors,
unsigned int num_colors,
float brightness
);
void SendStartAction
(
unsigned char channel,
unsigned int num_fans
);
void SendColorData
(
unsigned char channel, // Zone index
unsigned int fan_or_edge, // 1 (Fan) or 0 (Edge) modifer to channel
unsigned int num_leds,
unsigned char* led_data // Color data payload
);
void SendCommitAction
(
unsigned char channel, // Zone index
unsigned int fan_or_edge, // 1 (Fan) or 0 (Edge) modifer to channel
unsigned char effect,
unsigned char speed,
unsigned int direction,
unsigned int brightness
);
private:
/* The Uni Hub requires colors in RBG order */
struct Color
{
uint8_t r;
uint8_t b;
uint8_t g;
};
/* The values correspond to the definitions above */
struct Channel
{
uint8_t index;
uint8_t anyFanCountOffset;
uint8_t anyFanCount;
uint16_t ledActionAddress;
uint16_t ledCommitAddress;
uint16_t ledModeAddress;
uint16_t ledSpeedAddress;
uint16_t ledDirectionAddress;
uint16_t ledBrightnessAddress;
Color colors[UNIHUB_AL_CHAN_FANLED_COUNT];
uint8_t ledMode;
uint8_t ledSpeed;
uint8_t ledDirection;
uint8_t ledBrightness;
uint16_t fanHubActionAddress;
uint16_t fanHubCommitAddress;
uint16_t fanPwmActionAddress;
uint16_t fanPwmCommitAddress;
uint16_t fanRpmActionAddress;
uint16_t fanSpeed;
};
private:
hid_device* dev;
unsigned short dev_pid;
/*---------------------------------------------------------*\
| Device information strings |
\*---------------------------------------------------------*/
std::string firmware_version;
std::string location;
std::string name;
};
/*---------------------------------------------------------*\
| LianLiUniHubALController.h |
| |
| Driver for Lian Li AL Uni Hub |
| |
| Oliver P 26 Apr 2022 |
| Credit to Luca Lovisa for original work |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <string>
#include <hidapi.h>
#include "RGBController.h"
/*----------------------------------------------------------------------------*\
| Global definitions. |
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
| Definitions related to zone Sizes |
\*----------------------------------------------------------------------------*/
enum
{
UNIHUB_AL_CHANNEL_COUNT = 0x04, /* Channel count */
UNIHUB_AL_CHAN_FANLED_COUNT = 0x20, /* Max-LED per channel count - 32 */
UNIHUB_AL_CHAN_EDGELED_COUNT = 0x30, /* Max-LED per channel count - 48 */
UNIHUB_AL_CHAN_LED_COUNT = 0x50, /* Max-LED per channel count - 80 */
};
/*----------------------------------------------------------------------------*\
| Definitions related to LED configuration. |
\*----------------------------------------------------------------------------*/
// Used for sync'd mode between Fan and Edge
enum
{
UNIHUB_AL_LED_MODE_RAINBOW = 0x28, /* Rainbow mode - Calls Fan only */
UNIHUB_AL_LED_MODE_RAINBOW_MORPH = 0x35, /* Rainbow Morph mode - Calls Fan only */
UNIHUB_AL_LED_MODE_STATIC_COLOR = 0x01, /* Static Color mode */
UNIHUB_AL_LED_MODE_BREATHING = 0x02, /* Breathing mode */
UNIHUB_AL_LED_MODE_TAICHI = 0x2C, /* Neon mode - Calls Fan only */
UNIHUB_AL_LED_MODE_COLOR_CYCLE = 0x2B, /* Color Cycle mode - Calls Fan only */
UNIHUB_AL_LED_MODE_RUNWAY = 0x1A, /* Runway mode */
UNIHUB_AL_LED_MODE_METEOR = 0x19, /* Meteor mode */
UNIHUB_AL_LED_MODE_WARNING = 0x2D, /* Warning mode - Calls Fan only */
UNIHUB_AL_LED_MODE_VOICE = 0x2E, /* Voice mode - Calls Fan only */
UNIHUB_AL_LED_MODE_SPINNING_TEACUP = 0x38, /* Spinning Teacup mode - Calls Fan only */
UNIHUB_AL_LED_MODE_TORNADO = 0x36, /* Tornado mode - Calls Fan only */
UNIHUB_AL_LED_MODE_MIXING = 0x2F, /* Mixing mode - Calls Fan only */
UNIHUB_AL_LED_MODE_STACK = 0x30, /* Stack mode - Calls Fan only */
UNIHUB_AL_LED_MODE_STAGGGERED = 0x37, /* Stagggered mode - Calls Fan only */
UNIHUB_AL_LED_MODE_TIDE = 0x31, /* Tide mode - Calls Fan only */
UNIHUB_AL_LED_MODE_SCAN = 0x32, /* Scan mode - Calls Fan only */
UNIHUB_AL_LED_MODE_CONTEST = 0x33, /* Contest mode - Calls Fan only */
};
enum
{
UNIHUB_AL_LED_SPEED_000 = 0x02, /* Very slow speed */
UNIHUB_AL_LED_SPEED_025 = 0x01, /* Rather slow speed */
UNIHUB_AL_LED_SPEED_050 = 0x00, /* Medium speed */
UNIHUB_AL_LED_SPEED_075 = 0xFF, /* Rather fast speed */
UNIHUB_AL_LED_SPEED_100 = 0xFE, /* Very fast speed */
};
enum
{
UNIHUB_AL_LED_DIRECTION_LTR = 0x00, /* Left-to-Right direction */
UNIHUB_AL_LED_DIRECTION_RTL = 0x01, /* Right-to-Left direction */
};
enum
{
UNIHUB_AL_LED_BRIGHTNESS_000 = 0x08, /* Very dark (off) */
UNIHUB_AL_LED_BRIGHTNESS_025 = 0x03, /* Rather dark */
UNIHUB_AL_LED_BRIGHTNESS_050 = 0x02, /* Medium bright */
UNIHUB_AL_LED_BRIGHTNESS_075 = 0x01, /* Rather bright */
UNIHUB_AL_LED_BRIGHTNESS_100 = 0x00, /* Very bright */
};
enum
{
UNIHUB_AL_LED_LIMITER = 0x01 /* Limit the color white to 999999 as per manufacturer limits */
};
/*----------------------------------------------------------------------------*\
| Definitions related to packet configuration. |
\*----------------------------------------------------------------------------*/
enum
{
UNIHUB_AL_TRANSACTION_ID = 0xE0, /* Command value to start all packets */
};
/*----------------------------------------------------------------------------*\
| Uni Hub AL controller. |
\*----------------------------------------------------------------------------*/
class LianLiUniHubALController
{
public:
LianLiUniHubALController(hid_device* dev_handle, const char* path, unsigned short pid, std::string dev_name);
~LianLiUniHubALController();
std::string GetDeviceLocation();
std::string GetFirmwareVersionString();
std::string GetName();
std::string GetSerialString();
void SetChannelMode
(
unsigned char channel,
unsigned int mode_value,
std::vector<RGBColor> colors, // Not a pointer because the copy gets resized
unsigned int num_colors,
unsigned int num_fans,
bool upd_both_fan_edge,
unsigned int brightness,
unsigned int speed,
unsigned int direction
);
void SetChannelLEDs
(
unsigned char channel,
RGBColor * colors,
unsigned int num_colors,
float brightness
);
void SendStartAction
(
unsigned char channel,
unsigned int num_fans
);
void SendColorData
(
unsigned char channel, // Zone index
unsigned int fan_or_edge, // 1 (Fan) or 0 (Edge) modifer to channel
unsigned int num_leds,
unsigned char* led_data // Color data payload
);
void SendCommitAction
(
unsigned char channel, // Zone index
unsigned int fan_or_edge, // 1 (Fan) or 0 (Edge) modifer to channel
unsigned char effect,
unsigned char speed,
unsigned int direction,
unsigned int brightness
);
private:
/* The Uni Hub requires colors in RBG order */
struct Color
{
uint8_t r;
uint8_t b;
uint8_t g;
};
/* The values correspond to the definitions above */
struct Channel
{
uint8_t index;
uint8_t anyFanCountOffset;
uint8_t anyFanCount;
uint16_t ledActionAddress;
uint16_t ledCommitAddress;
uint16_t ledModeAddress;
uint16_t ledSpeedAddress;
uint16_t ledDirectionAddress;
uint16_t ledBrightnessAddress;
Color colors[UNIHUB_AL_CHAN_FANLED_COUNT];
uint8_t ledMode;
uint8_t ledSpeed;
uint8_t ledDirection;
uint8_t ledBrightness;
uint16_t fanHubActionAddress;
uint16_t fanHubCommitAddress;
uint16_t fanPwmActionAddress;
uint16_t fanPwmCommitAddress;
uint16_t fanRpmActionAddress;
uint16_t fanSpeed;
};
private:
hid_device* dev;
unsigned short dev_pid;
/*---------------------------------------------------------*\
| Device information strings |
\*---------------------------------------------------------*/
std::string firmware_version;
std::string location;
std::string name;
};
File diff suppressed because it is too large. Load diff
@@ -1,39 +1,39 @@
/*---------------------------------------------------------*\
| RGBController_LianLiUniHub_AL.h |
| |
| RGBController for Lian Li AL Uni Hub |
| |
| Oliver P 26 Apr 2022 |
| Credit to Luca Lovisa for original work |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <cstdint>
#include <vector>
#include "LianLiUniHubALController.h"
#include "RGBController.h"
class RGBController_LianLiUniHubAL : public RGBController
{
public:
RGBController_LianLiUniHubAL(LianLiUniHubALController* controller_ptr);
~RGBController_LianLiUniHubAL();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
LianLiUniHubALController* controller;
bool initializedMode;
};
/*---------------------------------------------------------*\
| RGBController_LianLiUniHub_AL.h |
| |
| RGBController for Lian Li AL Uni Hub |
| |
| Oliver P 26 Apr 2022 |
| Credit to Luca Lovisa for original work |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <cstdint>
#include <vector>
#include "LianLiUniHubALController.h"
#include "RGBController.h"
class RGBController_LianLiUniHubAL : public RGBController
{
public:
RGBController_LianLiUniHubAL(LianLiUniHubALController* controller_ptr);
~RGBController_LianLiUniHubAL();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
LianLiUniHubALController* controller;
bool initializedMode;
};