Clean up usb Asus motherboard (Aura) controller
This commit is contained in:
parent
9436b55556
commit
2ec52b68ba
5 changed files with 59 additions and 118 deletions
|
|
@ -28,37 +28,12 @@ AuraAddressableController::~AuraAddressableController()
|
|||
|
||||
void AuraAddressableController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
|
||||
{
|
||||
unsigned char led_data[60];
|
||||
unsigned int leds_sent = 0;
|
||||
|
||||
while(leds_sent < num_colors)
|
||||
{
|
||||
unsigned int leds_to_send = 20;
|
||||
|
||||
if((num_colors - leds_sent) < leds_to_send)
|
||||
{
|
||||
leds_to_send = num_colors - leds_sent;
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < leds_to_send; led_idx++)
|
||||
{
|
||||
led_data[(led_idx * 3) + 0] = RGBGetRValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 1] = RGBGetGValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 2] = RGBGetBValue(colors[led_idx + leds_sent]);
|
||||
}
|
||||
|
||||
SendDirect
|
||||
(
|
||||
channel,
|
||||
leds_sent,
|
||||
leds_to_send,
|
||||
led_data
|
||||
);
|
||||
|
||||
leds_sent += leds_to_send;
|
||||
}
|
||||
|
||||
SendDirectApply(channel);
|
||||
SendDirect
|
||||
(
|
||||
device_info[channel].direct_channel,
|
||||
num_colors,
|
||||
colors
|
||||
);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SetMode
|
||||
|
|
@ -117,28 +92,3 @@ void AuraAddressableController::SendEffect
|
|||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SendDirectApply
|
||||
(
|
||||
unsigned char channel
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_CONTROL_MODE_DIRECT;
|
||||
usb_buf[0x02] = 0x80 | channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,9 +52,4 @@ private:
|
|||
unsigned char grn,
|
||||
unsigned char blu
|
||||
);
|
||||
|
||||
void SendDirectApply
|
||||
(
|
||||
unsigned char channel
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,36 +46,13 @@ AuraMainboardController::~AuraMainboardController()
|
|||
|
||||
void AuraMainboardController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
|
||||
{
|
||||
unsigned char led_data[60];
|
||||
unsigned int leds_sent = 0;
|
||||
SendDirect
|
||||
(
|
||||
device_info[channel].direct_channel,
|
||||
num_colors,
|
||||
colors
|
||||
);
|
||||
|
||||
while(leds_sent < num_colors)
|
||||
{
|
||||
unsigned int leds_to_send = 20;
|
||||
|
||||
if((num_colors - leds_sent) < leds_to_send)
|
||||
{
|
||||
leds_to_send = num_colors - leds_sent;
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < leds_to_send; led_idx++)
|
||||
{
|
||||
led_data[(led_idx * 3) + 0] = RGBGetRValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 1] = RGBGetGValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 2] = RGBGetBValue(colors[led_idx + leds_sent]);
|
||||
}
|
||||
|
||||
SendDirect
|
||||
(
|
||||
device_info[channel].direct_channel,
|
||||
leds_sent,
|
||||
leds_to_send,
|
||||
led_data,
|
||||
leds_sent + leds_to_send >= num_colors
|
||||
);
|
||||
|
||||
leds_sent += leds_to_send;
|
||||
}
|
||||
}
|
||||
|
||||
void AuraMainboardController::SetMode
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#include "LogManager.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
|
||||
AuraUSBController::AuraUSBController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
|
|
@ -144,36 +143,56 @@ void AuraUSBController::GetFirmwareVersion()
|
|||
void AuraUSBController::SendDirect
|
||||
(
|
||||
unsigned char device,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data,
|
||||
bool apply /* = false */
|
||||
RGBColor* colors
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
unsigned char offset = 0x00;
|
||||
unsigned char sent_led_count = LEDS_PER_PACKET;
|
||||
bool apply = false;
|
||||
while(!apply)
|
||||
{
|
||||
if(offset + sent_led_count > led_count)
|
||||
{
|
||||
sent_led_count = led_count - offset;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_CONTROL_MODE_DIRECT;
|
||||
usb_buf[0x02] = apply ? 0x80 : 0x00;
|
||||
usb_buf[0x02] |= device;
|
||||
usb_buf[0x03] = start_led;
|
||||
usb_buf[0x04] = led_count;
|
||||
if(offset + sent_led_count == led_count)
|
||||
{
|
||||
apply = true;
|
||||
}
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x05], led_data, led_count * 3);
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_CONTROL_MODE_DIRECT;
|
||||
usb_buf[0x02] = (apply ? 0x80 : 0x00) | device;
|
||||
usb_buf[0x03] = offset;
|
||||
usb_buf[0x04] = sent_led_count;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
for(unsigned char led_idx = 0; led_idx < sent_led_count; led_idx++)
|
||||
{
|
||||
|
||||
usb_buf[0x05 + (led_idx * 3)] = RGBGetRValue(colors[offset + led_idx]);
|
||||
usb_buf[0x06 + (led_idx * 3)] = RGBGetGValue(colors[offset + led_idx]);
|
||||
usb_buf[0x07 + (led_idx * 3)] = RGBGetBValue(colors[offset + led_idx]);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
|
||||
offset += sent_led_count;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ enum class AuraDeviceType
|
|||
ADDRESSABLE,
|
||||
};
|
||||
|
||||
#define LEDS_PER_PACKET 0x14;
|
||||
|
||||
struct AuraDeviceInfo
|
||||
{
|
||||
unsigned char effect_channel;
|
||||
|
|
@ -97,10 +99,8 @@ protected:
|
|||
void SendDirect
|
||||
(
|
||||
unsigned char device,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data,
|
||||
bool apply = false
|
||||
RGBColor * colors
|
||||
);
|
||||
private:
|
||||
char device_name[16];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue