Publish LumaOps source
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| EKController.cpp |
|
||||
| |
|
||||
| Driver for EK Loop Connect |
|
||||
| |
|
||||
| Chris M (Dr_No) 16 Jul 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "EKController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
static unsigned char ek_colour_mode_data[][16] =
|
||||
{
|
||||
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
|
||||
0x00, 0x10, 0x20, 0x01, 0x01, 0x00, 0xFF, 0x64}, // Static
|
||||
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
|
||||
0x00, 0x10, 0x20, 0x01, 0x02, 0x00, 0xFF, 0x64}, // Breathing
|
||||
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
|
||||
0x00, 0x10, 0x20, 0x01, 0x03, 0xFF, 0xFF, 0x64}, // Fading
|
||||
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
|
||||
0x00, 0x10, 0x20, 0x01, 0x04, 0x00, 0xFF, 0x64}, // Marquee
|
||||
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
|
||||
0x00, 0x10, 0x20, 0x01, 0x05, 0x00, 0xFF, 0x64}, // Covering Marquee
|
||||
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
|
||||
0x00, 0x10, 0x20, 0x01, 0x06, 0x00, 0xFF, 0x64}, // Pulse
|
||||
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
|
||||
0x00, 0x10, 0x20, 0x01, 0x07, 0x00, 0xFF, 0x64}, // Wave
|
||||
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
|
||||
0x00, 0x10, 0x20, 0x01, 0x08, 0x00, 0xFF, 0x64}, // Alternating
|
||||
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
|
||||
0x00, 0x10, 0x20, 0x01, 0x09, 0x00, 0xFF, 0x64}, // Candle
|
||||
};
|
||||
|
||||
static unsigned char ek_speed_mode_data[][9] =
|
||||
{
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // Static
|
||||
{ 0x00, 0x0C, 0x19, 0x25, 0x32, 0x3E, 0x4B, 0x57, 0x64 }, // Breathing
|
||||
{ 0x00, 0x0C, 0x19, 0x25, 0x32, 0x3E, 0x4B, 0x57, 0x64 }, // Fading
|
||||
{ 0x00, 0x0C, 0x19, 0x25, 0x32, 0x3E, 0x4B, 0x57, 0x64 }, // Marquee
|
||||
{ 0x00, 0x0C, 0x19, 0x25, 0x32, 0x3E, 0x4B, 0x57, 0x64 }, // Covering Marquee
|
||||
{ 0x00, 0x0C, 0x19, 0x25, 0x32, 0x3E, 0x4B, 0x57, 0x64 }, // Pulse
|
||||
{ 0x00, 0x0C, 0x19, 0x25, 0x32, 0x3E, 0x4B, 0x57, 0x64 }, // Wave
|
||||
{ 0x00, 0x0C, 0x19, 0x25, 0x32, 0x3E, 0x4B, 0x57, 0x64 }, // Alternating
|
||||
{ 0x00, 0x0C, 0x19, 0x25, 0x32, 0x3E, 0x4B, 0x57, 0x64 } // Candle
|
||||
};
|
||||
|
||||
EKController::EKController(hid_device* dev_handle, char *_path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = _path;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Get device name from HID manufacturer and product strings |
|
||||
\*---------------------------------------------------------*/
|
||||
wchar_t name_string[HID_MAX_STR];
|
||||
|
||||
hid_get_manufacturer_string(dev, name_string, HID_MAX_STR);
|
||||
device_name = StringUtils::wstring_to_string(name_string);
|
||||
|
||||
hid_get_product_string(dev, name_string, HID_MAX_STR);
|
||||
device_name.append(" ").append(StringUtils::wstring_to_string(name_string));
|
||||
|
||||
current_mode = EK_MODE_STATIC;
|
||||
current_speed = EK_SPEED_NORMAL;
|
||||
}
|
||||
|
||||
EKController::~EKController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string EKController::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
std::string EKController::GetSerial()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
std::string EKController::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
void EKController::SetMode(unsigned char mode, unsigned char speed)
|
||||
{
|
||||
current_mode = mode;
|
||||
current_speed = speed;
|
||||
|
||||
SendUpdate();
|
||||
}
|
||||
|
||||
void EKController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
current_red = red;
|
||||
current_green = green;
|
||||
current_blue = blue;
|
||||
|
||||
SendUpdate();
|
||||
}
|
||||
|
||||
void EKController::SendUpdate()
|
||||
{
|
||||
unsigned char buffer[EK_PACKET_LENGTH] = { 0x00 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
|
||||
for(std::size_t i = 0; i < EK_COLOUR_MODE_DATA_SIZE; i++)
|
||||
{
|
||||
buffer[i] = ek_colour_mode_data[current_mode][i];
|
||||
}
|
||||
|
||||
//Set the relevant colour info
|
||||
buffer[EK_RED_BYTE] = current_red;
|
||||
buffer[EK_GREEN_BYTE] = current_green;
|
||||
buffer[EK_BLUE_BYTE] = current_blue;
|
||||
buffer[EK_SPEED_BYTE] = ek_speed_mode_data[current_mode][current_speed];
|
||||
|
||||
buffer[10] = 0x10;
|
||||
buffer[47] = 0xFF;
|
||||
buffer[48] = 0x00;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| EKController.h |
|
||||
| |
|
||||
| Driver for EK Loop Connect |
|
||||
| |
|
||||
| Chris M (Dr_No) 16 Jul 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
|
||||
#define EK_COLOUR_MODE_DATA_SIZE (sizeof(ek_colour_mode_data[0]) / sizeof(ek_colour_mode_data[0][0]))
|
||||
#define EK_DEVICE_NAME_SIZE (sizeof(device_name) / sizeof(device_name[ 0 ]))
|
||||
#define EK_PACKET_LENGTH 0x3F
|
||||
#define HID_MAX_STR 255
|
||||
|
||||
enum
|
||||
{
|
||||
EK_MODE_BYTE = 12,
|
||||
EK_SPEED_BYTE = 14,
|
||||
EK_RED_BYTE = 16,
|
||||
EK_GREEN_BYTE = 17,
|
||||
EK_BLUE_BYTE = 18
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EK_MODE_STATIC = 0x00, //Static Mode
|
||||
EK_MODE_BREATHING = 0x01, //Breathing Mode
|
||||
EK_MODE_FADING = 0x02, //Fading Mode
|
||||
EK_MODE_MARQUEE = 0x03, //Marquee Mode
|
||||
EK_MODE_COVERING_MARQUEE = 0x04, //Covering Marquee Mode
|
||||
EK_MODE_PULSE = 0x05, //Pulse Mode
|
||||
EK_MODE_SPECTRUM_WAVE = 0x06, //Spectrum Wave Mode
|
||||
EK_MODE_ALTERNATING = 0x07, //Alternating Mode
|
||||
EK_MODE_CANDLE = 0x08 //Candle Mode
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EK_SPEED_SLOWEST = 0x00, // Slowest speed
|
||||
EK_SPEED_SLOWER = 0x01, // Slower speed
|
||||
EK_SPEED_SLOW = 0x02, // Slow speed
|
||||
EK_SPEED_SLOWISH = 0x03, // Slowish speed
|
||||
EK_SPEED_NORMAL = 0x04, // Normal speed
|
||||
EK_SPEED_FASTISH = 0x05, // Fastish speed
|
||||
EK_SPEED_FAST = 0x06, // Fast speed
|
||||
EK_SPEED_FASTER = 0x07, // Faster speed
|
||||
EK_SPEED_FASTEST = 0x08, // Fastest speed
|
||||
};
|
||||
|
||||
class EKController
|
||||
{
|
||||
public:
|
||||
EKController(hid_device* dev_handle, char *_path);
|
||||
~EKController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerial();
|
||||
std::string GetLocation();
|
||||
|
||||
void SetMode(unsigned char mode, unsigned char speed);
|
||||
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
private:
|
||||
std::string device_name;
|
||||
std::string location;
|
||||
hid_device* dev;
|
||||
|
||||
unsigned char current_mode;
|
||||
unsigned char current_speed;
|
||||
|
||||
unsigned char current_red;
|
||||
unsigned char current_green;
|
||||
unsigned char current_blue;
|
||||
|
||||
void SendUpdate();
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| EKControllerDetect.cpp |
|
||||
| |
|
||||
| Detector for EK Loop Connect |
|
||||
| |
|
||||
| Chris M (Dr_No) 16 Jul 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <hidapi.h>
|
||||
#include "Detector.h"
|
||||
#include "EKController.h"
|
||||
#include "RGBController_EKController.h"
|
||||
|
||||
#define EK_VID 0x0483
|
||||
#define EK_LOOP_CONNECT 0x5750
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectEKControllers *
|
||||
* *
|
||||
* Tests the USB address to see if any EK Controllers exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectEKControllers(hid_device_info* info, const std::string&)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
EKController* controller = new EKController(dev, info->path);
|
||||
RGBController_EKController* rgb_controller = new RGBController_EKController(controller);
|
||||
// Constructor sets the name
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
} /* DetectEKControllers() */
|
||||
|
||||
REGISTER_HID_DETECTOR_IPU("EK Loop Connect", DetectEKControllers, EK_VID, EK_LOOP_CONNECT, 0, 0xFFA0, 1);
|
||||
@@ -0,0 +1,183 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_EKController.cpp |
|
||||
| |
|
||||
| RGBController for EK Loop Connect |
|
||||
| |
|
||||
| Chris M (Dr_No) 16 Jul 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_EKController.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name EK Loop Connect
|
||||
@category LEDStrip
|
||||
@type USB
|
||||
@save :robot:
|
||||
@direct :x:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectEKControllers
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_EKController::RGBController_EKController(EKController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetDeviceName();
|
||||
vendor = "EK";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = controller->GetDeviceName();
|
||||
serial = controller->GetSerial();
|
||||
location = controller->GetLocation();
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = EK_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = EK_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.speed_min = EK_SPEED_SLOWEST;
|
||||
Breathing.speed_max = EK_SPEED_FASTEST;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.speed = EK_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Fading;
|
||||
Fading.name = "Fading";
|
||||
Fading.value = EK_MODE_FADING;
|
||||
Fading.flags = MODE_FLAG_HAS_SPEED;
|
||||
Fading.speed_min = EK_SPEED_SLOWEST;
|
||||
Fading.speed_max = EK_SPEED_FASTEST;
|
||||
Fading.color_mode = MODE_COLORS_NONE;
|
||||
Fading.speed = EK_SPEED_NORMAL;
|
||||
modes.push_back(Fading);
|
||||
|
||||
mode Marquee;
|
||||
Marquee.name = "Marquee";
|
||||
Marquee.value = EK_MODE_MARQUEE;
|
||||
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Marquee.speed_min = EK_SPEED_SLOWEST;
|
||||
Marquee.speed_max = EK_SPEED_FASTEST;
|
||||
Marquee.color_mode = MODE_COLORS_PER_LED;
|
||||
Marquee.speed = EK_SPEED_NORMAL;
|
||||
modes.push_back(Marquee);
|
||||
|
||||
mode Covering_Marquee;
|
||||
Covering_Marquee.name = "Covering Marquee";
|
||||
Covering_Marquee.value = EK_MODE_COVERING_MARQUEE;
|
||||
Covering_Marquee.flags = MODE_FLAG_HAS_SPEED;
|
||||
Covering_Marquee.speed_min = EK_SPEED_SLOWEST;
|
||||
Covering_Marquee.speed_max = EK_SPEED_FASTEST;
|
||||
Covering_Marquee.color_mode = MODE_COLORS_NONE;
|
||||
Covering_Marquee.speed = EK_SPEED_NORMAL;
|
||||
modes.push_back(Covering_Marquee);
|
||||
|
||||
mode Pulse;
|
||||
Pulse.name = "Pulse";
|
||||
Pulse.value = EK_MODE_PULSE;
|
||||
Pulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Pulse.speed_min = EK_SPEED_SLOWEST;
|
||||
Pulse.speed_max = EK_SPEED_FASTEST;
|
||||
Pulse.color_mode = MODE_COLORS_PER_LED;
|
||||
Pulse.speed = EK_SPEED_NORMAL;
|
||||
modes.push_back(Pulse);
|
||||
|
||||
mode Spectrum_Wave;
|
||||
Spectrum_Wave.name = "Spectrum_Wave";
|
||||
Spectrum_Wave.value = EK_MODE_SPECTRUM_WAVE;
|
||||
Spectrum_Wave.flags = MODE_FLAG_HAS_SPEED;
|
||||
Spectrum_Wave.speed_min = EK_SPEED_SLOWEST;
|
||||
Spectrum_Wave.speed_max = EK_SPEED_FASTEST;
|
||||
Spectrum_Wave.color_mode = MODE_COLORS_NONE;
|
||||
Spectrum_Wave.speed = EK_SPEED_NORMAL;
|
||||
modes.push_back(Spectrum_Wave);
|
||||
|
||||
mode Alternating;
|
||||
Alternating.name = "Alternating";
|
||||
Alternating.value = EK_MODE_ALTERNATING;
|
||||
Alternating.flags = MODE_FLAG_HAS_SPEED;
|
||||
Alternating.speed_min = EK_SPEED_SLOWEST;
|
||||
Alternating.speed_max = EK_SPEED_FASTEST;
|
||||
Alternating.color_mode = MODE_COLORS_PER_LED;
|
||||
Alternating.speed = EK_SPEED_NORMAL;
|
||||
modes.push_back(Alternating);
|
||||
|
||||
mode Candle;
|
||||
Candle.name = "Candle";
|
||||
Candle.value = EK_MODE_CANDLE;
|
||||
Candle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Candle.speed_min = EK_SPEED_SLOWEST;
|
||||
Candle.speed_max = EK_SPEED_FASTEST;
|
||||
Candle.color_mode = MODE_COLORS_PER_LED;
|
||||
Candle.speed = EK_SPEED_NORMAL;
|
||||
modes.push_back(Candle);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_EKController::~RGBController_EKController()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_EKController::SetupZones()
|
||||
{
|
||||
zone EK_zone;
|
||||
EK_zone.name = "Loop Connect";
|
||||
EK_zone.type = ZONE_TYPE_SINGLE;
|
||||
EK_zone.leds_min = 1;
|
||||
EK_zone.leds_max = 1;
|
||||
EK_zone.leds_count = 1;
|
||||
EK_zone.matrix_map = NULL;
|
||||
zones.push_back(EK_zone);
|
||||
|
||||
led EK_led;
|
||||
EK_led.name = "EK LED";
|
||||
leds.push_back(EK_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_EKController::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| ToDo |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_EKController::DeviceUpdateLEDs()
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
|
||||
controller->SetColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_EKController::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
RGBColor color = colors[zone];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
controller->SetColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_EKController::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateZoneLEDs(led);
|
||||
}
|
||||
|
||||
void RGBController_EKController::DeviceUpdateMode()
|
||||
{
|
||||
controller->SetMode(modes[active_mode].value, modes[active_mode].speed);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_EKController.h |
|
||||
| |
|
||||
| RGBController for EK Loop Connect |
|
||||
| |
|
||||
| Chris M (Dr_No) 16 Jul 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "EKController.h"
|
||||
|
||||
class RGBController_EKController : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_EKController(EKController* controller_ptr);
|
||||
~RGBController_EKController();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
EKController* controller;
|
||||
};
|
||||
Reference in New Issue
Block a user