Publish LumaOps source

This commit is contained in:
LumaOps release export
2026-09-03 01:18:36 +02:00
commit 7f1c0e5f71
2363 changed files with 501543 additions and 0 deletions
@@ -0,0 +1,374 @@
/*---------------------------------------------------------*\
| AMDWraithPrismController.cpp |
| |
| Driver for AMD Wraith Prism |
| |
| Adam Honse (CalcProgrammer1) 06 Dec 2019 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include "AMDWraithPrismController.h"
#include "StringUtils.h"
AMDWraithPrismController::AMDWraithPrismController(hid_device* dev_handle, const char* path)
{
dev = dev_handle;
location = path;
current_fan_mode = AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC;
current_fan_speed = 0xFF;
current_fan_random_color = false;
current_fan_brightness = 0xFF;
current_logo_mode = AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC;
current_logo_speed = 0xFF;
current_logo_random_color = false;
current_logo_brightness = 0xFF;
current_ring_mode = AMD_WRAITH_PRISM_EFFECT_CHANNEL_STATIC;
current_ring_speed = 0xFF;
current_ring_direction = false;
current_ring_brightness = 0xFF;
}
AMDWraithPrismController::~AMDWraithPrismController()
{
hid_close(dev);
}
std::string AMDWraithPrismController::GetLocationString()
{
return("HID: " + location);
}
std::string AMDWraithPrismController::GetSerialString()
{
wchar_t serial_string[128];
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
return(StringUtils::wstring_to_string(serial_string));
}
std::string AMDWraithPrismController::GetFirmwareVersionString()
{
std::string ret_string = "";
unsigned char usb_buf[] =
{
0x00,
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,
};
unsigned char fw_buf[16] = {0x00};
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
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::SetFanMode(unsigned char mode, unsigned char speed, unsigned char brightness, bool random_color)
{
current_fan_mode = mode;
current_fan_speed = speed_values_fan_logo[mode][speed];
current_fan_brightness = brightness;
current_fan_random_color = random_color;
}
void AMDWraithPrismController::SetFanColor(unsigned char red, unsigned char green, unsigned char blue)
{
SendEffectChannelUpdate
(
AMD_WRAITH_PRISM_EFFECT_CHANNEL_FAN_LED,
current_fan_speed,
false,
current_fan_random_color,
current_fan_mode,
current_fan_brightness,
red,
green,
blue
);
}
void AMDWraithPrismController::SetLogoMode(unsigned char mode, unsigned char speed, unsigned char brightness, bool random_color)
{
current_logo_mode = mode;
current_logo_speed = speed_values_fan_logo[mode][speed];
current_logo_brightness = brightness;
current_logo_random_color = random_color;
}
void AMDWraithPrismController::SetLogoColor(unsigned char red, unsigned char green, unsigned char blue)
{
SendEffectChannelUpdate
(
AMD_WRAITH_PRISM_EFFECT_CHANNEL_LOGO_LED,
current_logo_speed,
false,
current_logo_random_color,
current_logo_mode,
current_logo_brightness,
red,
green,
blue
);
}
void AMDWraithPrismController::SetRingMode(unsigned char mode, unsigned char speed, unsigned char brightness, bool direction, bool random_color)
{
current_ring_mode = mode;
current_ring_speed = speed_values_ring[mode][speed];
current_ring_direction = direction;
current_ring_brightness = brightness;
current_ring_random_color = random_color;
}
void AMDWraithPrismController::SetRingColor(unsigned char red, unsigned char green, unsigned char blue)
{
SetRingEffectChannel(current_ring_mode);
SendEffectChannelUpdate
(
current_ring_mode,
current_ring_speed,
current_ring_direction,
current_ring_random_color,
mode_value_ring[current_ring_mode],
current_ring_brightness,
red,
green,
blue
);
SendApplyCommand();
}
void AMDWraithPrismController::SetRingEffectChannel(unsigned char channel)
{
SendChannelRemap(channel, AMD_WRAITH_PRISM_EFFECT_CHANNEL_LOGO_LED, AMD_WRAITH_PRISM_EFFECT_CHANNEL_FAN_LED);
}
void AMDWraithPrismController::SendEnableCommand(bool direct)
{
unsigned char usb_buf[] =
{
0x00,
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,
};
if(direct)
{
usb_buf[0x02] = 0x03;
}
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
}
void AMDWraithPrismController::SendApplyCommand()
{
unsigned char usb_buf[] =
{
0x00,
0x51, 0x28, 0x00, 0x00,
0xE0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
}
void AMDWraithPrismController::SendDirectPacket
(
unsigned char size,
unsigned char * led_ids,
RGBColor * colors
)
{
unsigned char usb_buf[] =
{
0x00,
0xC0, 0x01, size, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
for(unsigned int led_idx = 0; led_idx < size; led_idx++)
{
unsigned int index = led_idx * 4;
usb_buf[index + 5] = led_ids[led_idx];
usb_buf[index + 6] = RGBGetRValue(colors[led_idx]);
usb_buf[index + 7] = RGBGetGValue(colors[led_idx]);
usb_buf[index + 8] = RGBGetBValue(colors[led_idx]);
}
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
}
void AMDWraithPrismController::SendEffectChannelUpdate
(
unsigned char effect_channel,
unsigned char speed,
bool direction,
bool random_color,
unsigned char mode,
unsigned char brightness,
unsigned char red,
unsigned char green,
unsigned char blue
)
{
unsigned char usb_buf[] =
{
0x00,
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
};
usb_buf[0x05] = effect_channel;
usb_buf[0x06] = speed;
usb_buf[0x07] = (direction ? 0x01 : 0x00) | (random_color ? 0x80 : 0x00);
usb_buf[0x08] = mode;
usb_buf[0x0A] = brightness;
usb_buf[0x0B] = red;
usb_buf[0x0C] = green;
usb_buf[0x0D] = blue;
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
}
void AMDWraithPrismController::SendChannelRemap(unsigned char ring_channel, unsigned char logo_channel, unsigned char fan_channel)
{
unsigned char usb_buf[] =
{
0x00,
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,
};
usb_buf[0x09] = logo_channel;
usb_buf[0x0A] = fan_channel;
for(int led = 0x0B; led <= 0x19; led++)
{
usb_buf[led] = ring_channel;
}
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
}
@@ -0,0 +1,157 @@
/*---------------------------------------------------------*\
| AMDWraithPrismController.h |
| |
| Driver for AMD Wraith Prism |
| |
| Adam Honse (CalcProgrammer1) 06 Dec 2019 |
| |
| 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"
#define AMD_WRAITH_PRISM_FAN_BRIGHTNESS_DEFAULT_MAX 0xFF
#define AMD_WRAITH_PRISM_FAN_BRIGHTNESS_CYCLE_MAX 0x7F
static const unsigned char speed_values_fan_logo[][5] =
{
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, /* Static */
{ 0x96, 0x8C, 0x80, 0x6E, 0x68 }, /* Color Cycle */
{ 0x3C, 0x37, 0x31, 0x2C, 0x26 }, /* Breathing */
};
static const unsigned char mode_value_ring[] =
{
0xFF,
0x03,
0xFF,
0x00,
0x00,
0x00,
0x00,
0x05,
0xFF,
0xC3,
0x4A,
0x05
};
static const unsigned char speed_values_ring[][5] =
{
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, /* Static */
{ 0x3C, 0x37, 0x31, 0x2C, 0x26 }, /* Breathing */
{ 0x96, 0x8C, 0x80, 0x6E, 0x68 }, /* Color Cycle */
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
{ 0x72, 0x68, 0x64, 0x62, 0x61 }, /* Rainbow */
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Bounce */
{ 0x77, 0x74, 0x6E, 0x6B, 0x67 }, /* Chase */
{ 0x77, 0x74, 0x6E, 0x6B, 0x67 }, /* Swirl */
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Morse Code */
};
enum
{
AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC = 0x01, /* Fan/Logo Static Mode */
AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE = 0x02, /* Fan/Logo Color Cycle Mode */
AMD_WRAITH_PRISM_FAN_LOGO_MODE_BREATHING = 0x03, /* Fan/Logo Breathing Mode */
};
enum
{
AMD_WRAITH_PRISM_EFFECT_CHANNEL_STATIC = 0x00, /* Static effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_BREATHING = 0x01, /* Breathing effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_COLOR_CYCLE = 0x02, /* Color cycle effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_LOGO_LED = 0x05, /* Logo LED effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_FAN_LED = 0x06, /* Fan LED effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_RAINBOW = 0x07, /* Rainbow effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_BOUNCE = 0x08, /* Bounce effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_CHASE = 0x09, /* Chase effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_SWIRL = 0x0A, /* Swirl effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_MORSE = 0x0B, /* Morse code effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_DIRECT = 0xFF, /* Value for direct mode */
};
enum
{
AMD_WRAITH_PRISM_SPEED_SLOWEST = 0x00, /* Slowest speed */
AMD_WRAITH_PRISM_SPEED_SLOW = 0x01, /* Slow speed */
AMD_WRAITH_PRISM_SPEED_NORMAL = 0x02, /* Normal speed */
AMD_WRAITH_PRISM_SPEED_FAST = 0x03, /* Fast speed */
AMD_WRAITH_PRISM_SPEED_FASTEST = 0x04, /* Fastest speed */
};
class AMDWraithPrismController
{
public:
AMDWraithPrismController(hid_device* dev_handle, const char* path);
~AMDWraithPrismController();
std::string GetEffectChannelString(unsigned char channel);
std::string GetFirmwareVersionString();
std::string GetLocationString();
std::string GetSerialString();
unsigned char current_fan_mode;
unsigned char current_fan_speed;
unsigned char current_fan_brightness;
bool current_fan_random_color;
unsigned char current_logo_mode;
unsigned char current_logo_speed;
unsigned char current_logo_brightness;
bool current_logo_random_color;
unsigned char current_ring_mode;
unsigned char current_ring_speed;
unsigned char current_ring_brightness;
bool current_ring_direction;
bool current_ring_random_color;
void SetFanMode(unsigned char mode, unsigned char speed, unsigned char brightness, bool random_color);
void SetFanColor(unsigned char red, unsigned char green, unsigned char blue);
void SetLogoMode(unsigned char mode, unsigned char speed, unsigned char brightness, bool random_color);
void SetLogoColor(unsigned char red, unsigned char green, unsigned char blue);
void SetRingMode(unsigned char mode, unsigned char speed, unsigned char brightness, bool direction, bool random_color);
void SetRingColor(unsigned char red, unsigned char green, unsigned char blue);
void SendDirectPacket
(
unsigned char size,
unsigned char * led_ids,
RGBColor * colors
);
void SendEnableCommand(bool direct);
void SendApplyCommand();
private:
hid_device* dev;
std::string location;
void SetRingEffectChannel(unsigned char channel);
void SendEffectChannelUpdate
(
unsigned char effect_channel,
unsigned char speed,
bool direction,
bool random_color,
unsigned char mode,
unsigned char brightness,
unsigned char red,
unsigned char green,
unsigned char blue
);
void SendChannelRemap(unsigned char ring_channel, unsigned char logo_channel, unsigned char fan_channel);
};
@@ -0,0 +1,48 @@
/*---------------------------------------------------------*\
| AMDWraithPrismControllerDetect.cpp |
| |
| Detector for AMD Wraith Prism |
| |
| Adam Honse (CalcProgrammer1) 06 Dec 2019 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <hidapi.h>
#include "Detector.h"
#include "AMDWraithPrismController.h"
#include "RGBController_AMDWraithPrism.h"
/*---------------------------------------------------------*\
| AMD Wraith Prism vendor ID |
\*---------------------------------------------------------*/
#define AMD_WRAITH_PRISM_VID 0x2516
/*---------------------------------------------------------*\
| AMD Wraith Prism product ID |
\*---------------------------------------------------------*/
#define AMD_WRAITH_PRISM_PID 0x0051
/******************************************************************************************\
* *
* DetectAMDWraithPrismControllers *
* *
* Tests the USB address to see if an AMD Wraith Prism controller exists there. *
* *
\******************************************************************************************/
void DetectAMDWraithPrismControllers(hid_device_info* info, const std::string&)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
AMDWraithPrismController* controller = new AMDWraithPrismController(dev, info->path);
RGBController_AMDWraithPrism* rgb_controller = new RGBController_AMDWraithPrism(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_HID_DETECTOR_IP("AMD Wraith Prism", DetectAMDWraithPrismControllers, AMD_WRAITH_PRISM_VID, AMD_WRAITH_PRISM_PID, 1, 0xFF00);
@@ -0,0 +1,336 @@
/*---------------------------------------------------------*\
| RGBController_AMDWraithPrism.cpp |
| |
| RGBController for AMD Wraith Prism |
| |
| Adam Honse (CalcProgrammer1) 25 Dec 2019 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_AMDWraithPrism.h"
/**------------------------------------------------------------------*\
@name AMD Wraith Prism
@category Cooler
@type USB
@save :o:
@direct :white_check_mark:
@effects :tools:
@detectors DetectAMDWraithPrismControllers
@comment The Wraith Prism comes with 2 cables but is only detectable
and controlable when using the USB cable. `Morse Code` and `Mirage`
modes have not been implemented. Saving to flash is supported by
the device but not yet implemented.
\*-------------------------------------------------------------------*/
RGBController_AMDWraithPrism::RGBController_AMDWraithPrism(AMDWraithPrismController* controller_ptr)
{
controller = controller_ptr;
name = "AMD Wraith Prism";
vendor = "Cooler Master";
type = DEVICE_TYPE_COOLER;
description = "AMD Wraith Prism Device";
version = controller->GetFirmwareVersionString();
location = controller->GetLocationString();
mode Direct;
Direct.name = "Direct";
Direct.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_DIRECT;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Direct.brightness_min = 0;
Direct.brightness_max = 0;
Direct.brightness = 0;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_BREATHING;
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Breathing.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
Breathing.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
Breathing.brightness_min = 0;
Breathing.brightness_max = AMD_WRAITH_PRISM_FAN_BRIGHTNESS_DEFAULT_MAX;
Breathing.brightness = AMD_WRAITH_PRISM_FAN_BRIGHTNESS_DEFAULT_MAX;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathing.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
Breathing.colors.resize(3);
modes.push_back(Breathing);
mode ColorCycle;
ColorCycle.name = "Spectrum Cycle";
ColorCycle.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_COLOR_CYCLE;
ColorCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
ColorCycle.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
ColorCycle.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
ColorCycle.brightness_min = 0;
ColorCycle.brightness_max = AMD_WRAITH_PRISM_FAN_BRIGHTNESS_CYCLE_MAX;
ColorCycle.brightness = AMD_WRAITH_PRISM_FAN_BRIGHTNESS_CYCLE_MAX;
ColorCycle.color_mode = MODE_COLORS_NONE;
ColorCycle.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
modes.push_back(ColorCycle);
mode Rainbow;
Rainbow.name = "Rainbow Wave";
Rainbow.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_RAINBOW;
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Rainbow.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
Rainbow.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
Rainbow.brightness_min = 0;
Rainbow.brightness_max = AMD_WRAITH_PRISM_FAN_BRIGHTNESS_DEFAULT_MAX;
Rainbow.brightness = AMD_WRAITH_PRISM_FAN_BRIGHTNESS_DEFAULT_MAX; //The Ring zone can not get brighter but Logo / Fan can
Rainbow.color_mode = MODE_COLORS_NONE;
Rainbow.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
modes.push_back(Rainbow);
mode Bounce;
Bounce.name = "Bounce";
Bounce.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_BOUNCE;
Bounce.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Bounce.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
Bounce.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
Bounce.brightness_min = 0;
Bounce.brightness_max = AMD_WRAITH_PRISM_FAN_BRIGHTNESS_DEFAULT_MAX;
Bounce.brightness = AMD_WRAITH_PRISM_FAN_BRIGHTNESS_DEFAULT_MAX; //The Ring zone can not get brighter but Logo / Fan can
Bounce.color_mode = MODE_COLORS_NONE;
Bounce.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
modes.push_back(Bounce);
mode Chase;
Chase.name = "Chase";
Chase.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_CHASE;
Chase.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Chase.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
Chase.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
Chase.brightness_min = 0;
Chase.brightness_max = AMD_WRAITH_PRISM_FAN_BRIGHTNESS_DEFAULT_MAX;
Chase.brightness = AMD_WRAITH_PRISM_FAN_BRIGHTNESS_DEFAULT_MAX;
Chase.color_mode = MODE_COLORS_MODE_SPECIFIC;
Chase.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
Chase.colors.resize(3);
modes.push_back(Chase);
mode Swirl;
Swirl.name = "Swirl";
Swirl.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_SWIRL;
Swirl.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Swirl.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
Swirl.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
Swirl.brightness_min = 0;
Swirl.brightness_max = AMD_WRAITH_PRISM_FAN_BRIGHTNESS_DEFAULT_MAX;
Swirl.brightness = AMD_WRAITH_PRISM_FAN_BRIGHTNESS_DEFAULT_MAX;
Swirl.color_mode = MODE_COLORS_MODE_SPECIFIC;
Swirl.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
Swirl.colors.resize(3);
modes.push_back(Swirl);
SetupZones();
}
RGBController_AMDWraithPrism::~RGBController_AMDWraithPrism()
{
delete controller;
}
void RGBController_AMDWraithPrism::SetupZones()
{
/*-----------------------------------------------------*\
| LED maps |
\*-----------------------------------------------------*/
const unsigned int logo_leds[1] = { 0x00 };
const unsigned int fan_leds[1] = { 0x01 };
const unsigned int ring_leds[15] = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x10,
0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09 };
/*-----------------------------------------------------*\
| Set up zones |
\*-----------------------------------------------------*/
zone logo_zone;
logo_zone.name = "Logo";
logo_zone.type = ZONE_TYPE_SINGLE;
logo_zone.leds_min = 1;
logo_zone.leds_max = 1;
logo_zone.leds_count = 1;
logo_zone.matrix_map = NULL;
zones.push_back(logo_zone);
zone fan_zone;
fan_zone.name = "Fan";
fan_zone.type = ZONE_TYPE_SINGLE;
fan_zone.leds_min = 1;
fan_zone.leds_max = 1;
fan_zone.leds_count = 1;
fan_zone.matrix_map = NULL;
zones.push_back(fan_zone);
zone ring_zone;
ring_zone.name = "Ring";
ring_zone.type = ZONE_TYPE_LINEAR;
ring_zone.leds_min = 15;
ring_zone.leds_max = 15;
ring_zone.leds_count = 15;
ring_zone.matrix_map = NULL;
zones.push_back(ring_zone);
/*-----------------------------------------------------*\
| Set up LEDs |
\*-----------------------------------------------------*/
for(unsigned int led_idx = 0; led_idx < 1; led_idx++)
{
led logo_led;
logo_led.name = "Logo LED";
logo_led.value = logo_leds[led_idx];
leds.push_back(logo_led);
}
for(unsigned int led_idx = 0; led_idx < 1; led_idx++)
{
led fan_led;
fan_led.name = "Fan LED";
fan_led.value = fan_leds[led_idx];
leds.push_back(fan_led);
}
for(unsigned int led_idx = 0; led_idx < 15; led_idx++)
{
led ring_led;
ring_led.name = "Ring LED";
ring_led.value = ring_leds[led_idx];
leds.push_back(ring_led);
}
SetupColors();
}
void RGBController_AMDWraithPrism::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*-----------------------------------------------------*\
| This device does not support resizing zones |
\*-----------------------------------------------------*/
}
void RGBController_AMDWraithPrism::DeviceUpdateLEDs()
{
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
{
unsigned char led_ids[17];
RGBColor color_buf[17];
unsigned int leds_count;
/*-------------------------------------------------*\
| Send logo and fan LEDs in the first packet |
\*-------------------------------------------------*/
leds_count = 0;
for(std::size_t led_idx = 0; led_idx < 2; led_idx++)
{
led_ids[leds_count] = (unsigned char)leds[led_idx].value;
color_buf[leds_count] = colors[led_idx];
leds_count++;
}
controller->SendDirectPacket(leds_count, led_ids, color_buf);
/*-------------------------------------------------*\
| Send all ring LEDs in the second packet |
\*-------------------------------------------------*/
leds_count = 0;
for(std::size_t led_idx = 0; led_idx < ( colors.size() - 2 ); led_idx++)
{
led_ids[leds_count] = (unsigned char)leds[led_idx + 2].value;
color_buf[leds_count] = colors[led_idx + 2];
leds_count++;
}
controller->SendDirectPacket(leds_count, led_ids, color_buf);
}
else if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
{
unsigned char red = RGBGetRValue(modes[active_mode].colors[0]);
unsigned char grn = RGBGetGValue(modes[active_mode].colors[0]);
unsigned char blu = RGBGetBValue(modes[active_mode].colors[0]);
controller->SetLogoColor(red, grn, blu);
red = RGBGetRValue(modes[active_mode].colors[1]);
grn = RGBGetGValue(modes[active_mode].colors[1]);
blu = RGBGetBValue(modes[active_mode].colors[1]);
controller->SetFanColor(red, grn, blu);
red = RGBGetRValue(modes[active_mode].colors[2]);
grn = RGBGetGValue(modes[active_mode].colors[2]);
blu = RGBGetBValue(modes[active_mode].colors[2]);
controller->SetRingColor(red, grn, blu);
}
else
{
controller->SetLogoColor(0, 0, 0);
controller->SetFanColor(0, 0, 0);
controller->SetRingColor(0, 0, 0);
}
}
void RGBController_AMDWraithPrism::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_AMDWraithPrism::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_AMDWraithPrism::DeviceUpdateMode()
{
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
switch(modes[active_mode].value)
{
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_DIRECT:
controller->SendEnableCommand(true);
controller->SendApplyCommand();
break;
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_COLOR_CYCLE:
controller->SendEnableCommand(false);
controller->SetRingMode(modes[active_mode].value, modes[active_mode].speed, modes[active_mode].brightness, modes[active_mode].direction, random);
controller->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].brightness, random);
controller->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].brightness, random);
break;
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_RAINBOW:
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_BOUNCE:
controller->SendEnableCommand(false);
controller->SetRingMode(modes[active_mode].value, modes[active_mode].speed, modes[active_mode].brightness, modes[active_mode].direction, random);
controller->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, (modes[active_mode].brightness >> 1), random);
controller->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, (modes[active_mode].brightness >> 1), random);
break;
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_BREATHING:
controller->SendEnableCommand(false);
controller->SetRingMode(modes[active_mode].value, modes[active_mode].speed, modes[active_mode].brightness, modes[active_mode].direction, random);
controller->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_BREATHING, modes[active_mode].speed, modes[active_mode].brightness, random);
controller->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_BREATHING, modes[active_mode].speed, modes[active_mode].brightness, random);
break;
default:
if(random)
{
controller->SendEnableCommand(false);
controller->SetRingMode(modes[active_mode].value, modes[active_mode].speed, modes[active_mode].brightness, modes[active_mode].direction, random);
controller->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].brightness, random);
controller->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].brightness, random);
}
else
{
controller->SendEnableCommand(false);
controller->SetRingMode(modes[active_mode].value, modes[active_mode].speed, modes[active_mode].brightness, modes[active_mode].direction, random);
controller->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC, modes[active_mode].speed, modes[active_mode].brightness, random);
controller->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC, modes[active_mode].speed, modes[active_mode].brightness, random);
}
break;
}
DeviceUpdateLEDs();
}
@@ -0,0 +1,35 @@
/*---------------------------------------------------------*\
| RGBController_AMDWraithPrism.h |
| |
| RGBController for AMD Wraith Prism |
| |
| Adam Honse (CalcProgrammer1) 25 Dec 2019 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AMDWraithPrismController.h"
class RGBController_AMDWraithPrism : public RGBController
{
public:
RGBController_AMDWraithPrism(AMDWraithPrismController* controller_ptr);
~RGBController_AMDWraithPrism();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
AMDWraithPrismController* controller;
};