Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
748e9a5df4 | ||
|
|
a865ca5881 |
@@ -0,0 +1,133 @@
|
||||
/*-----------------------------------------*\
|
||||
| CrucialController.cpp |
|
||||
| |
|
||||
| Driver for Crucial Ballistix RGB lighting|
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/19/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "CrucialController.h"
|
||||
#include <cstring>
|
||||
|
||||
CrucialController::CrucialController(i2c_smbus_interface* bus, crucial_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
}
|
||||
|
||||
CrucialController::~CrucialController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string CrucialController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string CrucialController::GetDeviceLocation()
|
||||
{
|
||||
std::string return_string(bus->device_name);
|
||||
char addr[5];
|
||||
snprintf(addr, 5, "0x%02X", dev);
|
||||
return_string.append(", address ");
|
||||
return_string.append(addr);
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
unsigned int CrucialController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
void CrucialController::SetMode(unsigned char mode)
|
||||
{
|
||||
SendEffectMode(mode, 0x10);
|
||||
}
|
||||
|
||||
void CrucialController::SetAllColorsDirect(RGBColor* colors)
|
||||
{
|
||||
SendDirectColors(colors);
|
||||
}
|
||||
|
||||
void CrucialController::SendEffectColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
CrucialRegisterWrite(0x82E9, 0xFF);
|
||||
CrucialRegisterWrite(0x82EA, 0x00);
|
||||
CrucialRegisterWrite(0x82EB, 0x00);
|
||||
CrucialRegisterWrite(0x82EC, 0x00);
|
||||
CrucialRegisterWrite(0x82ED, red);
|
||||
CrucialRegisterWrite(0x82EE, green);
|
||||
CrucialRegisterWrite(0x82EF, blue);
|
||||
CrucialRegisterWrite(0x82F0, 0x01);
|
||||
}
|
||||
|
||||
void CrucialController::SendBrightness(unsigned char brightness)
|
||||
{
|
||||
CrucialRegisterWrite(0x82EE, 0xFF);
|
||||
CrucialRegisterWrite(0x82EF, brightness);
|
||||
CrucialRegisterWrite(0x82F0, 0x83);
|
||||
}
|
||||
|
||||
void CrucialController::SendEffectMode(unsigned char mode, unsigned char speed)
|
||||
{
|
||||
CrucialRegisterWrite(0x820F, mode);
|
||||
CrucialRegisterWrite(0x82EE, 0x00);
|
||||
CrucialRegisterWrite(0x82EF, speed);
|
||||
CrucialRegisterWrite(0x82F0, 0x84);
|
||||
}
|
||||
|
||||
void CrucialController::SendDirectColors(RGBColor* color_buf)
|
||||
{
|
||||
//Red Channels
|
||||
CrucialRegisterWrite(0x8300, RGBGetRValue(color_buf[0]));
|
||||
CrucialRegisterWrite(0x8301, RGBGetRValue(color_buf[1]));
|
||||
CrucialRegisterWrite(0x8302, RGBGetRValue(color_buf[2]));
|
||||
CrucialRegisterWrite(0x8303, RGBGetRValue(color_buf[3]));
|
||||
CrucialRegisterWrite(0x8304, RGBGetRValue(color_buf[4]));
|
||||
CrucialRegisterWrite(0x8305, RGBGetRValue(color_buf[5]));
|
||||
CrucialRegisterWrite(0x8306, RGBGetRValue(color_buf[6]));
|
||||
CrucialRegisterWrite(0x8307, RGBGetRValue(color_buf[7]));
|
||||
|
||||
//Green Channels
|
||||
CrucialRegisterWrite(0x8340, RGBGetGValue(color_buf[0]));
|
||||
CrucialRegisterWrite(0x8341, RGBGetGValue(color_buf[1]));
|
||||
CrucialRegisterWrite(0x8342, RGBGetGValue(color_buf[2]));
|
||||
CrucialRegisterWrite(0x8343, RGBGetGValue(color_buf[3]));
|
||||
CrucialRegisterWrite(0x8344, RGBGetGValue(color_buf[4]));
|
||||
CrucialRegisterWrite(0x8345, RGBGetGValue(color_buf[5]));
|
||||
CrucialRegisterWrite(0x8346, RGBGetGValue(color_buf[6]));
|
||||
CrucialRegisterWrite(0x8347, RGBGetGValue(color_buf[7]));
|
||||
|
||||
//Blue Channels
|
||||
CrucialRegisterWrite(0x8380, RGBGetBValue(color_buf[0]));
|
||||
CrucialRegisterWrite(0x8381, RGBGetBValue(color_buf[1]));
|
||||
CrucialRegisterWrite(0x8382, RGBGetBValue(color_buf[2]));
|
||||
CrucialRegisterWrite(0x8383, RGBGetBValue(color_buf[3]));
|
||||
CrucialRegisterWrite(0x8384, RGBGetBValue(color_buf[4]));
|
||||
CrucialRegisterWrite(0x8385, RGBGetBValue(color_buf[5]));
|
||||
CrucialRegisterWrite(0x8386, RGBGetBValue(color_buf[6]));
|
||||
CrucialRegisterWrite(0x8387, RGBGetBValue(color_buf[7]));
|
||||
}
|
||||
|
||||
unsigned char CrucialController::CrucialRegisterRead(crucial_register reg)
|
||||
{
|
||||
//Write Crucial register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Read Crucial value
|
||||
return(bus->i2c_smbus_read_byte_data(dev, 0x81));
|
||||
|
||||
}
|
||||
|
||||
void CrucialController::CrucialRegisterWrite(crucial_register reg, unsigned char val)
|
||||
{
|
||||
//Write Crucial register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Write Crucial value
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x01, val);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*-----------------------------------------*\
|
||||
| CrucialController.h |
|
||||
| |
|
||||
| Definitions and types for Crucial |
|
||||
| Ballistix RGB lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/19/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char crucial_dev_id;
|
||||
typedef unsigned short crucial_register;
|
||||
|
||||
enum
|
||||
{
|
||||
CRUCIAL_MODE_SHIFT = 0x1F, /* Shift effect mode */
|
||||
CRUCIAL_MODE_GRADIENT_SHIFT = 0x2F, /* Gradient shift mode */
|
||||
CRUCIAL_MODE_FILL = 0x3F, /* Fill effect mode */
|
||||
CRUCIAL_MODE_STACK = 0x4F, /* Stack effect mode */
|
||||
CRUCIAL_MODE_DOUBLE_STACK = 0x5F, /* Double stack effect mode */
|
||||
CRUCIAL_MODE_BREATHING = 0x6F, /* Breathing effect mode */
|
||||
CRUCIAL_MODE_MOTION_POINT = 0x7F, /* Motion point effect mode */
|
||||
CRUCIAL_MODE_INSIDE_OUT = 0x8F, /* Inside out effect mode */
|
||||
CRUCIAL_MODE_COLOR_STEP = 0x9F, /* Color step effect mode */
|
||||
CRUCIAL_MODE_WATER_WAVE = 0xAF, /* Water wave effect mode */
|
||||
CRUCIAL_MODE_FLASHING = 0xBF, /* Flashing effect mode */
|
||||
CRUCIAL_MODE_STATIC = 0xCF, /* Static effect mode */
|
||||
};
|
||||
|
||||
class CrucialController
|
||||
{
|
||||
public:
|
||||
CrucialController(i2c_smbus_interface* bus, crucial_dev_id dev);
|
||||
~CrucialController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
unsigned int GetLEDCount();
|
||||
void SetAllColorsDirect(RGBColor* colors);
|
||||
void SetMode(unsigned char mode);
|
||||
|
||||
unsigned char CrucialRegisterRead(crucial_register reg);
|
||||
void CrucialRegisterWrite(crucial_register reg, unsigned char val);
|
||||
|
||||
private:
|
||||
char device_name[16];
|
||||
unsigned char config_table[64];
|
||||
unsigned int led_count;
|
||||
unsigned char channel_cfg;
|
||||
i2c_smbus_interface * bus;
|
||||
crucial_dev_id dev;
|
||||
|
||||
void SendDirectColors(RGBColor* color_buf);
|
||||
void SendEffectColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SendBrightness(unsigned char brightness);
|
||||
void SendEffectMode(unsigned char mode, unsigned char speed);
|
||||
};
|
||||
@@ -0,0 +1,88 @@
|
||||
#include "CrucialController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_Crucial.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
| This list contains the available SMBus addresses for Crucial RAM |
|
||||
\*----------------------------------------------------------------------*/
|
||||
#define CRUCIAL_ADDRESS_COUNT 4
|
||||
|
||||
static const unsigned char crucial_addresses[] =
|
||||
{
|
||||
0x20,
|
||||
0x21,
|
||||
0x22,
|
||||
0x22
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForCrucialController *
|
||||
* *
|
||||
* Tests the given address to see if an Crucial controller exists there. First does a*
|
||||
* quick write to test for a response, and if so does a simple read at 0xA0 to test *
|
||||
* for incrementing values 0...F which was observed at this location during data dump *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForCrucialController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
for (int i = 0xA0; i < 0xB0; i++)
|
||||
{
|
||||
res = bus->i2c_smbus_read_byte_data(address, i);
|
||||
|
||||
if (res != (i - 0xA0))
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForCrucialController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCrucialControllers *
|
||||
* *
|
||||
* Detect Crucial controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
CrucialController* new_crucial;
|
||||
RGBController_Crucial* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Add Crucial controllers
|
||||
for (unsigned int address_list_idx = 0; address_list_idx < CRUCIAL_ADDRESS_COUNT; address_list_idx++)
|
||||
{
|
||||
if (TestForCrucialController(busses[bus], crucial_addresses[address_list_idx]))
|
||||
{
|
||||
new_crucial = new CrucialController(busses[bus], crucial_addresses[address_list_idx]);
|
||||
new_controller = new RGBController_Crucial(new_crucial);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectCrucialControllers() */
|
||||
@@ -320,6 +320,7 @@ void DetectI2CBusses()
|
||||
void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectCorsairControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectCorsairProControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectHyperXControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectPolychromeControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
@@ -351,6 +352,7 @@ void DetectRGBControllers(void)
|
||||
DetectAuraControllers(busses, rgb_controllers);
|
||||
DetectCorsairControllers(busses, rgb_controllers);
|
||||
DetectCorsairProControllers(busses, rgb_controllers);
|
||||
DetectCrucialControllers(busses, rgb_controllers);
|
||||
DetectHyperXControllers(busses, rgb_controllers);
|
||||
DetectPatriotViperControllers(busses, rgb_controllers);
|
||||
DetectPolychromeControllers(busses, rgb_controllers);
|
||||
|
||||
@@ -16,6 +16,7 @@ INCLUDEPATH += \
|
||||
Controllers/CorsairController/ \
|
||||
Controllers/CorsairNodeProController/ \
|
||||
Controllers/CorsairProController/ \
|
||||
Controllers/CrucialController/ \
|
||||
Controllers/Hue2Controller/ \
|
||||
Controllers/HuePlusController/ \
|
||||
Controllers/HyperXController/ \
|
||||
@@ -52,6 +53,8 @@ SOURCES += \
|
||||
Controllers/CorsairNodeProController/CorsairNodeProControllerDetect.cpp \
|
||||
Controllers/CorsairProController/CorsairProController.cpp \
|
||||
Controllers/CorsairProController/CorsairProControllerDetect.cpp \
|
||||
Controllers/CrucialController/CrucialController.cpp \
|
||||
Controllers/CrucialController/CrucialControllerDetect.cpp \
|
||||
Controllers/Hue2Controller/Hue2Controller.cpp \
|
||||
Controllers/Hue2Controller/Hue2ControllerDetect.cpp \
|
||||
Controllers/HuePlusController/HuePlusController.cpp \
|
||||
@@ -77,6 +80,7 @@ SOURCES += \
|
||||
RGBController/RGBController_Corsair.cpp \
|
||||
RGBController/RGBController_CorsairNodePro.cpp \
|
||||
RGBController/RGBController_CorsairPro.cpp \
|
||||
RGBController/RGBController_Crucial.cpp \
|
||||
RGBController/RGBController_Hue2.cpp \
|
||||
RGBController/RGBController_HuePlus.cpp \
|
||||
RGBController/RGBController_HyperX.cpp \
|
||||
@@ -104,6 +108,7 @@ HEADERS += \
|
||||
Controllers/CorsairController/CorsairController.h \
|
||||
Controllers/CorsairNodeProController/CorsairNodeProController.h \
|
||||
Controllers/CorsairProController/CorsairProController.h \
|
||||
Controllers/CrucialController/CrucialController.h \
|
||||
Controllers/Hue2Controller/Hue2Controller.h \
|
||||
Controllers/HuePlusController/HuePlusController.h \
|
||||
Controllers/HyperXController/HyperXController.h \
|
||||
@@ -119,6 +124,7 @@ HEADERS += \
|
||||
RGBController/RGBController_Corsair.h \
|
||||
RGBController/RGBController_CorsairNodePro.h \
|
||||
RGBController/RGBController_CorsairPro.h \
|
||||
RGBController/RGBController_Crucial.h \
|
||||
RGBController/RGBController_E131.h \
|
||||
RGBController/RGBController_Hue2.h \
|
||||
RGBController/RGBController_HuePlus.h \
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Crucial.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Crucial |
|
||||
| Ballistix RGB controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/19/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_Crucial.h"
|
||||
|
||||
int RGBController_Crucial::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_Crucial::SetMode(int mode)
|
||||
{
|
||||
mode = ((mode+1) << 4) | 0x0F;
|
||||
crucial->SetMode(mode);
|
||||
}
|
||||
|
||||
void RGBController_Crucial::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Crucial::UpdateLEDs()
|
||||
{
|
||||
crucial->SetAllColorsDirect(&colors[0]);
|
||||
}
|
||||
|
||||
void RGBController_Crucial::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
crucial->SetAllColorsDirect(&colors[0]);
|
||||
}
|
||||
|
||||
void RGBController_Crucial::UpdateSingleLED(int led)
|
||||
{
|
||||
crucial->SetAllColorsDirect(&colors[0]);
|
||||
}
|
||||
|
||||
RGBController_Crucial::RGBController_Crucial(CrucialController * crucial_ptr)
|
||||
{
|
||||
crucial = crucial_ptr;
|
||||
|
||||
location = crucial->GetDeviceLocation();
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
name = "Crucial DRAM";
|
||||
|
||||
mode Shift;
|
||||
Shift.name = "Shift";
|
||||
//Shift.value = CRUCIAL_MODE_SHIFT;
|
||||
//Shift.flags = 0;
|
||||
modes.push_back(Shift);
|
||||
|
||||
mode GradientShift;
|
||||
GradientShift.name = "Gradient Shift";
|
||||
//GradientShift.value = CRUCIAL_MODE_GRADIENT_SHIFT;
|
||||
//GradientShift.flags = 0;
|
||||
modes.push_back(GradientShift);
|
||||
|
||||
mode Fill;
|
||||
Fill.name = "Fill";
|
||||
//Fill.value = CRUCIAL_MODE_FILL;
|
||||
//Fill.flags = 0;
|
||||
modes.push_back(Fill);
|
||||
|
||||
mode Stack;
|
||||
Stack.name = "Stack";
|
||||
//Stack.value = CRUCIAL_MODE_STACK;
|
||||
//Stack.flags = 0;
|
||||
modes.push_back(Stack);
|
||||
|
||||
mode DoubleStack;
|
||||
DoubleStack.name = "Double Stack";
|
||||
//DoubleStack.value = CRUCIAL_MODE_DOUBLE_STACK;
|
||||
//DoubleStack.flags = 0;
|
||||
modes.push_back(DoubleStack);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
//Breathing.value = CRUCIAL_MODE_BREATHING;
|
||||
//Breathing.flags = 0;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode MotionPoint;
|
||||
MotionPoint.name = "Motion Point";
|
||||
//MotionPoint.value = CRUCIAL_MODE_MOTION_POINT;
|
||||
//MotionPoint.flags = 0;
|
||||
modes.push_back(MotionPoint);
|
||||
|
||||
mode InsideOut;
|
||||
InsideOut.name = "Inside Out";
|
||||
//InsideOut.value = CRUCIAL_MODE_INSIDE_OUT;
|
||||
//InsideOut.flags = 0;
|
||||
modes.push_back(InsideOut);
|
||||
|
||||
mode ColorStep;
|
||||
ColorStep.name = "Color Step";
|
||||
//ColorStep.value = CRUCIAL_MODE_COLOR_STEP;
|
||||
//ColorStep.flags = 0;
|
||||
modes.push_back(ColorStep);
|
||||
|
||||
mode WaterWave;
|
||||
WaterWave.name = "Water Wave (Color Blending)";
|
||||
//WaterWave.value = CRUCIAL_MODE_WATER_WAVE;
|
||||
//WaterWave.flags = 0;
|
||||
modes.push_back(WaterWave);
|
||||
|
||||
mode Flashing;
|
||||
Flashing.name = "Flashing";
|
||||
//Flashing.value = CRUCIAL_MODE_FLASHING;
|
||||
//Flashing.flags = 0;
|
||||
modes.push_back(Flashing);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
//Static.value = CRUCIAL_MODE_STATIC;
|
||||
//Static.flags = 0;
|
||||
modes.push_back(Static);
|
||||
|
||||
zone new_zone;
|
||||
new_zone.name = "DRAM";
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
|
||||
std::vector<int> new_zone_map;
|
||||
|
||||
for(int led_idx = 0; led_idx < 8; led_idx++)
|
||||
{
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
led new_led;
|
||||
new_led.name = "DRAM LED";
|
||||
|
||||
leds.push_back(new_led);
|
||||
new_zone_map.push_back(led_idx);
|
||||
}
|
||||
|
||||
new_zone.map.push_back(new_zone_map);
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Crucial.h |
|
||||
| |
|
||||
| Generic RGB Interface for Crucial |
|
||||
| Ballistix RGB controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/19/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "CrucialController.h"
|
||||
|
||||
class RGBController_Crucial : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Crucial(CrucialController* crucial_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
private:
|
||||
CrucialController* crucial;
|
||||
};
|
||||
Reference in New Issue
Block a user