mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-05-24 06:25:01 -04:00
Clean up to match the libusb version of this controller
This commit is contained in:
@@ -17,8 +17,6 @@ HYTEMousematController::HYTEMousematController(char* port)
|
||||
| Baud rate doesn't matter for ACM device |
|
||||
\*-----------------------------------------------------*/
|
||||
serialport = new serial_port(port_name.c_str(), 2000000);
|
||||
|
||||
FirmwareAnimationControl(false);
|
||||
}
|
||||
|
||||
HYTEMousematController::~HYTEMousematController()
|
||||
@@ -35,13 +33,22 @@ void HYTEMousematController::FirmwareAnimationControl(bool enabled)
|
||||
{
|
||||
unsigned char serial_buf[4];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(serial_buf, 0, sizeof(serial_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Firmware Animation Control packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0] = 0xFF;
|
||||
serial_buf[1] = 0xDC;
|
||||
serial_buf[2] = 0x05;
|
||||
serial_buf[3] = enabled;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serialport->serial_write((char *)serial_buf, sizeof(serial_buf));
|
||||
}
|
||||
|
||||
@@ -50,8 +57,14 @@ void HYTEMousematController::StreamingCommand(RGBColor* colors)
|
||||
unsigned char serial_buf[157];
|
||||
unsigned int max_brightness = 72;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(serial_buf, 0, sizeof(serial_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Streaming packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0] = 0xFF;
|
||||
serial_buf[1] = 0xEE;
|
||||
serial_buf[2] = 0x02;
|
||||
@@ -60,6 +73,9 @@ void HYTEMousematController::StreamingCommand(RGBColor* colors)
|
||||
serial_buf[5] = 0x32;
|
||||
serial_buf[6] = 0x00;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in colors |
|
||||
\*-----------------------------------------------------*/
|
||||
for(unsigned int color_idx = 0; color_idx < 50; color_idx++)
|
||||
{
|
||||
serial_buf[7 + (color_idx * 3)] = ( max_brightness * RGBGetGValue(colors[color_idx]) ) / 100;
|
||||
@@ -67,6 +83,8 @@ void HYTEMousematController::StreamingCommand(RGBColor* colors)
|
||||
serial_buf[9 + (color_idx * 3)] = ( max_brightness * RGBGetBValue(colors[color_idx]) ) / 100;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serialport->serial_write((char *)serial_buf, sizeof(serial_buf));
|
||||
serialport->serial_flush_tx();
|
||||
}
|
||||
|
||||
@@ -20,11 +20,20 @@ RGBController_HYTEMousemat::RGBController_HYTEMousemat(HYTEMousematController* c
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.value = HYTE_CNVS_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
// HYTE CNVS does not seem to be able to transfer back into firmware animation
|
||||
// after streaming command has been used
|
||||
//mode Rainbow;
|
||||
//Rainbow.name = "Rainbow Wave";
|
||||
//Rainbow.value = HYTE_CNVS_MODE_RAINBOW;
|
||||
//Rainbow.flags = MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
//Rainbow.color_mode = MODE_COLORS_RANDOM;
|
||||
//modes.push_back(Rainbow);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
@@ -65,7 +74,6 @@ void RGBController_HYTEMousemat::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
|
||||
void RGBController_HYTEMousemat::DeviceUpdateLEDs()
|
||||
{
|
||||
printf("DeviceUpdateLEDs called\r\n");
|
||||
controller->StreamingCommand(&colors[0]);
|
||||
}
|
||||
|
||||
@@ -81,5 +89,14 @@ void RGBController_HYTEMousemat::UpdateSingleLED(int /*led*/)
|
||||
|
||||
void RGBController_HYTEMousemat::DeviceUpdateMode()
|
||||
{
|
||||
switch(modes[active_mode].value)
|
||||
{
|
||||
case HYTE_CNVS_MODE_DIRECT:
|
||||
controller->FirmwareAnimationControl(false);
|
||||
break;
|
||||
|
||||
case HYTE_CNVS_MODE_RAINBOW:
|
||||
controller->FirmwareAnimationControl(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
#include "RGBController.h"
|
||||
#include "HYTEMousematController.h"
|
||||
|
||||
enum
|
||||
{
|
||||
HYTE_CNVS_MODE_DIRECT = 0, /* Direct (streaming) mode */
|
||||
HYTE_CNVS_MODE_RAINBOW = 1, /* Rainbow wave (firmware animation) mode */
|
||||
};
|
||||
|
||||
class RGBController_HYTEMousemat : public RGBController
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user