Use block writes for updating all LEDs at once on ASUS Aura SMBus

This commit is contained in:
Adam Honse
2021-05-19 21:49:22 -05:00
parent 961fbc2585
commit 618faf42ec
3 changed files with 25 additions and 30 deletions

View File

@@ -194,38 +194,38 @@ unsigned char AuraSMBusController::GetLEDBlue(unsigned int led)
return(AuraRegisterRead(direct_reg + ( 3 * led ) + 1));
}
void AuraSMBusController::SetAllColorsDirect(unsigned char red, unsigned char green, unsigned char blue)
void AuraSMBusController::SetAllColorsDirect(RGBColor* colors)
{
unsigned char* colors = new unsigned char[led_count * 3];
unsigned char* color_buf = new unsigned char[led_count * 3];
for (unsigned int i = 0; i < (led_count * 3); i += 3)
{
colors[i + 0] = red;
colors[i + 1] = blue;
colors[i + 2] = green;
color_buf[i + 0] = RGBGetRValue(colors[i / 3]);
color_buf[i + 1] = RGBGetBValue(colors[i / 3]);
color_buf[i + 2] = RGBGetGValue(colors[i / 3]);
}
AuraRegisterWriteBlock(direct_reg, colors, led_count * 3);
AuraRegisterWriteBlock(direct_reg, color_buf, led_count * 3);
delete colors;
delete color_buf;
}
void AuraSMBusController::SetAllColorsEffect(unsigned char red, unsigned char green, unsigned char blue)
void AuraSMBusController::SetAllColorsEffect(RGBColor* colors)
{
unsigned char* colors = new unsigned char[led_count * 3];
unsigned char* color_buf = new unsigned char[led_count * 3];
for (unsigned int i = 0; i < (led_count * 3); i += 3)
{
colors[i + 0] = red;
colors[i + 1] = blue;
colors[i + 2] = green;
color_buf[i + 0] = RGBGetRValue(colors[i / 3]);
color_buf[i + 1] = RGBGetBValue(colors[i / 3]);
color_buf[i + 2] = RGBGetGValue(colors[i / 3]);
}
AuraRegisterWriteBlock(effect_reg, colors, led_count * 3);
AuraRegisterWriteBlock(effect_reg, color_buf, led_count * 3);
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
delete[] colors;
delete[] color_buf;
}
void AuraSMBusController::SetDirect(unsigned char direct)

View File

@@ -7,6 +7,8 @@
| Adam Honse (CalcProgrammer1) 8/19/2018 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include "i2c_smbus.h"
@@ -87,8 +89,8 @@ public:
unsigned char GetLEDRed(unsigned int led);
unsigned char GetLEDGreen(unsigned int led);
unsigned char GetLEDBlue(unsigned int led);
void SetAllColorsDirect(unsigned char red, unsigned char green, unsigned char blue);
void SetAllColorsEffect(unsigned char red, unsigned char green, unsigned char blue);
void SetAllColorsDirect(RGBColor* colors);
void SetAllColorsEffect(RGBColor* colors);
void SetDirect(unsigned char direct);
void SetLEDColorDirect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
void SetLEDColorEffect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);

View File

@@ -58,20 +58,13 @@ int RGBController_AuraSMBus::GetDeviceMode()
void RGBController_AuraSMBus::DeviceUpdateLEDs()
{
for(std::size_t led = 0; led < colors.size(); led++)
if(GetMode() == 0)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
if (GetMode() == 0)
{
aura->SetLEDColorDirect(led, red, grn, blu);
}
else
{
aura->SetLEDColorEffect(led, red, grn, blu);
}
aura->SetAllColorsDirect(&colors[0]);
}
else
{
aura->SetAllColorsEffect(&colors[0]);
}
}