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

File diff suppressed because it is too large. Load diff
@@ -1,263 +1,263 @@
/*---------------------------------------------------------*\
| LianLiUniHubController.h |
| |
| Driver for Lian Li Uni Hub |
| |
| Luca Lovisa 20 Feb 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <cstdint>
#include <mutex>
#include <string>
#include <libusb.h>
#include "RGBController.h"
/*----------------------------------------------------------------------------*\
| Global definitions. |
\*----------------------------------------------------------------------------*/
enum
{
UNIHUB_CHANNEL_COUNT = 0x04, /* Channel count */
UNIHUB_CHANLED_COUNT = 0x40, /* Max-LED per channel count */
};
enum
{
UNIHUB_ACTION_ADDRESS = 0xe021, /* Global action address */
UNIHUB_COMMIT_ADDRESS = 0xe02f, /* Global commit address */
};
enum
{
UNIHUB_ANY_C1_FAN_COUNT_OFFSET = 0x00, /* Channel 1 fan count offset */
UNIHUB_ANY_C2_FAN_COUNT_OFFSET = 0x10, /* Channel 2 fan count offset */
UNIHUB_ANY_C3_FAN_COUNT_OFFSET = 0x20, /* Channel 3 fan count offset */
UNIHUB_ANY_C4_FAN_COUNT_OFFSET = 0x30, /* Channel 4 fan count offset */
};
enum
{
UNIHUB_ANY_FAN_COUNT_000 = 0xFF, /* Fan count for 0 fans (dummy value) */
UNIHUB_ANY_FAN_COUNT_001 = 0x00, /* Fan count for 1 fan */
UNIHUB_ANY_FAN_COUNT_002 = 0x01, /* Fan count for 2 fans */
UNIHUB_ANY_FAN_COUNT_003 = 0x02, /* Fan count for 3 fans */
UNIHUB_ANY_FAN_COUNT_004 = 0x03, /* Fan count for 4 fans */
};
/*----------------------------------------------------------------------------*\
| Definitions related to led configuration. |
\*----------------------------------------------------------------------------*/
enum
{
UNIHUB_LED_C1_ACTION_ADDRESS = 0xe300, /* Channel 1 led action address */
UNIHUB_LED_C1_COMMIT_ADDRESS = 0xe02f, /* Channel 1 led commit address */
UNIHUB_LED_C1_MODE_ADDRESS = 0xe021, /* Channel 1 led mode address */
UNIHUB_LED_C1_SPEED_ADDRESS = 0xe022, /* Channel 1 led speed address */
UNIHUB_LED_C1_DIRECTION_ADDRESS = 0xe023, /* Channel 1 led direction address */
UNIHUB_LED_C1_BRIGHTNESS_ADDRESS = 0xe029, /* Channel 1 led brightness address */
UNIHUB_LED_C2_ACTION_ADDRESS = 0xe3c0, /* Channel 2 led action address */
UNIHUB_LED_C2_COMMIT_ADDRESS = 0xe03f, /* Channel 2 led commit address */
UNIHUB_LED_C2_MODE_ADDRESS = 0xe031, /* Channel 2 led mode address */
UNIHUB_LED_C2_SPEED_ADDRESS = 0xe032, /* Channel 2 led speed address */
UNIHUB_LED_C2_DIRECTION_ADDRESS = 0xe033, /* Channel 2 led direction address */
UNIHUB_LED_C2_BRIGHTNESS_ADDRESS = 0xe039, /* Channel 2 led brightness address */
UNIHUB_LED_C3_ACTION_ADDRESS = 0xe480, /* Channel 3 led action address */
UNIHUB_LED_C3_COMMIT_ADDRESS = 0xe04f, /* Channel 3 led commit address */
UNIHUB_LED_C3_MODE_ADDRESS = 0xe041, /* Channel 3 led mode address */
UNIHUB_LED_C3_SPEED_ADDRESS = 0xe042, /* Channel 3 led speed address */
UNIHUB_LED_C3_DIRECTION_ADDRESS = 0xe043, /* Channel 3 led direction address */
UNIHUB_LED_C3_BRIGHTNESS_ADDRESS = 0xe049, /* Channel 3 led brightness address */
UNIHUB_LED_C4_ACTION_ADDRESS = 0xe540, /* Channel 4 led action address */
UNIHUB_LED_C4_COMMIT_ADDRESS = 0xe05f, /* Channel 4 led commit address */
UNIHUB_LED_C4_MODE_ADDRESS = 0xe051, /* Channel 4 led mode address */
UNIHUB_LED_C4_SPEED_ADDRESS = 0xe052, /* Channel 4 led speed address */
UNIHUB_LED_C4_DIRECTION_ADDRESS = 0xe053, /* Channel 4 led direction address */
UNIHUB_LED_C4_BRIGHTNESS_ADDRESS = 0xe059, /* Channel 4 led brightness address */
};
enum
{
UNIHUB_LED_MODE_RAINBOW = 0x05, /* Rainbow mode */
UNIHUB_LED_MODE_STATIC_COLOR = 0x01, /* Static Color mode */
UNIHUB_LED_MODE_BREATHING = 0x02, /* Breathing mode */
UNIHUB_LED_MODE_COLOR_CYCLE = 0x04, /* Color Cycle mode */
UNIHUB_LED_MODE_RUNWAY = 0x1c, /* Runway mode */
UNIHUB_LED_MODE_RUNWAY_SYNC = 0x1c, /* Runway Sync mode */
UNIHUB_LED_MODE_STAGGGERED = 0x18, /* Stagggered mode */
UNIHUB_LED_MODE_MIXING = 0x1a, /* Mixing mode */
UNIHUB_LED_MODE_METEOR = 0x07, /* Meteor mode */
UNIHUB_LED_MODE_METEOR_SYNC = 0x07, /* Meteor Sync mode */
UNIHUB_LED_MODE_FIREWORK = 0x1f, /* Firework mode */
UNIHUB_LED_MODE_STACK = 0x21, /* Stack mode */
UNIHUB_LED_MODE_STACK_MULTI_COLOR = 0x22, /* Stack Multi Color mode */
UNIHUB_LED_MODE_NEON = 0x23, /* Neon mode */
};
enum
{
UNIHUB_LED_SPEED_000 = 0x04, /* Very slow speed */
UNIHUB_LED_SPEED_025 = 0x03, /* Rather slow speed */
UNIHUB_LED_SPEED_050 = 0x02, /* Medium speed */
UNIHUB_LED_SPEED_075 = 0x01, /* Rather fast speed */
UNIHUB_LED_SPEED_100 = 0x00, /* Very fast speed */
};
enum
{
UNIHUB_LED_DIRECTION_LTR = 0x00, /* Left-to-Right direction */
UNIHUB_LED_DIRECTION_RTL = 0x01, /* Right-to-Left direction */
};
enum
{
UNIHUB_LED_BRIGHTNESS_000 = 0x08, /* Very dark (off) */
UNIHUB_LED_BRIGHTNESS_025 = 0x03, /* Rather dark */
UNIHUB_LED_BRIGHTNESS_050 = 0x02, /* Medium bright */
UNIHUB_LED_BRIGHTNESS_075 = 0x01, /* Rather bright */
UNIHUB_LED_BRIGHTNESS_100 = 0x00, /* Very bright */
};
/*----------------------------------------------------------------------------*\
| Definitions related to fan configuration. |
\*----------------------------------------------------------------------------*/
enum
{
UNIHUB_FAN_C1_HUB_ACTION_ADDRESS = 0xe8a0, /* Channel 1 fan action address for hub control */
UNIHUB_FAN_C1_HUB_COMMIT_ADDRESS = 0xe890, /* Channel 1 fan commit address for hub control */
UNIHUB_FAN_C1_PWM_ACTION_ADDRESS = 0xe890, /* Channel 1 fan action address for pwm control */
UNIHUB_FAN_C1_PWM_COMMIT_ADDRESS = 0xe818, /* Channel 1 fan commit address for pwm control */
UNIHUB_FAN_C1_RPM_ACTION_ADDRESS = 0xe800, /* Channel 1 fan pwm read address */
UNIHUB_FAN_C2_HUB_ACTION_ADDRESS = 0xe8a2, /* Channel 2 fan action address for hub control */
UNIHUB_FAN_C2_HUB_COMMIT_ADDRESS = 0xe891, /* Channel 2 fan commit address for hub control */
UNIHUB_FAN_C2_PWM_ACTION_ADDRESS = 0xe891, /* Channel 2 fan action address for pwm control */
UNIHUB_FAN_C2_PWM_COMMIT_ADDRESS = 0xe81a, /* Channel 2 fan commit address for pwm control */
UNIHUB_FAN_C2_RPM_ACTION_ADDRESS = 0xe802, /* Channel 1 fan pwm read address */
UNIHUB_FAN_C3_HUB_ACTION_ADDRESS = 0xe8a4, /* Channel 3 fan action address for hub control */
UNIHUB_FAN_C3_HUB_COMMIT_ADDRESS = 0xe892, /* Channel 3 fan commit address for hub control */
UNIHUB_FAN_C3_PWM_ACTION_ADDRESS = 0xe892, /* Channel 3 fan action address for pwm control */
UNIHUB_FAN_C3_PWM_COMMIT_ADDRESS = 0xe81c, /* Channel 3 fan commit address for pwm control */
UNIHUB_FAN_C3_RPM_ACTION_ADDRESS = 0xe804, /* Channel 1 fan pwm read address */
UNIHUB_FAN_C4_HUB_ACTION_ADDRESS = 0xe8a6, /* Channel 4 fan action address for hub control */
UNIHUB_FAN_C4_HUB_COMMIT_ADDRESS = 0xe893, /* Channel 4 fan commit address for hub control */
UNIHUB_FAN_C4_PWM_ACTION_ADDRESS = 0xe893, /* Channel 4 fan action address for pwm control */
UNIHUB_FAN_C4_PWM_COMMIT_ADDRESS = 0xe81e, /* Channel 4 fan commit address for pwm control */
UNIHUB_FAN_C4_RPM_ACTION_ADDRESS = 0xe806, /* Channel 1 fan pwm read address */
};
enum
{
UNIHUB_FAN_SPEED_QUIET = 0x2003, /* Rather slow */
UNIHUB_FAN_SPEED_HIGH_SPEED = 0x2206, /* Rather fast */
UNIHUB_FAN_SPEED_FULL_SPEED = 0x6c07, /* BRRRRRRRRRR */
UNIHUB_FAN_SPEED_PWM = 0xffff, /* PWM Control */
};
/*----------------------------------------------------------------------------*\
| Uni Hub controller. |
\*----------------------------------------------------------------------------*/
class LianLiUniHubController
{
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_CHANLED_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;
};
public:
LianLiUniHubController
(
libusb_device* device,
libusb_device_descriptor* descriptor
);
~LianLiUniHubController();
std::string GetVersion();
std::string GetLocation();
std::string GetSerial();
void SetAnyFanCount(size_t channel, uint8_t count);
void SetLedColors(size_t channel, RGBColor* colors, size_t count);
void SetLedMode(size_t channel, uint8_t mode);
void SetLedSpeed(size_t channel, uint8_t speed);
void SetLedDirection(size_t channel, uint8_t direction);
void SetLedBrightness(size_t channel, uint8_t brightness);
uint16_t GetFanSpeed(size_t channel);
void SetFanSpeed(size_t channel, uint16_t speed);
void EnableRgbhMode();
void DisableRgbhMode();
void EnableSyncMode();
void DisableSyncMode();
uint16_t ReadFanSpeed(size_t channel);
/*-----------------------------------------------------*\
| Synchronize the current configuration to the Uni Hub. |
\*-----------------------------------------------------*/
void Synchronize();
private:
libusb_device_handle* handle = nullptr;
std::string version;
std::string location;
std::string serial;
bool rgbhModeEnabled = false;
bool syncModeEnabled = false;
Channel channels[UNIHUB_CHANNEL_COUNT];
void CloseLibusb();
std::string ReadVersion();
void SendConfig(uint16_t wIndex, uint8_t *config, size_t length);
void SendCommit(uint16_t wIndex);
};
/*---------------------------------------------------------*\
| LianLiUniHubController.h |
| |
| Driver for Lian Li Uni Hub |
| |
| Luca Lovisa 20 Feb 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <cstdint>
#include <mutex>
#include <string>
#include <libusb.h>
#include "RGBController.h"
/*----------------------------------------------------------------------------*\
| Global definitions. |
\*----------------------------------------------------------------------------*/
enum
{
UNIHUB_CHANNEL_COUNT = 0x04, /* Channel count */
UNIHUB_CHANLED_COUNT = 0x40, /* Max-LED per channel count */
};
enum
{
UNIHUB_ACTION_ADDRESS = 0xe021, /* Global action address */
UNIHUB_COMMIT_ADDRESS = 0xe02f, /* Global commit address */
};
enum
{
UNIHUB_ANY_C1_FAN_COUNT_OFFSET = 0x00, /* Channel 1 fan count offset */
UNIHUB_ANY_C2_FAN_COUNT_OFFSET = 0x10, /* Channel 2 fan count offset */
UNIHUB_ANY_C3_FAN_COUNT_OFFSET = 0x20, /* Channel 3 fan count offset */
UNIHUB_ANY_C4_FAN_COUNT_OFFSET = 0x30, /* Channel 4 fan count offset */
};
enum
{
UNIHUB_ANY_FAN_COUNT_000 = 0xFF, /* Fan count for 0 fans (dummy value) */
UNIHUB_ANY_FAN_COUNT_001 = 0x00, /* Fan count for 1 fan */
UNIHUB_ANY_FAN_COUNT_002 = 0x01, /* Fan count for 2 fans */
UNIHUB_ANY_FAN_COUNT_003 = 0x02, /* Fan count for 3 fans */
UNIHUB_ANY_FAN_COUNT_004 = 0x03, /* Fan count for 4 fans */
};
/*----------------------------------------------------------------------------*\
| Definitions related to led configuration. |
\*----------------------------------------------------------------------------*/
enum
{
UNIHUB_LED_C1_ACTION_ADDRESS = 0xe300, /* Channel 1 led action address */
UNIHUB_LED_C1_COMMIT_ADDRESS = 0xe02f, /* Channel 1 led commit address */
UNIHUB_LED_C1_MODE_ADDRESS = 0xe021, /* Channel 1 led mode address */
UNIHUB_LED_C1_SPEED_ADDRESS = 0xe022, /* Channel 1 led speed address */
UNIHUB_LED_C1_DIRECTION_ADDRESS = 0xe023, /* Channel 1 led direction address */
UNIHUB_LED_C1_BRIGHTNESS_ADDRESS = 0xe029, /* Channel 1 led brightness address */
UNIHUB_LED_C2_ACTION_ADDRESS = 0xe3c0, /* Channel 2 led action address */
UNIHUB_LED_C2_COMMIT_ADDRESS = 0xe03f, /* Channel 2 led commit address */
UNIHUB_LED_C2_MODE_ADDRESS = 0xe031, /* Channel 2 led mode address */
UNIHUB_LED_C2_SPEED_ADDRESS = 0xe032, /* Channel 2 led speed address */
UNIHUB_LED_C2_DIRECTION_ADDRESS = 0xe033, /* Channel 2 led direction address */
UNIHUB_LED_C2_BRIGHTNESS_ADDRESS = 0xe039, /* Channel 2 led brightness address */
UNIHUB_LED_C3_ACTION_ADDRESS = 0xe480, /* Channel 3 led action address */
UNIHUB_LED_C3_COMMIT_ADDRESS = 0xe04f, /* Channel 3 led commit address */
UNIHUB_LED_C3_MODE_ADDRESS = 0xe041, /* Channel 3 led mode address */
UNIHUB_LED_C3_SPEED_ADDRESS = 0xe042, /* Channel 3 led speed address */
UNIHUB_LED_C3_DIRECTION_ADDRESS = 0xe043, /* Channel 3 led direction address */
UNIHUB_LED_C3_BRIGHTNESS_ADDRESS = 0xe049, /* Channel 3 led brightness address */
UNIHUB_LED_C4_ACTION_ADDRESS = 0xe540, /* Channel 4 led action address */
UNIHUB_LED_C4_COMMIT_ADDRESS = 0xe05f, /* Channel 4 led commit address */
UNIHUB_LED_C4_MODE_ADDRESS = 0xe051, /* Channel 4 led mode address */
UNIHUB_LED_C4_SPEED_ADDRESS = 0xe052, /* Channel 4 led speed address */
UNIHUB_LED_C4_DIRECTION_ADDRESS = 0xe053, /* Channel 4 led direction address */
UNIHUB_LED_C4_BRIGHTNESS_ADDRESS = 0xe059, /* Channel 4 led brightness address */
};
enum
{
UNIHUB_LED_MODE_RAINBOW = 0x05, /* Rainbow mode */
UNIHUB_LED_MODE_STATIC_COLOR = 0x01, /* Static Color mode */
UNIHUB_LED_MODE_BREATHING = 0x02, /* Breathing mode */
UNIHUB_LED_MODE_COLOR_CYCLE = 0x04, /* Color Cycle mode */
UNIHUB_LED_MODE_RUNWAY = 0x1c, /* Runway mode */
UNIHUB_LED_MODE_RUNWAY_SYNC = 0x1c, /* Runway Sync mode */
UNIHUB_LED_MODE_STAGGGERED = 0x18, /* Stagggered mode */
UNIHUB_LED_MODE_MIXING = 0x1a, /* Mixing mode */
UNIHUB_LED_MODE_METEOR = 0x07, /* Meteor mode */
UNIHUB_LED_MODE_METEOR_SYNC = 0x07, /* Meteor Sync mode */
UNIHUB_LED_MODE_FIREWORK = 0x1f, /* Firework mode */
UNIHUB_LED_MODE_STACK = 0x21, /* Stack mode */
UNIHUB_LED_MODE_STACK_MULTI_COLOR = 0x22, /* Stack Multi Color mode */
UNIHUB_LED_MODE_NEON = 0x23, /* Neon mode */
};
enum
{
UNIHUB_LED_SPEED_000 = 0x04, /* Very slow speed */
UNIHUB_LED_SPEED_025 = 0x03, /* Rather slow speed */
UNIHUB_LED_SPEED_050 = 0x02, /* Medium speed */
UNIHUB_LED_SPEED_075 = 0x01, /* Rather fast speed */
UNIHUB_LED_SPEED_100 = 0x00, /* Very fast speed */
};
enum
{
UNIHUB_LED_DIRECTION_LTR = 0x00, /* Left-to-Right direction */
UNIHUB_LED_DIRECTION_RTL = 0x01, /* Right-to-Left direction */
};
enum
{
UNIHUB_LED_BRIGHTNESS_000 = 0x08, /* Very dark (off) */
UNIHUB_LED_BRIGHTNESS_025 = 0x03, /* Rather dark */
UNIHUB_LED_BRIGHTNESS_050 = 0x02, /* Medium bright */
UNIHUB_LED_BRIGHTNESS_075 = 0x01, /* Rather bright */
UNIHUB_LED_BRIGHTNESS_100 = 0x00, /* Very bright */
};
/*----------------------------------------------------------------------------*\
| Definitions related to fan configuration. |
\*----------------------------------------------------------------------------*/
enum
{
UNIHUB_FAN_C1_HUB_ACTION_ADDRESS = 0xe8a0, /* Channel 1 fan action address for hub control */
UNIHUB_FAN_C1_HUB_COMMIT_ADDRESS = 0xe890, /* Channel 1 fan commit address for hub control */
UNIHUB_FAN_C1_PWM_ACTION_ADDRESS = 0xe890, /* Channel 1 fan action address for pwm control */
UNIHUB_FAN_C1_PWM_COMMIT_ADDRESS = 0xe818, /* Channel 1 fan commit address for pwm control */
UNIHUB_FAN_C1_RPM_ACTION_ADDRESS = 0xe800, /* Channel 1 fan pwm read address */
UNIHUB_FAN_C2_HUB_ACTION_ADDRESS = 0xe8a2, /* Channel 2 fan action address for hub control */
UNIHUB_FAN_C2_HUB_COMMIT_ADDRESS = 0xe891, /* Channel 2 fan commit address for hub control */
UNIHUB_FAN_C2_PWM_ACTION_ADDRESS = 0xe891, /* Channel 2 fan action address for pwm control */
UNIHUB_FAN_C2_PWM_COMMIT_ADDRESS = 0xe81a, /* Channel 2 fan commit address for pwm control */
UNIHUB_FAN_C2_RPM_ACTION_ADDRESS = 0xe802, /* Channel 1 fan pwm read address */
UNIHUB_FAN_C3_HUB_ACTION_ADDRESS = 0xe8a4, /* Channel 3 fan action address for hub control */
UNIHUB_FAN_C3_HUB_COMMIT_ADDRESS = 0xe892, /* Channel 3 fan commit address for hub control */
UNIHUB_FAN_C3_PWM_ACTION_ADDRESS = 0xe892, /* Channel 3 fan action address for pwm control */
UNIHUB_FAN_C3_PWM_COMMIT_ADDRESS = 0xe81c, /* Channel 3 fan commit address for pwm control */
UNIHUB_FAN_C3_RPM_ACTION_ADDRESS = 0xe804, /* Channel 1 fan pwm read address */
UNIHUB_FAN_C4_HUB_ACTION_ADDRESS = 0xe8a6, /* Channel 4 fan action address for hub control */
UNIHUB_FAN_C4_HUB_COMMIT_ADDRESS = 0xe893, /* Channel 4 fan commit address for hub control */
UNIHUB_FAN_C4_PWM_ACTION_ADDRESS = 0xe893, /* Channel 4 fan action address for pwm control */
UNIHUB_FAN_C4_PWM_COMMIT_ADDRESS = 0xe81e, /* Channel 4 fan commit address for pwm control */
UNIHUB_FAN_C4_RPM_ACTION_ADDRESS = 0xe806, /* Channel 1 fan pwm read address */
};
enum
{
UNIHUB_FAN_SPEED_QUIET = 0x2003, /* Rather slow */
UNIHUB_FAN_SPEED_HIGH_SPEED = 0x2206, /* Rather fast */
UNIHUB_FAN_SPEED_FULL_SPEED = 0x6c07, /* BRRRRRRRRRR */
UNIHUB_FAN_SPEED_PWM = 0xffff, /* PWM Control */
};
/*----------------------------------------------------------------------------*\
| Uni Hub controller. |
\*----------------------------------------------------------------------------*/
class LianLiUniHubController
{
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_CHANLED_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;
};
public:
LianLiUniHubController
(
libusb_device* device,
libusb_device_descriptor* descriptor
);
~LianLiUniHubController();
std::string GetVersion();
std::string GetLocation();
std::string GetSerial();
void SetAnyFanCount(size_t channel, uint8_t count);
void SetLedColors(size_t channel, RGBColor* colors, size_t count);
void SetLedMode(size_t channel, uint8_t mode);
void SetLedSpeed(size_t channel, uint8_t speed);
void SetLedDirection(size_t channel, uint8_t direction);
void SetLedBrightness(size_t channel, uint8_t brightness);
uint16_t GetFanSpeed(size_t channel);
void SetFanSpeed(size_t channel, uint16_t speed);
void EnableRgbhMode();
void DisableRgbhMode();
void EnableSyncMode();
void DisableSyncMode();
uint16_t ReadFanSpeed(size_t channel);
/*-----------------------------------------------------*\
| Synchronize the current configuration to the Uni Hub. |
\*-----------------------------------------------------*/
void Synchronize();
private:
libusb_device_handle* handle = nullptr;
std::string version;
std::string location;
std::string serial;
bool rgbhModeEnabled = false;
bool syncModeEnabled = false;
Channel channels[UNIHUB_CHANNEL_COUNT];
void CloseLibusb();
std::string ReadVersion();
void SendConfig(uint16_t wIndex, uint8_t *config, size_t length);
void SendCommit(uint16_t wIndex);
};
@@ -1,479 +1,479 @@
/*---------------------------------------------------------*\
| RGBController_LianLiUniHub.cpp |
| |
| RGBController for Lian Li Uni Hub |
| |
| Luca Lovisa 20 Feb 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <string>
#include "RGBController_LianLiUniHub.h"
mode makeMode()
{
mode Mode;
Mode.value = 0;
Mode.flags = 0;
Mode.speed_min = 0;
Mode.speed_max = 0;
Mode.colors_min = 0;
Mode.colors_max = 0;
Mode.speed = 0;
Mode.direction = 0;
Mode.color_mode = 0;
return Mode;
}
/**------------------------------------------------------------------*\
@name Lian Li Uni Hub
@category Cooler
@type USB
@save :x:
@direct :rotating_light:
@effects :white_check_mark:
@detectors DetectLianLiUniHub
@comment
\*-------------------------------------------------------------------*/
RGBController_LianLiUniHub::RGBController_LianLiUniHub(LianLiUniHubController* controller_ptr)
{
controller = controller_ptr;
name = "Lian Li Uni Hub";
vendor = "Lian Li";
version = controller->GetVersion();
type = DEVICE_TYPE_COOLER;
description = "Lian Li Uni Hub";
location = controller->GetLocation();
serial = controller->GetSerial();
initializedMode = false;
mode StaticColor = makeMode();
StaticColor.name = "Custom";
StaticColor.value = UNIHUB_LED_MODE_STATIC_COLOR;
StaticColor.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
StaticColor.color_mode = MODE_COLORS_PER_LED;
modes.push_back(StaticColor);
mode Rainbow = makeMode();
Rainbow.name = "Rainbow Wave";
Rainbow.value = UNIHUB_LED_MODE_RAINBOW;
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
Rainbow.speed_min = 1;
Rainbow.speed_max = 5;
Rainbow.color_mode = MODE_COLORS_NONE;
modes.push_back(Rainbow);
mode Breathing = makeMode();
Breathing.name = "Breathing";
Breathing.value = UNIHUB_LED_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
Breathing.speed_min = 1;
Breathing.speed_max = 5;
Breathing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Breathing);
mode ColorCycle = makeMode();
ColorCycle.name = "Color Cycle";
ColorCycle.value = UNIHUB_LED_MODE_COLOR_CYCLE;
ColorCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
ColorCycle.speed_min = 1;
ColorCycle.speed_max = 5;
ColorCycle.colors_min = 3;
ColorCycle.colors_max = 3;
ColorCycle.color_mode = MODE_COLORS_MODE_SPECIFIC;
ColorCycle.colors.resize(3);
modes.push_back(ColorCycle);
mode Runway = makeMode();
Runway.name = "Runway";
Runway.value = UNIHUB_LED_MODE_RUNWAY;
Runway.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Runway.speed_min = 1;
Runway.speed_max = 5;
Runway.colors_min = 2;
Runway.colors_max = 2;
Runway.color_mode = MODE_COLORS_MODE_SPECIFIC;
Runway.colors.resize(2);
modes.push_back(Runway);
mode RunwaySync = makeMode();
RunwaySync.name = "Runway Sync";
RunwaySync.value = UNIHUB_LED_MODE_RUNWAY_SYNC | 0x0100;
RunwaySync.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
RunwaySync.speed_min = 1;
RunwaySync.speed_max = 5;
RunwaySync.colors_min = 2;
RunwaySync.colors_max = 2;
RunwaySync.color_mode = MODE_COLORS_MODE_SPECIFIC;
RunwaySync.colors.resize(2);
modes.push_back(RunwaySync);
mode Staggered = makeMode();
Staggered.name = "Staggered";
Staggered.value = UNIHUB_LED_MODE_STAGGGERED;
Staggered.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Staggered.speed_min = 1;
Staggered.speed_max = 5;
Staggered.colors_min = 2;
Staggered.colors_max = 2;
Staggered.color_mode = MODE_COLORS_MODE_SPECIFIC;
Staggered.colors.resize(2);
modes.push_back(Staggered);
mode Mixing = makeMode();
Mixing.name = "Mixing";
Mixing.value = UNIHUB_LED_MODE_MIXING;
Mixing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Mixing.speed_min = 1;
Mixing.speed_max = 5;
Mixing.colors_min = 2;
Mixing.colors_max = 2;
Mixing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Mixing.colors.resize(2);
modes.push_back(Mixing);
mode Meteor = makeMode();
Meteor.name = "Meteor";
Meteor.value = UNIHUB_LED_MODE_METEOR;
Meteor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Meteor.speed_min = 1;
Meteor.speed_max = 5;
Meteor.colors_min = 2;
Meteor.colors_max = 2;
Meteor.color_mode = MODE_COLORS_MODE_SPECIFIC;
Meteor.colors.resize(2);
modes.push_back(Meteor);
mode MeteorSync = makeMode();
MeteorSync.name = "Meteor Sync";
MeteorSync.value = UNIHUB_LED_MODE_METEOR_SYNC | 0x0100;
MeteorSync.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
MeteorSync.speed_min = 1;
MeteorSync.speed_max = 5;
MeteorSync.colors_min = 2;
MeteorSync.colors_max = 2;
MeteorSync.color_mode = MODE_COLORS_MODE_SPECIFIC;
MeteorSync.colors.resize(2);
modes.push_back(MeteorSync);
mode Firework = makeMode();
Firework.name = "Firework";
Firework.value = UNIHUB_LED_MODE_FIREWORK;
Firework.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Firework.speed_min = 1;
Firework.speed_max = 5;
Firework.colors_min = 2;
Firework.colors_max = 2;
Firework.color_mode = MODE_COLORS_MODE_SPECIFIC;
Firework.colors.resize(2);
modes.push_back(Firework);
mode Stack = makeMode();
Stack.name = "Stack";
Stack.value = UNIHUB_LED_MODE_STACK;
Stack.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Stack.speed_min = 1;
Stack.speed_max = 5;
Stack.colors_min = 1;
Stack.colors_max = 1;
Stack.color_mode = MODE_COLORS_MODE_SPECIFIC;
Stack.colors.resize(1);
modes.push_back(Stack);
mode StackMultiColor = makeMode();
StackMultiColor.name = "Stack Multi Color";
StackMultiColor.value = UNIHUB_LED_MODE_STACK_MULTI_COLOR;
StackMultiColor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
StackMultiColor.speed_min = 1;
StackMultiColor.speed_max = 5;
StackMultiColor.color_mode = MODE_COLORS_NONE;
modes.push_back(StackMultiColor);
mode Neon = makeMode();
Neon.name = "Neon";
Neon.value = UNIHUB_LED_MODE_NEON;
Neon.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Neon.speed_min = 1;
Neon.speed_max = 5;
Neon.color_mode = MODE_COLORS_NONE;
modes.push_back(Neon);
mode Rgbh = makeMode();
Rgbh.name = "RGB Header";
Rgbh.value = UNIHUB_LED_MODE_STATIC_COLOR | 0x0200;
Rgbh.flags = 0;
Rgbh.color_mode = MODE_COLORS_NONE;
modes.push_back(Rgbh);
RGBController_LianLiUniHub::SetupZones();
}
void RGBController_LianLiUniHub::SetupZones()
{
/*-------------------------------------------------*\
| Only set LED count on the first run |
\*-------------------------------------------------*/
bool first_run = false;
if(zones.size() == 0)
{
first_run = true;
}
/*-------------------------------------------------*\
| Clear any existing color/LED configuration |
\*-------------------------------------------------*/
leds.clear();
colors.clear();
zones.resize(UNIHUB_CHANNEL_COUNT);
/*-------------------------------------------------*\
| Set zones and leds |
\*-------------------------------------------------*/
int addressableCounter = 1;
for(unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++)
{
zones[channel_idx].name = "Channel ";
zones[channel_idx].name.append(std::to_string(addressableCounter));
addressableCounter++;
zones[channel_idx].type = ZONE_TYPE_LINEAR;
zones[channel_idx].leds_min = 0;
zones[channel_idx].leds_max = UNIHUB_CHANLED_COUNT;
if(first_run)
{
zones[channel_idx].leds_count = zones[channel_idx].leds_min;
}
for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
{
led new_led;
new_led.name = zones[channel_idx].name;
new_led.name.append(", LED ");
new_led.name.append(std::to_string(led_ch_idx + 1));
new_led.value = channel_idx;
leds.push_back(new_led);
}
zones[channel_idx].matrix_map = NULL;
}
SetupColors();
}
void RGBController_LianLiUniHub::ResizeZone(int zone, int new_size)
{
if((size_t) zone >= zones.size())
{
return;
}
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
{
zones[zone].leds_count = new_size;
SetupZones();
}
}
void RGBController_LianLiUniHub::DeviceUpdateLEDs()
{
if(!initializedMode)
{
DeviceUpdateMode();
}
for(size_t channel = 0; channel < zones.size(); channel++)
{
uint8_t fanCount = convertLedCountToFanCount(zones[channel].leds_count);
controller->SetAnyFanCount(channel, convertAnyFanCount(fanCount));
controller->SetLedColors(channel, zones[channel].colors, zones[channel].leds_count);
}
controller->Synchronize();
}
void RGBController_LianLiUniHub::UpdateZoneLEDs(int zone)
{
if(!initializedMode)
{
DeviceUpdateMode();
}
unsigned int channel = zone;
uint8_t fanCount = convertLedCountToFanCount(zones[channel].leds_count);
controller->SetAnyFanCount(channel, convertAnyFanCount(fanCount));
controller->SetLedColors(channel, zones[channel].colors, zones[channel].leds_count);
controller->Synchronize();
}
void RGBController_LianLiUniHub::UpdateSingleLED(int led)
{
if(!initializedMode)
{
DeviceUpdateMode();
}
unsigned int channel = leds[led].value;
uint8_t fanCount = convertLedCountToFanCount(zones[channel].leds_count);
controller->SetAnyFanCount(channel, convertAnyFanCount(fanCount));
controller->SetLedColors(channel, zones[channel].colors, zones[channel].leds_count);
controller->Synchronize();
}
void RGBController_LianLiUniHub::DeviceUpdateMode()
{
initializedMode = true;
for (size_t channel = 0; channel < zones.size(); channel++)
{
uint8_t fanCount = convertLedCountToFanCount(zones[channel].leds_count);
controller->SetAnyFanCount(channel, convertAnyFanCount(fanCount));
switch (modes[active_mode].color_mode)
{
case MODE_COLORS_PER_LED:
controller->SetLedColors(channel, zones[channel].colors, zones[channel].leds_count);
break;
case MODE_COLORS_MODE_SPECIFIC:
controller->SetLedColors(channel, modes[active_mode].colors.data(), modes[active_mode].colors.size());
break;
default:
controller->SetLedColors(channel, nullptr, 0);
break;
}
controller->SetLedMode(channel, modes[active_mode].value);
if(modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
{
controller->SetLedSpeed(channel, convertLedSpeed(modes[active_mode].speed));
}
else
{
controller->SetLedSpeed(channel, UNIHUB_LED_SPEED_000);
}
if(modes[active_mode].flags & MODE_FLAG_HAS_DIRECTION_LR)
{
controller->SetLedDirection(channel, convertLedDirection(modes[active_mode].direction));
}
else
{
controller->SetLedDirection(channel, UNIHUB_LED_DIRECTION_LTR);
}
}
if(modes[active_mode].value & 0x0200)
{
controller->EnableRgbhMode();
controller->DisableSyncMode();
}
else if (modes[active_mode].value & 0x0100)
{
controller->DisableRgbhMode();
controller->EnableSyncMode();
}
else
{
controller->DisableRgbhMode();
controller->DisableSyncMode();
}
controller->Synchronize();
}
uint8_t RGBController_LianLiUniHub::convertAnyFanCount(uint8_t count)
{
switch (count)
{
case 0:
return UNIHUB_ANY_FAN_COUNT_000;
case 1:
return UNIHUB_ANY_FAN_COUNT_001;
case 2:
return UNIHUB_ANY_FAN_COUNT_002;
case 3:
return UNIHUB_ANY_FAN_COUNT_003;
case 4:
return UNIHUB_ANY_FAN_COUNT_004;
default:
return UNIHUB_ANY_FAN_COUNT_001;
}
}
uint8_t RGBController_LianLiUniHub::convertLedSpeed(uint8_t speed)
{
switch (speed)
{
case 1:
return UNIHUB_LED_SPEED_000;
case 2:
return UNIHUB_LED_SPEED_025;
case 3:
return UNIHUB_LED_SPEED_050;
case 4:
return UNIHUB_LED_SPEED_075;
case 5:
return UNIHUB_LED_SPEED_100;
default:
return UNIHUB_LED_SPEED_050;
}
}
uint8_t RGBController_LianLiUniHub::convertLedDirection(uint8_t direction)
{
switch (direction)
{
case 0:
return UNIHUB_LED_DIRECTION_LTR;
case 1:
return UNIHUB_LED_DIRECTION_RTL;
default:
return UNIHUB_LED_DIRECTION_LTR;
}
}
uint8_t RGBController_LianLiUniHub::convertLedCountToFanCount(uint8_t count)
{
/*-------------------------------------------------*\
| Converts 0 to 0, 1-16 to 1, 17-32 to 2, 33-48 to |
| 3 and 49-64+ to 4 |
\*-------------------------------------------------*/
if (count == 0x00)
{
return 0x00;
}
if (count >= 0x40)
{
count = 0x40;
}
return((count -1) / 16 + 1);
}
/*---------------------------------------------------------*\
| RGBController_LianLiUniHub.cpp |
| |
| RGBController for Lian Li Uni Hub |
| |
| Luca Lovisa 20 Feb 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <string>
#include "RGBController_LianLiUniHub.h"
mode makeMode()
{
mode Mode;
Mode.value = 0;
Mode.flags = 0;
Mode.speed_min = 0;
Mode.speed_max = 0;
Mode.colors_min = 0;
Mode.colors_max = 0;
Mode.speed = 0;
Mode.direction = 0;
Mode.color_mode = 0;
return Mode;
}
/**------------------------------------------------------------------*\
@name Lian Li Uni Hub
@category Cooler
@type USB
@save :x:
@direct :rotating_light:
@effects :white_check_mark:
@detectors DetectLianLiUniHub
@comment
\*-------------------------------------------------------------------*/
RGBController_LianLiUniHub::RGBController_LianLiUniHub(LianLiUniHubController* controller_ptr)
{
controller = controller_ptr;
name = "Lian Li Uni Hub";
vendor = "Lian Li";
version = controller->GetVersion();
type = DEVICE_TYPE_COOLER;
description = "Lian Li Uni Hub";
location = controller->GetLocation();
serial = controller->GetSerial();
initializedMode = false;
mode StaticColor = makeMode();
StaticColor.name = "Custom";
StaticColor.value = UNIHUB_LED_MODE_STATIC_COLOR;
StaticColor.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
StaticColor.color_mode = MODE_COLORS_PER_LED;
modes.push_back(StaticColor);
mode Rainbow = makeMode();
Rainbow.name = "Rainbow Wave";
Rainbow.value = UNIHUB_LED_MODE_RAINBOW;
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
Rainbow.speed_min = 1;
Rainbow.speed_max = 5;
Rainbow.color_mode = MODE_COLORS_NONE;
modes.push_back(Rainbow);
mode Breathing = makeMode();
Breathing.name = "Breathing";
Breathing.value = UNIHUB_LED_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
Breathing.speed_min = 1;
Breathing.speed_max = 5;
Breathing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Breathing);
mode ColorCycle = makeMode();
ColorCycle.name = "Color Cycle";
ColorCycle.value = UNIHUB_LED_MODE_COLOR_CYCLE;
ColorCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
ColorCycle.speed_min = 1;
ColorCycle.speed_max = 5;
ColorCycle.colors_min = 3;
ColorCycle.colors_max = 3;
ColorCycle.color_mode = MODE_COLORS_MODE_SPECIFIC;
ColorCycle.colors.resize(3);
modes.push_back(ColorCycle);
mode Runway = makeMode();
Runway.name = "Runway";
Runway.value = UNIHUB_LED_MODE_RUNWAY;
Runway.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Runway.speed_min = 1;
Runway.speed_max = 5;
Runway.colors_min = 2;
Runway.colors_max = 2;
Runway.color_mode = MODE_COLORS_MODE_SPECIFIC;
Runway.colors.resize(2);
modes.push_back(Runway);
mode RunwaySync = makeMode();
RunwaySync.name = "Runway Sync";
RunwaySync.value = UNIHUB_LED_MODE_RUNWAY_SYNC | 0x0100;
RunwaySync.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
RunwaySync.speed_min = 1;
RunwaySync.speed_max = 5;
RunwaySync.colors_min = 2;
RunwaySync.colors_max = 2;
RunwaySync.color_mode = MODE_COLORS_MODE_SPECIFIC;
RunwaySync.colors.resize(2);
modes.push_back(RunwaySync);
mode Staggered = makeMode();
Staggered.name = "Staggered";
Staggered.value = UNIHUB_LED_MODE_STAGGGERED;
Staggered.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Staggered.speed_min = 1;
Staggered.speed_max = 5;
Staggered.colors_min = 2;
Staggered.colors_max = 2;
Staggered.color_mode = MODE_COLORS_MODE_SPECIFIC;
Staggered.colors.resize(2);
modes.push_back(Staggered);
mode Mixing = makeMode();
Mixing.name = "Mixing";
Mixing.value = UNIHUB_LED_MODE_MIXING;
Mixing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Mixing.speed_min = 1;
Mixing.speed_max = 5;
Mixing.colors_min = 2;
Mixing.colors_max = 2;
Mixing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Mixing.colors.resize(2);
modes.push_back(Mixing);
mode Meteor = makeMode();
Meteor.name = "Meteor";
Meteor.value = UNIHUB_LED_MODE_METEOR;
Meteor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Meteor.speed_min = 1;
Meteor.speed_max = 5;
Meteor.colors_min = 2;
Meteor.colors_max = 2;
Meteor.color_mode = MODE_COLORS_MODE_SPECIFIC;
Meteor.colors.resize(2);
modes.push_back(Meteor);
mode MeteorSync = makeMode();
MeteorSync.name = "Meteor Sync";
MeteorSync.value = UNIHUB_LED_MODE_METEOR_SYNC | 0x0100;
MeteorSync.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
MeteorSync.speed_min = 1;
MeteorSync.speed_max = 5;
MeteorSync.colors_min = 2;
MeteorSync.colors_max = 2;
MeteorSync.color_mode = MODE_COLORS_MODE_SPECIFIC;
MeteorSync.colors.resize(2);
modes.push_back(MeteorSync);
mode Firework = makeMode();
Firework.name = "Firework";
Firework.value = UNIHUB_LED_MODE_FIREWORK;
Firework.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Firework.speed_min = 1;
Firework.speed_max = 5;
Firework.colors_min = 2;
Firework.colors_max = 2;
Firework.color_mode = MODE_COLORS_MODE_SPECIFIC;
Firework.colors.resize(2);
modes.push_back(Firework);
mode Stack = makeMode();
Stack.name = "Stack";
Stack.value = UNIHUB_LED_MODE_STACK;
Stack.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Stack.speed_min = 1;
Stack.speed_max = 5;
Stack.colors_min = 1;
Stack.colors_max = 1;
Stack.color_mode = MODE_COLORS_MODE_SPECIFIC;
Stack.colors.resize(1);
modes.push_back(Stack);
mode StackMultiColor = makeMode();
StackMultiColor.name = "Stack Multi Color";
StackMultiColor.value = UNIHUB_LED_MODE_STACK_MULTI_COLOR;
StackMultiColor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
StackMultiColor.speed_min = 1;
StackMultiColor.speed_max = 5;
StackMultiColor.color_mode = MODE_COLORS_NONE;
modes.push_back(StackMultiColor);
mode Neon = makeMode();
Neon.name = "Neon";
Neon.value = UNIHUB_LED_MODE_NEON;
Neon.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Neon.speed_min = 1;
Neon.speed_max = 5;
Neon.color_mode = MODE_COLORS_NONE;
modes.push_back(Neon);
mode Rgbh = makeMode();
Rgbh.name = "RGB Header";
Rgbh.value = UNIHUB_LED_MODE_STATIC_COLOR | 0x0200;
Rgbh.flags = 0;
Rgbh.color_mode = MODE_COLORS_NONE;
modes.push_back(Rgbh);
RGBController_LianLiUniHub::SetupZones();
}
void RGBController_LianLiUniHub::SetupZones()
{
/*-------------------------------------------------*\
| Only set LED count on the first run |
\*-------------------------------------------------*/
bool first_run = false;
if(zones.size() == 0)
{
first_run = true;
}
/*-------------------------------------------------*\
| Clear any existing color/LED configuration |
\*-------------------------------------------------*/
leds.clear();
colors.clear();
zones.resize(UNIHUB_CHANNEL_COUNT);
/*-------------------------------------------------*\
| Set zones and leds |
\*-------------------------------------------------*/
int addressableCounter = 1;
for(unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++)
{
zones[channel_idx].name = "Channel ";
zones[channel_idx].name.append(std::to_string(addressableCounter));
addressableCounter++;
zones[channel_idx].type = ZONE_TYPE_LINEAR;
zones[channel_idx].leds_min = 0;
zones[channel_idx].leds_max = UNIHUB_CHANLED_COUNT;
if(first_run)
{
zones[channel_idx].leds_count = zones[channel_idx].leds_min;
}
for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
{
led new_led;
new_led.name = zones[channel_idx].name;
new_led.name.append(", LED ");
new_led.name.append(std::to_string(led_ch_idx + 1));
new_led.value = channel_idx;
leds.push_back(new_led);
}
zones[channel_idx].matrix_map = NULL;
}
SetupColors();
}
void RGBController_LianLiUniHub::ResizeZone(int zone, int new_size)
{
if((size_t) zone >= zones.size())
{
return;
}
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
{
zones[zone].leds_count = new_size;
SetupZones();
}
}
void RGBController_LianLiUniHub::DeviceUpdateLEDs()
{
if(!initializedMode)
{
DeviceUpdateMode();
}
for(size_t channel = 0; channel < zones.size(); channel++)
{
uint8_t fanCount = convertLedCountToFanCount(zones[channel].leds_count);
controller->SetAnyFanCount(channel, convertAnyFanCount(fanCount));
controller->SetLedColors(channel, zones[channel].colors, zones[channel].leds_count);
}
controller->Synchronize();
}
void RGBController_LianLiUniHub::UpdateZoneLEDs(int zone)
{
if(!initializedMode)
{
DeviceUpdateMode();
}
unsigned int channel = zone;
uint8_t fanCount = convertLedCountToFanCount(zones[channel].leds_count);
controller->SetAnyFanCount(channel, convertAnyFanCount(fanCount));
controller->SetLedColors(channel, zones[channel].colors, zones[channel].leds_count);
controller->Synchronize();
}
void RGBController_LianLiUniHub::UpdateSingleLED(int led)
{
if(!initializedMode)
{
DeviceUpdateMode();
}
unsigned int channel = leds[led].value;
uint8_t fanCount = convertLedCountToFanCount(zones[channel].leds_count);
controller->SetAnyFanCount(channel, convertAnyFanCount(fanCount));
controller->SetLedColors(channel, zones[channel].colors, zones[channel].leds_count);
controller->Synchronize();
}
void RGBController_LianLiUniHub::DeviceUpdateMode()
{
initializedMode = true;
for (size_t channel = 0; channel < zones.size(); channel++)
{
uint8_t fanCount = convertLedCountToFanCount(zones[channel].leds_count);
controller->SetAnyFanCount(channel, convertAnyFanCount(fanCount));
switch (modes[active_mode].color_mode)
{
case MODE_COLORS_PER_LED:
controller->SetLedColors(channel, zones[channel].colors, zones[channel].leds_count);
break;
case MODE_COLORS_MODE_SPECIFIC:
controller->SetLedColors(channel, modes[active_mode].colors.data(), modes[active_mode].colors.size());
break;
default:
controller->SetLedColors(channel, nullptr, 0);
break;
}
controller->SetLedMode(channel, modes[active_mode].value);
if(modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
{
controller->SetLedSpeed(channel, convertLedSpeed(modes[active_mode].speed));
}
else
{
controller->SetLedSpeed(channel, UNIHUB_LED_SPEED_000);
}
if(modes[active_mode].flags & MODE_FLAG_HAS_DIRECTION_LR)
{
controller->SetLedDirection(channel, convertLedDirection(modes[active_mode].direction));
}
else
{
controller->SetLedDirection(channel, UNIHUB_LED_DIRECTION_LTR);
}
}
if(modes[active_mode].value & 0x0200)
{
controller->EnableRgbhMode();
controller->DisableSyncMode();
}
else if (modes[active_mode].value & 0x0100)
{
controller->DisableRgbhMode();
controller->EnableSyncMode();
}
else
{
controller->DisableRgbhMode();
controller->DisableSyncMode();
}
controller->Synchronize();
}
uint8_t RGBController_LianLiUniHub::convertAnyFanCount(uint8_t count)
{
switch (count)
{
case 0:
return UNIHUB_ANY_FAN_COUNT_000;
case 1:
return UNIHUB_ANY_FAN_COUNT_001;
case 2:
return UNIHUB_ANY_FAN_COUNT_002;
case 3:
return UNIHUB_ANY_FAN_COUNT_003;
case 4:
return UNIHUB_ANY_FAN_COUNT_004;
default:
return UNIHUB_ANY_FAN_COUNT_001;
}
}
uint8_t RGBController_LianLiUniHub::convertLedSpeed(uint8_t speed)
{
switch (speed)
{
case 1:
return UNIHUB_LED_SPEED_000;
case 2:
return UNIHUB_LED_SPEED_025;
case 3:
return UNIHUB_LED_SPEED_050;
case 4:
return UNIHUB_LED_SPEED_075;
case 5:
return UNIHUB_LED_SPEED_100;
default:
return UNIHUB_LED_SPEED_050;
}
}
uint8_t RGBController_LianLiUniHub::convertLedDirection(uint8_t direction)
{
switch (direction)
{
case 0:
return UNIHUB_LED_DIRECTION_LTR;
case 1:
return UNIHUB_LED_DIRECTION_RTL;
default:
return UNIHUB_LED_DIRECTION_LTR;
}
}
uint8_t RGBController_LianLiUniHub::convertLedCountToFanCount(uint8_t count)
{
/*-------------------------------------------------*\
| Converts 0 to 0, 1-16 to 1, 17-32 to 2, 33-48 to |
| 3 and 49-64+ to 4 |
\*-------------------------------------------------*/
if (count == 0x00)
{
return 0x00;
}
if (count >= 0x40)
{
count = 0x40;
}
return((count -1) / 16 + 1);
}
@@ -1,43 +1,43 @@
/*---------------------------------------------------------*\
| RGBController_LianLiUniHub.h |
| |
| RGBController for Lian Li Uni Hub |
| |
| Luca Lovisa 20 Feb 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <cstdint>
#include <vector>
#include "LianLiUniHubController.h"
#include "RGBController.h"
class RGBController_LianLiUniHub : public RGBController
{
public:
RGBController_LianLiUniHub(LianLiUniHubController* controller_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
uint8_t convertAnyFanCount(uint8_t count);
uint8_t convertLedSpeed(uint8_t speed);
uint8_t convertLedDirection(uint8_t direction);
uint8_t convertLedCountToFanCount(uint8_t count);
private:
LianLiUniHubController* controller;
bool initializedMode;
};
/*---------------------------------------------------------*\
| RGBController_LianLiUniHub.h |
| |
| RGBController for Lian Li Uni Hub |
| |
| Luca Lovisa 20 Feb 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <cstdint>
#include <vector>
#include "LianLiUniHubController.h"
#include "RGBController.h"
class RGBController_LianLiUniHub : public RGBController
{
public:
RGBController_LianLiUniHub(LianLiUniHubController* controller_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
uint8_t convertAnyFanCount(uint8_t count);
uint8_t convertLedSpeed(uint8_t speed);
uint8_t convertLedDirection(uint8_t direction);
uint8_t convertLedCountToFanCount(uint8_t count);
private:
LianLiUniHubController* controller;
bool initializedMode;
};