Rework packet sending to get it working in Linux
This commit is contained in:
parent
67bc2053d0
commit
c6a527b505
2 changed files with 33 additions and 13 deletions
|
|
@ -4,6 +4,8 @@
|
|||
| interface for Wushi L50 Devices |
|
||||
\*-------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "WushiL50USBController.h"
|
||||
|
||||
WushiL50USBController::WushiL50USBController(hidapi_wrapper hid_wrapper, hid_device* dev_handle, const char* path)
|
||||
|
|
@ -20,7 +22,36 @@ WushiL50USBController::~WushiL50USBController()
|
|||
|
||||
void WushiL50USBController::setMode(WushiL50State * in_mode)
|
||||
{
|
||||
wrapper.hid_send_feature_report(dev, (uint8_t *)in_mode, WUSHI_L50_HID_PACKET_SIZE);
|
||||
unsigned char usb_buf[WUSHI_L50_HID_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up custom lighting packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x16;
|
||||
usb_buf[0x01] = in_mode->effect;
|
||||
usb_buf[0x02] = in_mode->speed;
|
||||
usb_buf[0x03] = in_mode->brightness;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x04], in_mode->zone0_rgb, 3);
|
||||
memcpy(&usb_buf[0x07], in_mode->zone0_rgb, 3);
|
||||
memcpy(&usb_buf[0x0A], in_mode->zone0_rgb, 3);
|
||||
memcpy(&usb_buf[0x0D], in_mode->zone0_rgb, 3);
|
||||
|
||||
usb_buf[0x11] = in_mode->wave_ltr;
|
||||
usb_buf[0x12] = in_mode->wave_rtl;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
wrapper.hid_send_feature_report(dev, usb_buf, WUSHI_L50_HID_PACKET_SIZE);
|
||||
}
|
||||
|
||||
std::string WushiL50USBController::getName()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
#define HID_MAX_STR 255
|
||||
#endif
|
||||
|
||||
#define WUSHI_L50_HID_PACKET_SIZE 33
|
||||
#define WUSHI_L50_HID_PACKET_SIZE 65
|
||||
#define WUSHI_L50_NUM_LEDS 4
|
||||
|
||||
enum WUSHI_L50_EFFECT
|
||||
|
|
@ -53,7 +53,6 @@ enum WUSHI_L50_Direction
|
|||
class WushiL50State
|
||||
{
|
||||
public:
|
||||
uint8_t header[2] = {0xCC, 0x16};
|
||||
uint8_t effect = WUSHI_L50_EFFECT_STATIC;
|
||||
uint8_t speed = WUSHI_L50_SPEED_SLOWEST;
|
||||
uint8_t brightness = WUSHI_L50_BRIGHTNESS_LOW;
|
||||
|
|
@ -61,26 +60,16 @@ public:
|
|||
uint8_t zone1_rgb[3] = {0xFF, 0xFF, 0xFF};
|
||||
uint8_t zone2_rgb[3] = {0xFF, 0xFF, 0xFF};
|
||||
uint8_t zone3_rgb[3] = {0xFF, 0xFF, 0xFF};
|
||||
uint8_t padding = 0;
|
||||
uint8_t wave_ltr = 0;
|
||||
uint8_t wave_rtl = 0;
|
||||
uint8_t unused[13] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
void Reset()
|
||||
{
|
||||
header[0] = 0xCC;
|
||||
header[1] = 0x16;
|
||||
effect = WUSHI_L50_EFFECT_STATIC;
|
||||
speed = WUSHI_L50_SPEED_SLOWEST;
|
||||
brightness = WUSHI_L50_BRIGHTNESS_LOW;
|
||||
padding = 0;
|
||||
wave_ltr = 0;
|
||||
wave_rtl = 0;
|
||||
|
||||
for(int i = 0; i < 13; ++i)
|
||||
{
|
||||
unused[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void SetColors(std::vector<RGBColor> group_colors)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue