Add mode control to Thermaltake Riing controller

This commit is contained in:
Adam Honse 2020-02-09 15:26:20 -06:00
parent 7ad3c18e3f
commit 2cd0b64251
4 changed files with 120 additions and 9 deletions

View file

@ -20,7 +20,7 @@ ThermaltakeRiingController::ThermaltakeRiingController(libusb_device_handle* dev
channel_leds[0] = 9;
channel_leds[1] = 9;
channel_leds[2] = 9;
channel_leds[4] = 0;
channel_leds[3] = 0;
channel_leds[4] = 0;
}
@ -31,7 +31,7 @@ ThermaltakeRiingController::~ThermaltakeRiingController()
void ThermaltakeRiingController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
{
unsigned char* color_data = new unsigned char[colors.size()];
unsigned char* color_data = new unsigned char[3 * colors.size()];
for(int color = 0; color < colors.size(); color++)
{
@ -41,11 +41,17 @@ void ThermaltakeRiingController::SetChannelLEDs(unsigned char channel, std::vect
color_data[color_idx + 2] = RGBGetBValue(colors[color]);
}
SendRGB(channel, THERMALTAKE_MODE_PER_LED, THERMALTAKE_SPEED_FAST, colors.size(), color_data);
SendRGB(channel, current_mode, current_speed, colors.size(), color_data);
delete[] color_data;
}
void ThermaltakeRiingController::SetMode(unsigned char mode, unsigned char speed)
{
current_mode = mode;
current_speed = speed;
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/

View file

@ -48,12 +48,16 @@ public:
ThermaltakeRiingController(libusb_device_handle* dev_handle);
~ThermaltakeRiingController();
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
void SetMode(unsigned char mode, unsigned char speed);
unsigned int channel_leds[5];
private:
libusb_device_handle* dev;
unsigned char current_mode;
unsigned char current_speed;
void SendInit();

View file

@ -18,6 +18,78 @@ RGBController_ThermaltakeRiing::RGBController_ThermaltakeRiing(ThermaltakeRiingC
type = DEVICE_TYPE_COOLER;
mode Flow;
Flow.name = "Flow";
Flow.value = THERMALTAKE_MODE_FLOW;
Flow.flags = MODE_FLAG_HAS_SPEED;
Flow.speed_min = THERMALTAKE_SPEED_SLOW;
Flow.speed_max = THERMALTAKE_SPEED_EXTREME;
Flow.speed = THERMALTAKE_SPEED_NORMAL;
modes.push_back(Flow);
mode Spectrum;
Spectrum.name = "Spectrum";
Spectrum.value = THERMALTAKE_MODE_SPECTRUM;
Spectrum.flags = MODE_FLAG_HAS_SPEED;
Spectrum.speed_min = THERMALTAKE_SPEED_SLOW;
Spectrum.speed_max = THERMALTAKE_SPEED_EXTREME;
Spectrum.speed = THERMALTAKE_SPEED_NORMAL;
modes.push_back(Spectrum);
mode Ripple;
Ripple.name = "Ripple";
Ripple.value = THERMALTAKE_MODE_RIPPLE;
Ripple.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR;
Ripple.speed_min = THERMALTAKE_SPEED_SLOW;
Ripple.speed_max = THERMALTAKE_SPEED_EXTREME;
Ripple.speed = THERMALTAKE_SPEED_NORMAL;
modes.push_back(Ripple);
mode Blink;
Blink.name = "Blink";
Blink.value = THERMALTAKE_MODE_BLINK;
Blink.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
Blink.speed_min = THERMALTAKE_SPEED_SLOW;
Blink.speed_max = THERMALTAKE_SPEED_EXTREME;
Blink.speed = THERMALTAKE_SPEED_NORMAL;
modes.push_back(Blink);
mode Pulse;
Pulse.name = "Pulse";
Pulse.value = THERMALTAKE_MODE_PULSE;
Pulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
Pulse.speed_min = THERMALTAKE_SPEED_SLOW;
Pulse.speed_max = THERMALTAKE_SPEED_EXTREME;
Pulse.speed = THERMALTAKE_SPEED_NORMAL;
modes.push_back(Pulse);
mode Wave;
Wave.name = "Wave";
Wave.value = THERMALTAKE_MODE_WAVE;
Wave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
Wave.speed_min = THERMALTAKE_SPEED_SLOW;
Wave.speed_max = THERMALTAKE_SPEED_EXTREME;
Wave.speed = THERMALTAKE_SPEED_NORMAL;
modes.push_back(Wave);
mode Direct;
Direct.name = "Direct";
Direct.value = THERMALTAKE_MODE_PER_LED;
Direct.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
Direct.speed_min = 0;
Direct.speed_max = 0;
Direct.speed = 0;
modes.push_back(Direct);
mode Static;
Static.name = "Static";
Static.value = THERMALTAKE_MODE_FULL;
Static.flags = MODE_FLAG_HAS_COLOR;
Static.speed_min = 0;
Static.speed_max = 0;
Static.speed = 0;
modes.push_back(Static);
/*-------------------------------------------------*\
| Set size of colors array |
\*-------------------------------------------------*/
@ -137,8 +209,29 @@ void RGBController_ThermaltakeRiing::UpdateSingleLED(int led)
void RGBController_ThermaltakeRiing::SetCustomMode()
{
SetMode(6);
}
void RGBController_ThermaltakeRiing::UpdateMode()
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
unsigned int channel = zones_channel[zone_idx];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
riing->SetMode(modes[active_mode].value, modes[active_mode].speed);
riing->SetChannelLEDs(channel, channel_colors);
}
}
}

View file

@ -348,7 +348,7 @@ void Ui::OpenRGBDevicePage::UpdateMode()
| Read user interface |
\*-----------------------------------------------------*/
int current_mode = ui->ModeBox->currentIndex();
int current_speed = ui->SpeedSlider->value();
int current_speed = 0;
bool current_random = ui->RandomCheck->checkState();
int current_dir_idx = ui->DirectionBox->currentIndex();
int current_direction = 0;
@ -396,11 +396,19 @@ void Ui::OpenRGBDevicePage::UpdateMode()
device->modes[current_mode].direction = current_direction;
/*-----------------------------------------------------*\
| If Speed Slider is inverted, invert value |
| If Speed Slider is enabled, read the speed value |
\*-----------------------------------------------------*/
if(InvertedSpeed)
if(ui->SpeedSlider->isEnabled())
{
current_speed = device->modes[current_mode].speed_min - current_speed + device->modes[current_mode].speed_max;
current_speed = ui->SpeedSlider->value();
/*-----------------------------------------------------*\
| If Speed Slider is inverted, invert value |
\*-----------------------------------------------------*/
if(InvertedSpeed)
{
current_speed = device->modes[current_mode].speed_min - current_speed + device->modes[current_mode].speed_max;
}
}
/*-----------------------------------------------------*\