Skip to content

Commit aa8c6b6

Browse files
Revert "Use block writes for updating all LEDs at once on ASUS Aura SMBus"
This reverts commit 618faf4.
1 parent 68d27e5 commit aa8c6b6

File tree

3 files changed

+30
-25
lines changed

3 files changed

+30
-25
lines changed

Controllers/AsusAuraSMBusController/AsusAuraSMBusController.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -194,38 +194,38 @@ unsigned char AuraSMBusController::GetLEDBlue(unsigned int led)
194194
return(AuraRegisterRead(direct_reg + ( 3 * led ) + 1));
195195
}
196196

197-
void AuraSMBusController::SetAllColorsDirect(RGBColor* colors)
197+
void AuraSMBusController::SetAllColorsDirect(unsigned char red, unsigned char green, unsigned char blue)
198198
{
199-
unsigned char* color_buf = new unsigned char[led_count * 3];
199+
unsigned char* colors = new unsigned char[led_count * 3];
200200

201201
for (unsigned int i = 0; i < (led_count * 3); i += 3)
202202
{
203-
color_buf[i + 0] = RGBGetRValue(colors[i / 3]);
204-
color_buf[i + 1] = RGBGetBValue(colors[i / 3]);
205-
color_buf[i + 2] = RGBGetGValue(colors[i / 3]);
203+
colors[i + 0] = red;
204+
colors[i + 1] = blue;
205+
colors[i + 2] = green;
206206
}
207207

208-
AuraRegisterWriteBlock(direct_reg, color_buf, led_count * 3);
208+
AuraRegisterWriteBlock(direct_reg, colors, led_count * 3);
209209

210-
delete[] color_buf;
210+
delete[] colors;
211211
}
212212

213-
void AuraSMBusController::SetAllColorsEffect(RGBColor* colors)
213+
void AuraSMBusController::SetAllColorsEffect(unsigned char red, unsigned char green, unsigned char blue)
214214
{
215-
unsigned char* color_buf = new unsigned char[led_count * 3];
215+
unsigned char* colors = new unsigned char[led_count * 3];
216216

217217
for (unsigned int i = 0; i < (led_count * 3); i += 3)
218218
{
219-
color_buf[i + 0] = RGBGetRValue(colors[i / 3]);
220-
color_buf[i + 1] = RGBGetBValue(colors[i / 3]);
221-
color_buf[i + 2] = RGBGetGValue(colors[i / 3]);
219+
colors[i + 0] = red;
220+
colors[i + 1] = blue;
221+
colors[i + 2] = green;
222222
}
223223

224-
AuraRegisterWriteBlock(effect_reg, color_buf, led_count * 3);
225-
224+
AuraRegisterWriteBlock(effect_reg, colors, led_count * 3);
225+
226226
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
227227

228-
delete[] color_buf;
228+
delete[] colors;
229229
}
230230

231231
void AuraSMBusController::SetDirect(unsigned char direct)

Controllers/AsusAuraSMBusController/AsusAuraSMBusController.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
| Adam Honse (CalcProgrammer1) 8/19/2018 |
88
\*-----------------------------------------*/
99

10-
#include "RGBController.h"
11-
1210
#include <string>
1311
#include "i2c_smbus.h"
1412

@@ -89,8 +87,8 @@ class AuraSMBusController
8987
unsigned char GetLEDRed(unsigned int led);
9088
unsigned char GetLEDGreen(unsigned int led);
9189
unsigned char GetLEDBlue(unsigned int led);
92-
void SetAllColorsDirect(RGBColor* colors);
93-
void SetAllColorsEffect(RGBColor* colors);
90+
void SetAllColorsDirect(unsigned char red, unsigned char green, unsigned char blue);
91+
void SetAllColorsEffect(unsigned char red, unsigned char green, unsigned char blue);
9492
void SetDirect(unsigned char direct);
9593
void SetLEDColorDirect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
9694
void SetLEDColorEffect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);

Controllers/AsusAuraSMBusController/RGBController_AsusAuraSMBus.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,20 @@ int RGBController_AuraSMBus::GetDeviceMode()
5858

5959
void RGBController_AuraSMBus::DeviceUpdateLEDs()
6060
{
61-
if(GetMode() == 0)
61+
for(std::size_t led = 0; led < colors.size(); led++)
6262
{
63-
aura->SetAllColorsDirect(&colors[0]);
64-
}
65-
else
66-
{
67-
aura->SetAllColorsEffect(&colors[0]);
63+
unsigned char red = RGBGetRValue(colors[led]);
64+
unsigned char grn = RGBGetGValue(colors[led]);
65+
unsigned char blu = RGBGetBValue(colors[led]);
66+
67+
if (GetMode() == 0)
68+
{
69+
aura->SetLEDColorDirect(led, red, grn, blu);
70+
}
71+
else
72+
{
73+
aura->SetLEDColorEffect(led, red, grn, blu);
74+
}
6875
}
6976
}
7077

0 commit comments

Comments
 (0)