mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-05-24 06:25:01 -04:00
Update file header comments and minor code cleanup
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| AirgooLustrousCommanderController.cpp |
|
||||
| AirgooLustrousCommanderController.cpp |
|
||||
| |
|
||||
| Processing Code for Airgoo Lustrous Commander |
|
||||
| Based on code by: |
|
||||
| Jeff P (@jeffp1), 2020/02/07 |
|
||||
| Driver for Airgoo Lustrous Commander |
|
||||
| |
|
||||
| Zacahry G. |
|
||||
| Zacahry Guinn 07 Feb 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "AirgooLustrousCommanderController.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include "AirgooLustrousCommanderController.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
@@ -20,14 +20,11 @@ AirgooLustrousCommanderController::AirgooLustrousCommanderController(hid_device*
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
controller_ready = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Initialize controller |
|
||||
\*-----------------------------------------------------*/
|
||||
InitController();
|
||||
|
||||
|
||||
}
|
||||
|
||||
AirgooLustrousCommanderController::~AirgooLustrousCommanderController()
|
||||
@@ -41,9 +38,9 @@ AirgooLustrousCommanderController::~AirgooLustrousCommanderController()
|
||||
void AirgooLustrousCommanderController::InitController()
|
||||
{
|
||||
unsigned char usb_buf[AIRGOO_LUSTROUS_COMMANDER_PACKET_SIZE];
|
||||
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Initialize Controller |
|
||||
| Send initialization packet |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
@@ -56,7 +53,7 @@ void AirgooLustrousCommanderController::InitController()
|
||||
|
||||
//expecting the device to return AA 55 01
|
||||
hid_read(dev, usb_buf, AIRGOO_LUSTROUS_COMMANDER_PACKET_SIZE);
|
||||
|
||||
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = 0x03;
|
||||
usb_buf[0x02] = 0x55;
|
||||
@@ -67,9 +64,6 @@ void AirgooLustrousCommanderController::InitController()
|
||||
hid_write(dev, usb_buf, AIRGOO_LUSTROUS_COMMANDER_PACKET_SIZE);
|
||||
|
||||
//device will send aa 55 00 back and it seems that we should be ready to send commands at this point
|
||||
|
||||
controller_ready = 1;
|
||||
|
||||
}
|
||||
|
||||
std::string AirgooLustrousCommanderController::GetLocationString()
|
||||
@@ -82,20 +76,21 @@ void AirgooLustrousCommanderController::SetMode(unsigned char mode)
|
||||
active_mode = mode;
|
||||
}
|
||||
|
||||
|
||||
void AirgooLustrousCommanderController::UpdateDevice(
|
||||
void AirgooLustrousCommanderController::UpdateDevice
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu,
|
||||
unsigned char speed)
|
||||
unsigned char speed
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet with leading 00 |
|
||||
| Set up message packet with leading 00 |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| AirgooLustrousCommanderController.h |
|
||||
| AirgooLustrousCommanderController.h |
|
||||
| |
|
||||
| Definitions for Airgoo Lustrous Commander |
|
||||
| Based on code by: |
|
||||
| Jeff P (@jeffp1), 2020/02/07 |
|
||||
| Driver for Airgoo Lustrous Commander |
|
||||
| |
|
||||
| Zachary G |
|
||||
| Zacahry Guinn 07 Feb 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
#define AIRGOO_LUSTROUS_COMMANDER_PACKET_SIZE 65
|
||||
#define AIRGOO_LUSTROUS_COMMANDER_NUM_RGB_CHANNELS 2
|
||||
#define AIRGOO_LUSTROUS_COMMANDER_NUM_FAN_CHANNELS 4
|
||||
#include <chrono>
|
||||
#include <vector>
|
||||
#include <hidapi.h>
|
||||
#include "RGBController.h"
|
||||
|
||||
#define AIRGOO_LUSTROUS_COMMANDER_PACKET_SIZE 65
|
||||
#define AIRGOO_LUSTROUS_COMMANDER_NUM_RGB_CHANNELS 2
|
||||
#define AIRGOO_LUSTROUS_COMMANDER_NUM_FAN_CHANNELS 4
|
||||
|
||||
class AirgooLustrousCommanderController
|
||||
{
|
||||
@@ -38,11 +39,9 @@ public:
|
||||
unsigned char speed
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
unsigned char active_mode;
|
||||
std::atomic<bool> controller_ready;
|
||||
std::string location;
|
||||
|
||||
void InitController();
|
||||
|
||||
@@ -1,19 +1,30 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| AirgooLustrousCommanderControllerDetect.cpp |
|
||||
| |
|
||||
| Detector for Airgoo Lustrous Commander |
|
||||
| |
|
||||
| Zacahry Guinn 07 Feb 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <vector>
|
||||
#include <hidapi.h>
|
||||
#include "Detector.h"
|
||||
#include "AirgooLustrousCommanderController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AirgooLustrousCommander.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Airgoo vendor ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define AIRGOO_VID 0x1A86
|
||||
/*---------------------------------------------------------*\
|
||||
| Airgoo vendor ID |
|
||||
\*---------------------------------------------------------*/
|
||||
#define AIRGOO_VID 0x1A86
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Lustrous Commander product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define AIRGOO_LUSTROUS_COMMANDER_PID 0xE6E0
|
||||
/*---------------------------------------------------------*\
|
||||
| Lustrous Commander product IDs |
|
||||
\*---------------------------------------------------------*/
|
||||
#define AIRGOO_LUSTROUS_COMMANDER_PID 0xE6E0
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -31,8 +42,7 @@ void DetectAirgooLustrousCommanderHIDControllers(hid_device_info* info, const st
|
||||
{
|
||||
AirgooLustrousCommanderController* controller = new AirgooLustrousCommanderController(dev, info->path);
|
||||
RGBController_AirgooLustrousCommander* rgb_controller = new RGBController_AirgooLustrousCommander(controller);
|
||||
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AirgooLustrousCommander.cpp|
|
||||
| |
|
||||
| Generic RGB Interface for Airgoo |
|
||||
| Based on code by: |
|
||||
| Jeff P (@jeffp1), 2020/02/07 |
|
||||
| |
|
||||
| Zachary G |
|
||||
\*-----------------------------------------*/
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_AirgooLustrousCommander.cpp |
|
||||
| |
|
||||
| RGBController for Airgoo Lustrous Commander |
|
||||
| |
|
||||
| Zacahry Guinn 07 Feb 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_AirgooLustrousCommander.h"
|
||||
|
||||
@@ -19,74 +20,6 @@ RGBController_AirgooLustrousCommander::RGBController_AirgooLustrousCommander(Air
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
location = controller->GetLocationString();
|
||||
|
||||
SetupZones();
|
||||
SetupModes();
|
||||
}
|
||||
|
||||
RGBController_AirgooLustrousCommander::~RGBController_AirgooLustrousCommander()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_AirgooLustrousCommander::SetupZones()
|
||||
{
|
||||
std::atomic<bool> first_run;
|
||||
first_run = 0;
|
||||
|
||||
if(zones.size() == 0)
|
||||
{
|
||||
first_run = 1;
|
||||
}
|
||||
|
||||
zones.resize(3);
|
||||
|
||||
for(unsigned int i = 1; i < (AIRGOO_LUSTROUS_COMMANDER_NUM_RGB_CHANNELS + 1); i++)
|
||||
{
|
||||
zones[i].name = "RGB Port " + std::to_string(i);
|
||||
zones[i].type = ZONE_TYPE_LINEAR;
|
||||
zones[i].leds_min = 1;
|
||||
zones[i].leds_max = 34;
|
||||
|
||||
if(first_run)
|
||||
{
|
||||
zones[i].leds_count = 1;
|
||||
}
|
||||
}
|
||||
|
||||
leds.clear();
|
||||
colors.clear();
|
||||
|
||||
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
for (unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = zones[zone_idx].name + " LED " + std::to_string(led_idx+1);
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_AirgooLustrousCommander::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
if((size_t) zone >= zones.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AirgooLustrousCommander::SetupModes()
|
||||
{
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = 0;
|
||||
@@ -171,6 +104,69 @@ void RGBController_AirgooLustrousCommander::SetupModes()
|
||||
// ColorMeteor.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
// modes.push_back(ColorMeteor);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_AirgooLustrousCommander::~RGBController_AirgooLustrousCommander()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_AirgooLustrousCommander::SetupZones()
|
||||
{
|
||||
std::atomic<bool> first_run;
|
||||
first_run = 0;
|
||||
|
||||
if(zones.size() == 0)
|
||||
{
|
||||
first_run = 1;
|
||||
}
|
||||
|
||||
zones.resize(3);
|
||||
|
||||
for(unsigned int i = 1; i < (AIRGOO_LUSTROUS_COMMANDER_NUM_RGB_CHANNELS + 1); i++)
|
||||
{
|
||||
zones[i].name = "RGB Port " + std::to_string(i);
|
||||
zones[i].type = ZONE_TYPE_LINEAR;
|
||||
zones[i].leds_min = 0;
|
||||
zones[i].leds_max = 34;
|
||||
|
||||
if(first_run)
|
||||
{
|
||||
zones[i].leds_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
leds.clear();
|
||||
colors.clear();
|
||||
|
||||
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
for (unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = zones[zone_idx].name + " LED " + std::to_string(led_idx+1);
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_AirgooLustrousCommander::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
if((size_t) zone >= zones.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AirgooLustrousCommander::DeviceUpdateLEDs()
|
||||
@@ -205,4 +201,4 @@ void RGBController_AirgooLustrousCommander::DeviceUpdateMode()
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
controller->UpdateDevice(modes[active_mode].value, red, grn, blu, modes[active_mode].speed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AirgooLustrousCommander.h |
|
||||
| |
|
||||
| Generic RGB Interface for Airgoo |
|
||||
| Lustrous Commander |
|
||||
| Based on code by: |
|
||||
| Jeff P (@jeffp1), 2020/02/07 |
|
||||
| |
|
||||
| Zachary G |
|
||||
\*-----------------------------------------*/
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_AirgooLustrousCommander.cpp |
|
||||
| |
|
||||
| RGBController for Airgoo Lustrous Commander |
|
||||
| |
|
||||
| Zacahry Guinn 07 Feb 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AirgooLustrousCommanderController.h"
|
||||
|
||||
@@ -21,8 +22,8 @@ public:
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void SetupModes();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
@@ -30,6 +31,6 @@ public:
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
AirgooLustrousCommanderController* controller;
|
||||
AirgooLustrousCommanderController* controller;
|
||||
std::vector<int> fanleds{0};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user