Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions Controllers/TForceXtreemController/RGBController_TForceXtreem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,25 @@
#include "ResourceManager.h"

/**------------------------------------------------------------------*\
@name T-Force Xtreem
@name T-Force Xtreem / Delta
@category RAM
@type SMBus
@save :white_check_mark:
@direct :white_check_mark:
@effects :white_check_mark:
@detectors DetectTForceXtreemControllers
@detectors DetectTForceXtreemControllers,DetectTForceDeltaControllers
@comment
Verified models:
TeamGroup T-Force Xtreem ARGB DDR4
TeamGroup T-Force Delta RGB DDR5
\*-------------------------------------------------------------------*/

RGBController_TForceXtreem::RGBController_TForceXtreem(TForceXtreemController * controller_ptr)
RGBController_TForceXtreem::RGBController_TForceXtreem(TForceXtreemController * controller_ptr, const std::string& device_name)
{
controller = controller_ptr;

type = DEVICE_TYPE_DRAM;
name = "T-Force Xtreem RGB";
name = device_name;
vendor = "TeamGroup";

location = controller->GetDeviceLocation();
Expand Down Expand Up @@ -416,15 +417,17 @@ void RGBController_TForceXtreem::UpdateSingleLED(int led)

void RGBController_TForceXtreem::SetupZones()
{
unsigned int led_count = controller->GetLEDCount();

/*---------------------------------------------------------*\
| Set up zone |
\*---------------------------------------------------------*/
zone new_zone;
new_zone.name = "DRAM";
new_zone.type = ZONE_TYPE_LINEAR;
new_zone.leds_min = XTREEM_LED_COUNT;
new_zone.leds_max = XTREEM_LED_COUNT;
new_zone.leds_count = XTREEM_LED_COUNT;
new_zone.leds_min = led_count;
new_zone.leds_max = led_count;
new_zone.leds_count = led_count;
new_zone.matrix_map = NULL;
zones.push_back(new_zone);

Expand All @@ -436,6 +439,7 @@ void RGBController_TForceXtreem::SetupZones()
led new_led;
new_led.name = "DRAM LED ";
new_led.name.append(std::to_string(led_idx));
new_led.value = led_idx;
leds.push_back(new_led);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@

#pragma once

#include <string>
#include "RGBController.h"
#include "TForceXtreemController.h"

class RGBController_TForceXtreem : public RGBController
{
public:
RGBController_TForceXtreem(TForceXtreemController* controller_ptr);
RGBController_TForceXtreem(TForceXtreemController* controller_ptr, const std::string& device_name = "T-Force Xtreem RGB");
~RGBController_TForceXtreem();

void SetupZones();
Expand Down
55 changes: 32 additions & 23 deletions Controllers/TForceXtreemController/TForceXtreemController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
#include "TForceXtreemController.h"
#include "LogManager.h"

TForceXtreemController::TForceXtreemController(i2c_smbus_interface *bus, ene_dev_id dev)
TForceXtreemController::TForceXtreemController(i2c_smbus_interface *bus, ene_dev_id dev, unsigned int led_count, bool folded)
{
this->bus = bus;
this->dev = dev;
this->led_count = led_count;
this->folded = folded;
}

TForceXtreemController::~TForceXtreemController()
Expand All @@ -37,59 +39,66 @@ std::string TForceXtreemController::GetDeviceLocation()

unsigned int TForceXtreemController::GetLEDCount()
{
return(XTREEM_LED_COUNT);
return(led_count);
}

/*---------------------------------------------------*\
| LEDs are in a single strip that is folded in half. |
| That makes the LED order: 0-14-1-13-2-...-7-9-8 |
\*---------------------------------------------------*/
#define XTREEM_LED_OFFSET(x) ((((x) & 0x01) > 0) ? XTREEM_LED_COUNT - 1 - ((x) >> 1) : ((x) >> 1))
/*-----------------------------------------------------------*\
| For folded strips (e.g. Xtreem), LEDs are in a single strip |
| folded in half, giving order: 0-(N-1)-1-(N-2)-2-... |
| For linear strips (e.g. Delta), offset is simply the index. |
\*-----------------------------------------------------------*/
unsigned int TForceXtreemController::GetLEDOffset(unsigned int led)
{
if(folded)
return (led & 0x01) ? led_count - 1 - (led >> 1) : (led >> 1);
else
return led;
}

unsigned char TForceXtreemController::GetLEDRed(unsigned int led)
{
return(ENERegisterRead(XTREEM_REG_COLORS_DIRECT + ( 3 * XTREEM_LED_OFFSET(led) )));
return(ENERegisterRead(XTREEM_REG_COLORS_DIRECT + ( 3 * GetLEDOffset(led) )));
}

unsigned char TForceXtreemController::GetLEDGreen(unsigned int led)
{
return(ENERegisterRead(XTREEM_REG_COLORS_DIRECT + ( 3 * XTREEM_LED_OFFSET(led) ) + 2));
return(ENERegisterRead(XTREEM_REG_COLORS_DIRECT + ( 3 * GetLEDOffset(led) ) + 2));
}

unsigned char TForceXtreemController::GetLEDBlue(unsigned int led)
{
return(ENERegisterRead(XTREEM_REG_COLORS_DIRECT + ( 3 * XTREEM_LED_OFFSET(led) ) + 1));
return(ENERegisterRead(XTREEM_REG_COLORS_DIRECT + ( 3 * GetLEDOffset(led) ) + 1));
}

unsigned char TForceXtreemController::GetLEDRedEffect(unsigned int led)
{
return(ENERegisterRead(XTREEM_REG_COLORS_EFFECT + ( 3 * XTREEM_LED_OFFSET(led) )));
return(ENERegisterRead(XTREEM_REG_COLORS_EFFECT + ( 3 * GetLEDOffset(led) )));
}

unsigned char TForceXtreemController::GetLEDGreenEffect(unsigned int led)
{
return(ENERegisterRead(XTREEM_REG_COLORS_EFFECT + ( 3 * XTREEM_LED_OFFSET(led) ) + 2));
return(ENERegisterRead(XTREEM_REG_COLORS_EFFECT + ( 3 * GetLEDOffset(led) ) + 2));
}

unsigned char TForceXtreemController::GetLEDBlueEffect(unsigned int led)
{
return(ENERegisterRead(XTREEM_REG_COLORS_EFFECT + ( 3 * XTREEM_LED_OFFSET(led) ) + 1));
return(ENERegisterRead(XTREEM_REG_COLORS_EFFECT + ( 3 * GetLEDOffset(led) ) + 1));
}

void TForceXtreemController::SetAllColorsDirect(RGBColor* colors)
{
unsigned char* color_buf = new unsigned char[XTREEM_LED_COUNT * 3];
unsigned char* color_buf = new unsigned char[led_count * 3];
unsigned int bytes_sent = 0;

for(unsigned int i = 0; i < XTREEM_LED_COUNT; i++)
for(unsigned int i = 0; i < led_count; i++)
{
unsigned int offset = 3 * XTREEM_LED_OFFSET(i);
unsigned int offset = 3 * GetLEDOffset(i);
color_buf[offset + 0] = RGBGetRValue(colors[i]);
color_buf[offset + 1] = RGBGetBValue(colors[i]);
color_buf[offset + 2] = RGBGetGValue(colors[i]);
}

while(bytes_sent < (XTREEM_LED_COUNT * 3))
while(bytes_sent < (led_count * 3))
{
ENERegisterWriteBlock(XTREEM_REG_COLORS_DIRECT + bytes_sent, &color_buf[bytes_sent], 3);

Expand All @@ -101,18 +110,18 @@ void TForceXtreemController::SetAllColorsDirect(RGBColor* colors)

void TForceXtreemController::SetAllColorsEffect(RGBColor* colors)
{
unsigned char* color_buf = new unsigned char[XTREEM_LED_COUNT * 3];
unsigned char* color_buf = new unsigned char[led_count * 3];
unsigned int bytes_sent = 0;

for(unsigned int i = 0; i < XTREEM_LED_COUNT; i++)
for(unsigned int i = 0; i < led_count; i++)
{
unsigned int offset = 3 * XTREEM_LED_OFFSET(i);
unsigned int offset = 3 * GetLEDOffset(i);
color_buf[offset + 0] = RGBGetRValue(colors[i]);
color_buf[offset + 1] = RGBGetBValue(colors[i]);
color_buf[offset + 2] = RGBGetGValue(colors[i]);
}

while(bytes_sent < (XTREEM_LED_COUNT * 3))
while(bytes_sent < (led_count * 3))
{
ENERegisterWriteBlock(XTREEM_REG_COLORS_EFFECT + bytes_sent, &color_buf[bytes_sent], 3);

Expand All @@ -135,14 +144,14 @@ void TForceXtreemController::SetLEDColorDirect(unsigned int led, unsigned char r
{
unsigned char colors[3] = { red, blue, green };

ENERegisterWriteBlock(XTREEM_REG_COLORS_DIRECT + ( 3 * XTREEM_LED_OFFSET(led) ), colors, 3);
ENERegisterWriteBlock(XTREEM_REG_COLORS_DIRECT + ( 3 * GetLEDOffset(led) ), colors, 3);
}

void TForceXtreemController::SetLEDColorEffect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char colors[3] = { red, blue, green };

ENERegisterWriteBlock(XTREEM_REG_COLORS_EFFECT + (3 * XTREEM_LED_OFFSET(led)), colors, 3);
ENERegisterWriteBlock(XTREEM_REG_COLORS_EFFECT + (3 * GetLEDOffset(led)), colors, 3);

ENERegisterWrite(XTREEM_REG_APPLY, XTREEM_APPLY_VAL);
}
Expand Down
7 changes: 6 additions & 1 deletion Controllers/TForceXtreemController/TForceXtreemController.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#define XTREEM_APPLY_VAL 0x01 /* Value for Apply Changes Register */
#define XTREEM_LED_COUNT 15
#define DELTA_LED_COUNT 8

typedef unsigned short ene_register;
typedef unsigned char ene_dev_id;
Expand Down Expand Up @@ -83,7 +84,7 @@ enum
class TForceXtreemController
{
public:
TForceXtreemController(i2c_smbus_interface *bus, ene_dev_id dev);
TForceXtreemController(i2c_smbus_interface *bus, ene_dev_id dev, unsigned int led_count = XTREEM_LED_COUNT, bool folded = true);
~TForceXtreemController();

std::string GetDeviceLocation();
Expand All @@ -106,6 +107,10 @@ class TForceXtreemController
void ENERegisterWriteBlock(ene_register reg, unsigned char * data, unsigned char sz);

private:
unsigned int GetLEDOffset(unsigned int led);

i2c_smbus_interface * bus;
ene_dev_id dev;
unsigned int led_count;
bool folded;
};
Loading