Code cleanup round 4

This commit is contained in:
Adam Honse 2022-01-18 20:20:22 -06:00
parent c09e4c9c92
commit c07f43c8d5
20 changed files with 988 additions and 992 deletions

View file

@ -1,37 +1,39 @@
#include "Detector.h"
#include "RGBController.h"
#include "ATC800Controller.h"
#include "RGBController_AorusATC800.h"
#include <hidapi/hidapi.h>
/*-----------------------------------------------------*\
| Vendor ID |
\*-----------------------------------------------------*/
#define HOLTEK_VID 0x1044
/*-----------------------------------------------------*\
| Controller product ids |
\*-----------------------------------------------------*/
#define ATC_800_CONTROLLER_PID 0x7A42
/******************************************************************************************\
* *
* DetectAorusCPUCoolerControllers *
* *
* Tests the USB address to see if a Aorus RGB CPU Cooler exists there. *
* *
\******************************************************************************************/
void DetectGigabyteAorusCPUCoolerControllers(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
ATC800Controller* controller = new ATC800Controller(dev, info->path);
RGBController_AorusATC800* rgb_controller = new RGBController_AorusATC800(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_HID_DETECTOR_IPU("Aorus CPU Coolers", DetectGigabyteAorusCPUCoolerControllers, HOLTEK_VID, ATC_800_CONTROLLER_PID, 0, 0xFF01, 1);
#include "Detector.h"
#include "RGBController.h"
#include "ATC800Controller.h"
#include "RGBController_AorusATC800.h"
#include <hidapi/hidapi.h>
/*-----------------------------------------------------*\
| Vendor ID |
\*-----------------------------------------------------*/
#define HOLTEK_VID 0x1044
/*-----------------------------------------------------*\
| Controller product ids |
\*-----------------------------------------------------*/
#define ATC_800_CONTROLLER_PID 0x7A42
/******************************************************************************************\
* *
* DetectAorusCPUCoolerControllers *
* *
* Tests the USB address to see if a Aorus RGB CPU Cooler exists there. *
* *
\******************************************************************************************/
void DetectGigabyteAorusCPUCoolerControllers(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
ATC800Controller* controller = new ATC800Controller(dev, info->path);
RGBController_AorusATC800* rgb_controller = new RGBController_AorusATC800(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_HID_DETECTOR_IPU("Aorus CPU Coolers", DetectGigabyteAorusCPUCoolerControllers, HOLTEK_VID, ATC_800_CONTROLLER_PID, 0, 0xFF01, 1);

View file

@ -1,150 +1,150 @@
/*-----------------------------------------*\
| RGBController_AorusATC800.cpp |
| |
| Generic RGB Interface Aorus ATC800 CPU |
| Cooler |
| |
| Felipe Cavalcanti 08/13/2020 |
\*-----------------------------------------*/
#include "RGBController_AorusATC800.h"
RGBController_AorusATC800::RGBController_AorusATC800(ATC800Controller* cooler_ptr)
{
cooler = cooler_ptr;
name = "Aorus ATC800 CPU Cooler";
vendor = "Gigabyte";
type = DEVICE_TYPE_COOLER;
description = "Aorus ATC800 CPU Cooler";
location = cooler->GetDeviceLocation();
serial = cooler->GetSerialString();
mode Static;
Static.name = "Static";
Static.value = AORUS_ATC800_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
mode Off;
Off.name = "Off";
Off.value = AORUS_ATC800_MODE_OFF;
Off.flags = 0;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
mode Flashing;
Flashing.name = "Flashing";
Flashing.value = AORUS_ATC800_MODE_FLASHING;
Flashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
Flashing.color_mode = MODE_COLORS_PER_LED;
Flashing.speed_min = AORUS_ATC800_SPEED_SLOWEST;
Flashing.speed_max = AORUS_ATC800_SPEED_FASTEST;
Flashing.speed = AORUS_ATC800_SPEED_NORMAL;
modes.push_back(Flashing);
mode DoubleFlashing;
DoubleFlashing.name = "Double Flashing";
DoubleFlashing.value = AORUS_ATC800_MODE_DOUBLE_FLASH;
DoubleFlashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
DoubleFlashing.color_mode = MODE_COLORS_PER_LED;
DoubleFlashing.speed_min = AORUS_ATC800_SPEED_SLOWEST;
DoubleFlashing.speed_max = AORUS_ATC800_SPEED_FASTEST;
DoubleFlashing.speed = AORUS_ATC800_SPEED_NORMAL;
modes.push_back(DoubleFlashing);
mode Pulsing;
Pulsing.name = "Pulsing";
Pulsing.value = AORUS_ATC800_MODE_PULSE;
Pulsing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
Pulsing.color_mode = MODE_COLORS_PER_LED;
Pulsing.speed_min = AORUS_ATC800_SPEED_SLOWEST;
Pulsing.speed_max = AORUS_ATC800_SPEED_FASTEST;
Pulsing.speed = AORUS_ATC800_SPEED_NORMAL;
modes.push_back(Pulsing);
SetupZones();
}
RGBController_AorusATC800::~RGBController_AorusATC800()
{
delete cooler;
}
void RGBController_AorusATC800::SetupZones()
{
zone atc800_cpu_fans_zone;
atc800_cpu_fans_zone.name = "Fan";
atc800_cpu_fans_zone.type = ZONE_TYPE_SINGLE;
atc800_cpu_fans_zone.leds_min = 1;
atc800_cpu_fans_zone.leds_max = 1;
atc800_cpu_fans_zone.leds_count = 1;
atc800_cpu_fans_zone.matrix_map = NULL;
zones.push_back(atc800_cpu_fans_zone);
led atc800_fan_led;
atc800_fan_led.name = "Fan";
leds.push_back(atc800_fan_led);
zone atc800_top_zone;
atc800_top_zone.name = "Top";
atc800_top_zone.type = ZONE_TYPE_SINGLE;
atc800_top_zone.leds_min = 1;
atc800_top_zone.leds_max = 1;
atc800_top_zone.leds_count = 1;
atc800_top_zone.matrix_map = NULL;
zones.push_back(atc800_top_zone);
led atc800_top_led;
atc800_top_led.name = "Top";
leds.push_back(atc800_top_led);
SetupColors();
}
void RGBController_AorusATC800::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_AorusATC800::DeviceUpdateLEDs()
{
UpdateZoneLEDs(0);
UpdateZoneLEDs(1);
}
void RGBController_AorusATC800::UpdateZoneLEDs(int zone)
{
unsigned char mode = modes[active_mode].value;
unsigned char red = RGBGetRValue(colors[zone]);
unsigned char grn = RGBGetGValue(colors[zone]);
unsigned char blu = RGBGetBValue(colors[zone]);
if (mode == AORUS_ATC800_MODE_OFF)
{
mode = 1;
red = 0;
grn = 0;
blu = 0;
}
cooler->SendCoolerMode(mode, modes[active_mode].speed, zone, red, grn, blu);
}
void RGBController_AorusATC800::UpdateSingleLED(int led)
{
UpdateZoneLEDs(led);
}
void RGBController_AorusATC800::SetCustomMode()
{
}
void RGBController_AorusATC800::DeviceUpdateMode()
{
DeviceUpdateLEDs();
}
/*-----------------------------------------*\
| RGBController_AorusATC800.cpp |
| |
| Generic RGB Interface Aorus ATC800 CPU |
| Cooler |
| |
| Felipe Cavalcanti 08/13/2020 |
\*-----------------------------------------*/
#include "RGBController_AorusATC800.h"
RGBController_AorusATC800::RGBController_AorusATC800(ATC800Controller* controller_ptr)
{
controller = controller_ptr;
name = "Aorus ATC800 CPU Cooler";
vendor = "Gigabyte";
type = DEVICE_TYPE_COOLER;
description = "Aorus ATC800 CPU Cooler";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Static;
Static.name = "Static";
Static.value = AORUS_ATC800_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
mode Off;
Off.name = "Off";
Off.value = AORUS_ATC800_MODE_OFF;
Off.flags = 0;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
mode Flashing;
Flashing.name = "Flashing";
Flashing.value = AORUS_ATC800_MODE_FLASHING;
Flashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
Flashing.color_mode = MODE_COLORS_PER_LED;
Flashing.speed_min = AORUS_ATC800_SPEED_SLOWEST;
Flashing.speed_max = AORUS_ATC800_SPEED_FASTEST;
Flashing.speed = AORUS_ATC800_SPEED_NORMAL;
modes.push_back(Flashing);
mode DoubleFlashing;
DoubleFlashing.name = "Double Flashing";
DoubleFlashing.value = AORUS_ATC800_MODE_DOUBLE_FLASH;
DoubleFlashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
DoubleFlashing.color_mode = MODE_COLORS_PER_LED;
DoubleFlashing.speed_min = AORUS_ATC800_SPEED_SLOWEST;
DoubleFlashing.speed_max = AORUS_ATC800_SPEED_FASTEST;
DoubleFlashing.speed = AORUS_ATC800_SPEED_NORMAL;
modes.push_back(DoubleFlashing);
mode Pulsing;
Pulsing.name = "Pulsing";
Pulsing.value = AORUS_ATC800_MODE_PULSE;
Pulsing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
Pulsing.color_mode = MODE_COLORS_PER_LED;
Pulsing.speed_min = AORUS_ATC800_SPEED_SLOWEST;
Pulsing.speed_max = AORUS_ATC800_SPEED_FASTEST;
Pulsing.speed = AORUS_ATC800_SPEED_NORMAL;
modes.push_back(Pulsing);
SetupZones();
}
RGBController_AorusATC800::~RGBController_AorusATC800()
{
delete controller;
}
void RGBController_AorusATC800::SetupZones()
{
zone atc800_cpu_fans_zone;
atc800_cpu_fans_zone.name = "Fan";
atc800_cpu_fans_zone.type = ZONE_TYPE_SINGLE;
atc800_cpu_fans_zone.leds_min = 1;
atc800_cpu_fans_zone.leds_max = 1;
atc800_cpu_fans_zone.leds_count = 1;
atc800_cpu_fans_zone.matrix_map = NULL;
zones.push_back(atc800_cpu_fans_zone);
led atc800_fan_led;
atc800_fan_led.name = "Fan";
leds.push_back(atc800_fan_led);
zone atc800_top_zone;
atc800_top_zone.name = "Top";
atc800_top_zone.type = ZONE_TYPE_SINGLE;
atc800_top_zone.leds_min = 1;
atc800_top_zone.leds_max = 1;
atc800_top_zone.leds_count = 1;
atc800_top_zone.matrix_map = NULL;
zones.push_back(atc800_top_zone);
led atc800_top_led;
atc800_top_led.name = "Top";
leds.push_back(atc800_top_led);
SetupColors();
}
void RGBController_AorusATC800::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_AorusATC800::DeviceUpdateLEDs()
{
UpdateZoneLEDs(0);
UpdateZoneLEDs(1);
}
void RGBController_AorusATC800::UpdateZoneLEDs(int zone)
{
unsigned char mode = modes[active_mode].value;
unsigned char red = RGBGetRValue(colors[zone]);
unsigned char grn = RGBGetGValue(colors[zone]);
unsigned char blu = RGBGetBValue(colors[zone]);
if(mode == AORUS_ATC800_MODE_OFF)
{
mode = 1;
red = 0;
grn = 0;
blu = 0;
}
controller->SendCoolerMode(mode, modes[active_mode].speed, zone, red, grn, blu);
}
void RGBController_AorusATC800::UpdateSingleLED(int led)
{
UpdateZoneLEDs(led);
}
void RGBController_AorusATC800::SetCustomMode()
{
}
void RGBController_AorusATC800::DeviceUpdateMode()
{
DeviceUpdateLEDs();
}

View file

@ -1,33 +1,33 @@
/*-----------------------------------------*\
| RGBController_AorusATC800.h |
| |
| Generic RGB Interface for Aorus ATC 800 |
| CPU Cooler |
| |
| Felipe Cavalcanti 08/13/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "ATC800Controller.h"
class RGBController_AorusATC800 : public RGBController
{
public:
RGBController_AorusATC800(ATC800Controller* logitech_ptr);
~RGBController_AorusATC800();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
ATC800Controller* cooler;
};
/*-----------------------------------------*\
| RGBController_AorusATC800.h |
| |
| Generic RGB Interface for Aorus ATC 800 |
| CPU Cooler |
| |
| Felipe Cavalcanti 08/13/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "ATC800Controller.h"
class RGBController_AorusATC800 : public RGBController
{
public:
RGBController_AorusATC800(ATC800Controller* controller_ptr);
~RGBController_AorusATC800();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
ATC800Controller* controller;
};