mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-05-24 14:35:01 -04:00
Initial fan controller API and Thermaltake Riing controller implementation
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
/*-----------------------------------------*\
|
||||
| FanController_ThermaltakeRiing.cpp |
|
||||
| |
|
||||
| Generic Fan Interface for Thermaltake |
|
||||
| Riing controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/5/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "FanController_ThermaltakeRiing.h"
|
||||
|
||||
FanController_ThermaltakeRiing::FanController_ThermaltakeRiing(ThermaltakeRiingController* riing_ptr)
|
||||
{
|
||||
riing = riing_ptr;
|
||||
|
||||
name = "Thermaltake Riing";
|
||||
description = "Thermaltake Riing Device";
|
||||
version = riing->GetFirmwareVersion();
|
||||
|
||||
for(std::size_t fan_index = 0; fan_index < THERMALTAKE_NUM_CHANNELS; fan_index++)
|
||||
{
|
||||
fan new_fan;
|
||||
unsigned char speed;
|
||||
unsigned short rpm;
|
||||
|
||||
riing->GetFanData(fan_index + 1, &speed, &rpm);
|
||||
|
||||
new_fan.name = "Thermaltake Riing Fan ";
|
||||
new_fan.name.append(std::to_string(fan_index + 1));
|
||||
new_fan.speed_min = THERMALTAKE_FAN_SPEED_MIN;
|
||||
new_fan.speed_max = THERMALTAKE_FAN_SPEED_MAX;
|
||||
new_fan.speed_cmd = speed;
|
||||
new_fan.rpm_rdg = rpm;
|
||||
|
||||
fans.push_back(new_fan);
|
||||
}
|
||||
|
||||
|
||||
UpdateControl();
|
||||
}
|
||||
|
||||
void FanController_ThermaltakeRiing::UpdateControl()
|
||||
{
|
||||
for(std::size_t fan_index = 0; fan_index < fans.size(); fan_index++)
|
||||
{
|
||||
riing->SendFan(fan_index + 1, THERMALTAKE_FAN_MODE_FIXED, fans[fan_index].speed_cmd);
|
||||
}
|
||||
}
|
||||
|
||||
void FanController_ThermaltakeRiing::UpdateReading()
|
||||
{
|
||||
for(std::size_t fan_index = 0; fan_index < fans.size(); fan_index++)
|
||||
{
|
||||
unsigned char speed;
|
||||
unsigned short rpm;
|
||||
|
||||
riing->GetFanData(fan_index + 1, &speed, &rpm);
|
||||
|
||||
fans[fan_index].rpm_rdg = rpm;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*-----------------------------------------*\
|
||||
| FanController_ThermaltakeRiing.h |
|
||||
| |
|
||||
| Generic Fan Interface for Thermaltake |
|
||||
| Riing controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/5/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "FanController.h"
|
||||
#include "ThermaltakeRiingController.h"
|
||||
|
||||
class FanController_ThermaltakeRiing : public FanController
|
||||
{
|
||||
public:
|
||||
FanController_ThermaltakeRiing(ThermaltakeRiingController* riing_ptr);
|
||||
|
||||
void UpdateControl();
|
||||
void UpdateReading();
|
||||
|
||||
private:
|
||||
ThermaltakeRiingController* riing;
|
||||
};
|
||||
@@ -44,6 +44,37 @@ std::string ThermaltakeRiingController::GetSerialString()
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
void ThermaltakeRiingController::GetFanData
|
||||
(
|
||||
unsigned char port,
|
||||
unsigned char * speed,
|
||||
unsigned short * rpm
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Get Fan Data packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x33;
|
||||
usb_buf[0x01] = 0x51;
|
||||
usb_buf[0x02] = port;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
|
||||
*speed = usb_buf[0x04];
|
||||
*rpm = (usb_buf[0x06] << 8) + usb_buf[0x05];
|
||||
}
|
||||
|
||||
std::string ThermaltakeRiingController::GetFirmwareVersion()
|
||||
{
|
||||
unsigned char usb_buf[64];
|
||||
@@ -120,6 +151,36 @@ void ThermaltakeRiingController::SendInit()
|
||||
hid_read(dev, usb_buf, 65);
|
||||
}
|
||||
|
||||
void ThermaltakeRiingController::SendFan
|
||||
(
|
||||
unsigned char port,
|
||||
unsigned char mode,
|
||||
unsigned char speed
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up RGB packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x32;
|
||||
usb_buf[0x01] = 0x51;
|
||||
usb_buf[0x02] = port;
|
||||
usb_buf[0x03] = mode;
|
||||
usb_buf[0x04] = speed;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
}
|
||||
|
||||
void ThermaltakeRiingController::SendRGB
|
||||
(
|
||||
unsigned char port,
|
||||
|
||||
@@ -44,6 +44,18 @@ enum
|
||||
THERMALTAKE_SPEED_EXTREME = 0x00
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
THERMALTAKE_FAN_MODE_FIXED = 0x01,
|
||||
THERMALTAKE_FAN_MODE_PWM = 0x02
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
THERMALTAKE_FAN_SPEED_MIN = 20,
|
||||
THERMALTAKE_FAN_SPEED_MAX = 100
|
||||
};
|
||||
|
||||
#define THERMALTAKE_NUM_CHANNELS 5
|
||||
|
||||
class ThermaltakeRiingController
|
||||
@@ -56,9 +68,23 @@ public:
|
||||
std::string GetSerialString();
|
||||
std::string GetFirmwareVersion();
|
||||
|
||||
void GetFanData
|
||||
(
|
||||
unsigned char port,
|
||||
unsigned char * speed,
|
||||
unsigned short * rpm
|
||||
);
|
||||
|
||||
void SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors);
|
||||
void SetMode(unsigned char mode, unsigned char speed);
|
||||
|
||||
void SendFan
|
||||
(
|
||||
unsigned char port,
|
||||
unsigned char mode,
|
||||
unsigned char speed
|
||||
);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
|
||||
@@ -68,15 +94,14 @@ private:
|
||||
|
||||
void SendInit();
|
||||
|
||||
void SendRGB
|
||||
(
|
||||
unsigned char port,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char num_colors,
|
||||
unsigned char* color_data
|
||||
);
|
||||
void SendRGB
|
||||
(
|
||||
unsigned char port,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char num_colors,
|
||||
unsigned char* color_data
|
||||
);
|
||||
|
||||
void SendFan();
|
||||
void SendSave();
|
||||
};
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "Detector.h"
|
||||
#include "ThermaltakeRiingController.h"
|
||||
#include "ThermaltakeRiingQuadController.h"
|
||||
#include "FanController.h"
|
||||
#include "FanController_ThermaltakeRiing.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_ThermaltakeRiing.h"
|
||||
#include "RGBController_ThermaltakeRiingQuad.h"
|
||||
@@ -40,6 +42,10 @@ void DetectThermaltakeRiingControllers(hid_device_info* info, const std::string&
|
||||
RGBController_ThermaltakeRiing* rgb_controller = new RGBController_ThermaltakeRiing(controller);
|
||||
// Constructor sets the name
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
|
||||
FanController_ThermaltakeRiing* fan_controller = new FanController_ThermaltakeRiing(controller);
|
||||
|
||||
ResourceManager::get()->RegisterFanController(fan_controller);
|
||||
}
|
||||
} /* DetectThermaltakeRiingControllers() */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user