Add Luxafor pattern modes

This commit is contained in:
Adam Honse 2024-09-05 22:59:20 -05:00
parent ae826f2fd0
commit f115d2cbd9
4 changed files with 168 additions and 13 deletions

View file

@ -42,21 +42,88 @@ std::string LuxaforController::GetSerialString()
return(StringUtils::wstring_to_string(serial_string));
}
void LuxaforController::SendPacket(unsigned char mode, unsigned char led, unsigned char red, unsigned char grn, unsigned char blu)
void LuxaforController::SendPacket(unsigned char mode, unsigned char led, unsigned char red, unsigned char grn, unsigned char blu, unsigned char type)
{
unsigned char usb_buf[9];
memset(usb_buf, 0, sizeof(usb_buf));
usb_buf[0] = 0x00;
usb_buf[1] = mode;
usb_buf[2] = led;
usb_buf[3] = red;
usb_buf[4] = grn;
usb_buf[5] = blu;
usb_buf[6] = 100;
usb_buf[7] = 0;
usb_buf[8] = 255;
switch(mode)
{
/*-------------------------------------------------*\
| For Direct, Fade, and Strobe, the packet format: |
| 0: Report ID (Always 0) |
| 1: Mode (1: Direct, 2: Fade, 3: Strobe) |
| 2: LED Index |
| 3: Red |
| 4: Green |
| 5: Blue |
| 6: Changing Time (Fade) / Speed (Strobe) |
| 7: Unused |
| 8: Repeat (Strobe) |
\*-------------------------------------------------*/
case LUXAFOR_MODE_DIRECT:
case LUXAFOR_MODE_FADE:
case LUXAFOR_MODE_STROBE:
usb_buf[0] = 0x00;
usb_buf[1] = mode;
usb_buf[2] = led;
usb_buf[3] = red;
usb_buf[4] = grn;
usb_buf[5] = blu;
usb_buf[6] = 100;
usb_buf[7] = 0;
usb_buf[8] = (mode == LUXAFOR_MODE_STROBE) ? 255 : 0;
break;
/*-------------------------------------------------*\
| For Wave, the packet format: |
| 0: Report ID (Always 0) |
| 1: Mode (4: Wave) |
| 2: Wave Type (1-5) |
| 3: Red |
| 4: Green |
| 5: Blue |
| 6: Unused |
| 7: Repeat |
| 8: Speed |
\*-------------------------------------------------*/
case LUXAFOR_MODE_WAVE:
usb_buf[0] = 0x00;
usb_buf[1] = mode;
usb_buf[2] = type;
usb_buf[3] = red;
usb_buf[4] = grn;
usb_buf[5] = blu;
usb_buf[6] = 0;
usb_buf[7] = 255;
usb_buf[8] = 100;
break;
/*-------------------------------------------------*\
| For Pattern, the packet format: |
| 0: Report ID (Always 0) |
| 1: Mode (6: Pattern) |
| 2: Pattern Number (1-8) |
| 3: Repeat |
| 4: Unused |
| 5: Unused |
| 6: Unused |
| 7: Unused |
| 8: Unused |
\*-------------------------------------------------*/
case LUXAFOR_MODE_PATTERN:
usb_buf[0] = 0x00;
usb_buf[1] = mode;
usb_buf[2] = type;
usb_buf[3] = 255;
usb_buf[4] = 0;
usb_buf[5] = 0;
usb_buf[6] = 0;
usb_buf[7] = 0;
usb_buf[8] = 0;
break;
}
hid_write(dev, usb_buf, sizeof(usb_buf));
}

View file

@ -29,6 +29,18 @@ enum
LUXAFOR_MODE_PATTERN = 6,
};
enum
{
LUXAFOR_PATTERN_TRAFFIC_LIGHTS = 1,
LUXAFOR_PATTERN_2 = 2,
LUXAFOR_PATTERN_3 = 3,
LUXAFOR_PATTERN_4 = 4,
LUXAFOR_PATTERN_POLICE = 5,
LUXAFOR_PATTERN_6 = 6,
LUXAFOR_PATTERN_7 = 7,
LUXAFOR_PATTERN_8 = 8,
};
class LuxaforController
{
public:
@ -38,7 +50,7 @@ public:
std::string GetDeviceLocation();
std::string GetSerialString();
void SendPacket(unsigned char mode, unsigned char led, unsigned char red, unsigned char grn, unsigned char blu);
void SendPacket(unsigned char mode, unsigned char led, unsigned char red, unsigned char grn, unsigned char blu, unsigned char type);
private:
hid_device* dev;

View file

@ -56,6 +56,62 @@ RGBController_Luxafor::RGBController_Luxafor(LuxaforController* controller_ptr)
// Wave.colors.resize(1);
// modes.push_back(Wave);
mode TrafficLights;
TrafficLights.name = "Traffic Lights";
TrafficLights.value = LUXAFOR_MODE_PATTERN_TRAFFIC_LIGHTS;
TrafficLights.flags = 0;
TrafficLights.color_mode = MODE_COLORS_NONE;
modes.push_back(TrafficLights);
mode Pattern2;
Pattern2.name = "Pattern 2";
Pattern2.value = LUXAFOR_MODE_PATTERN_2;
Pattern2.flags = 0;
Pattern2.color_mode = MODE_COLORS_NONE;
modes.push_back(Pattern2);
mode Pattern3;
Pattern3.name = "Pattern 3";
Pattern3.value = LUXAFOR_MODE_PATTERN_3;
Pattern3.flags = 0;
Pattern3.color_mode = MODE_COLORS_NONE;
modes.push_back(Pattern3);
mode Pattern4;
Pattern4.name = "Pattern 4";
Pattern4.value = LUXAFOR_MODE_PATTERN_4;
Pattern4.flags = 0;
Pattern4.color_mode = MODE_COLORS_NONE;
modes.push_back(Pattern4);
mode Police;
Police.name = "Police";
Police.value = LUXAFOR_MODE_PATTERN_POLICE;
Police.flags = 0;
Police.color_mode = MODE_COLORS_NONE;
modes.push_back(Police);
mode Pattern6;
Pattern6.name = "Pattern 6";
Pattern6.value = LUXAFOR_MODE_PATTERN_6;
Pattern6.flags = 0;
Pattern6.color_mode = MODE_COLORS_NONE;
modes.push_back(Pattern6);
mode Pattern7;
Pattern7.name = "Pattern 7";
Pattern7.value = LUXAFOR_MODE_PATTERN_7;
Pattern7.flags = 0;
Pattern7.color_mode = MODE_COLORS_NONE;
modes.push_back(Pattern7);
mode Pattern8;
Pattern8.name = "Pattern 8";
Pattern8.value = LUXAFOR_MODE_PATTERN_8;
Pattern8.flags = 0;
Pattern8.color_mode = MODE_COLORS_NONE;
modes.push_back(Pattern8);
SetupZones();
}
@ -147,7 +203,7 @@ void RGBController_Luxafor::UpdateSingleLED(int led)
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
controller->SendPacket(modes[active_mode].value, leds[led].value, red, grn, blu);
controller->SendPacket((modes[active_mode].value & 0xFF), leds[led].value, red, grn, blu, 0);
}
}
@ -165,9 +221,13 @@ void RGBController_Luxafor::DeviceUpdateMode()
unsigned char grn = RGBGetGValue(colors[modes[active_mode].colors[0]]);
unsigned char blu = RGBGetBValue(colors[modes[active_mode].colors[0]]);
controller->SendPacket(modes[active_mode].value, LUXAFOR_LED_ALL, red, grn, blu);
controller->SendPacket((modes[active_mode].value & 0xFF), LUXAFOR_LED_ALL, red, grn, blu, 0);
}
break;
case MODE_COLORS_NONE:
controller->SendPacket((modes[active_mode].value & 0xFF), LUXAFOR_LED_ALL, 0, 0, 0, (modes[active_mode].value >> 8));
break;
}
}

View file

@ -14,6 +14,22 @@
#include "LuxaforController.h"
#include "RGBController.h"
/*---------------------------------------------------------*\
| Additional "pseudo-modes" which combine pattern mode with |
| the pattern to use. |
\*---------------------------------------------------------*/
enum
{
LUXAFOR_MODE_PATTERN_TRAFFIC_LIGHTS = LUXAFOR_MODE_PATTERN + (LUXAFOR_PATTERN_TRAFFIC_LIGHTS << 8),
LUXAFOR_MODE_PATTERN_2 = LUXAFOR_MODE_PATTERN + (LUXAFOR_PATTERN_2 << 8),
LUXAFOR_MODE_PATTERN_3 = LUXAFOR_MODE_PATTERN + (LUXAFOR_PATTERN_3 << 8),
LUXAFOR_MODE_PATTERN_4 = LUXAFOR_MODE_PATTERN + (LUXAFOR_PATTERN_4 << 8),
LUXAFOR_MODE_PATTERN_POLICE = LUXAFOR_MODE_PATTERN + (LUXAFOR_PATTERN_POLICE << 8),
LUXAFOR_MODE_PATTERN_6 = LUXAFOR_MODE_PATTERN + (LUXAFOR_PATTERN_6 << 8),
LUXAFOR_MODE_PATTERN_7 = LUXAFOR_MODE_PATTERN + (LUXAFOR_PATTERN_7 << 8),
LUXAFOR_MODE_PATTERN_8 = LUXAFOR_MODE_PATTERN + (LUXAFOR_PATTERN_8 << 8),
};
class RGBController_Luxafor : public RGBController
{
public: