mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-05-24 14:35:01 -04:00
Rework Direct mode to allow for other modes. Implement Off and Static modes
This commit is contained in:
@@ -27,10 +27,9 @@ RGBFusion2DRAMController::RGBFusion2DRAMController(i2c_smbus_interface* bus, rgb
|
||||
memset(led_data, 0, sizeof(led_data));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Initialize controller with 6 LEDs and mask 0x3B |
|
||||
| Initialize controller with 6 LEDs |
|
||||
| This is hard coded for Aorus RGB RAM |
|
||||
\*-----------------------------------------------------*/
|
||||
led_data[RGB_FUSION_2_DRAM_LED_EN_MASK] = 0x3B;
|
||||
led_count = 6;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -74,17 +73,29 @@ void RGBFusion2DRAMController::SetLEDEffect
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
led_data[RGB_FUSION_2_DRAM_LED_EN_MASK] = (1 << led);
|
||||
led_data[RGB_FUSION_2_DRAM_IDX_MODE] = mode;
|
||||
led_data[RGB_FUSION_2_DRAM_IDX_RED] = red;
|
||||
led_data[RGB_FUSION_2_DRAM_IDX_GREEN] = green;
|
||||
led_data[RGB_FUSION_2_DRAM_IDX_BLUE] = blue;
|
||||
if(mode == RGB_FUSION_2_DRAM_MODE_DIRECT)
|
||||
{
|
||||
led_data[RGB_FUSION_2_DRAM_LED_EN_MASK] = (1 << led);
|
||||
|
||||
// hack for direct mode
|
||||
led_data[16] = 1;
|
||||
led_data[22] = 2;
|
||||
led_data[29] = 1;
|
||||
led_data[30] = 1;
|
||||
// hack for direct mode
|
||||
led_data[16] = 1;
|
||||
led_data[22] = 2;
|
||||
led_data[29] = 1;
|
||||
led_data[30] = 1;
|
||||
|
||||
mode = RGB_FUSION_2_DRAM_MODE_PULSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
led_data[RGB_FUSION_2_DRAM_LED_EN_MASK] = 0x3F;
|
||||
}
|
||||
|
||||
led_data[RGB_FUSION_2_DRAM_IDX_MODE] = mode;
|
||||
led_data[RGB_FUSION_2_DRAM_IDX_RED] = red;
|
||||
led_data[RGB_FUSION_2_DRAM_IDX_GREEN] = green;
|
||||
led_data[RGB_FUSION_2_DRAM_IDX_BLUE] = blue;
|
||||
|
||||
bus->i2c_smbus_write_block_data(dev, RGB_FUSION_2_DRAM_LED_START_ADDR, 32, led_data);
|
||||
|
||||
Apply();
|
||||
}
|
||||
|
||||
@@ -45,10 +45,11 @@ enum
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_2_DRAM_MODE_OFF = 0x00,
|
||||
RGB_FUSION_2_DRAM_MODE_STATIC = 0x01,
|
||||
RGB_FUSION_2_DRAM_MODE_PULSE = 0x02,
|
||||
RGB_FUSION_2_DRAM_MODE_FLASH = 0x03
|
||||
RGB_FUSION_2_DRAM_MODE_OFF = 0x00, /* Off mode */
|
||||
RGB_FUSION_2_DRAM_MODE_STATIC = 0x01, /* Static mode */
|
||||
RGB_FUSION_2_DRAM_MODE_PULSE = 0x02, /* Pulsing mode */
|
||||
RGB_FUSION_2_DRAM_MODE_FLASH = 0x03, /* Flashing mode */
|
||||
RGB_FUSION_2_DRAM_MODE_DIRECT = 0xFF /* Dummy mode, implements per LED using Pulse */
|
||||
};
|
||||
|
||||
class RGBFusion2DRAMController
|
||||
|
||||
@@ -31,11 +31,28 @@ RGBController_RGBFusion2DRAM::RGBController_RGBFusion2DRAM(RGBFusion2DRAMControl
|
||||
\*-----------------------------------------------------*/
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = RGB_FUSION_2_DRAM_MODE_PULSE;
|
||||
Direct.value = RGB_FUSION_2_DRAM_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = RGB_FUSION_2_DRAM_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = RGB_FUSION_2_DRAM_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.colors.resize(1);
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
modes.push_back(Static);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
@@ -88,7 +105,17 @@ void RGBController_RGBFusion2DRAM::DeviceUpdateLEDs()
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int led_idx = 0; led_idx < colors.size(); led_idx++)
|
||||
{
|
||||
RGBColor color = colors[led_idx];
|
||||
RGBColor color = 0;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
|
||||
{
|
||||
color = colors[led_idx];
|
||||
}
|
||||
else if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
color = modes[active_mode].colors[0];
|
||||
}
|
||||
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
@@ -97,7 +124,14 @@ void RGBController_RGBFusion2DRAM::DeviceUpdateLEDs()
|
||||
unsigned int speed = modes[active_mode].speed;
|
||||
|
||||
controller->SetLEDEffect(led_idx, mode, speed, red, grn, blu);
|
||||
controller->Apply();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Only update once unless in direct mode |
|
||||
\*---------------------------------------------------------*/
|
||||
if(modes[active_mode].value != RGB_FUSION_2_DRAM_MODE_DIRECT)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user