Skip to content

Commit a605d55

Browse files
TheRogueZetaCalcProgrammer1
authored andcommitted
Update zones on mode update
Minor cleanup, logic tweak to only update per-zone modes for Polychrome V1 by Adam Honse <calcprogrammer1@gmail.com>
1 parent 759e09b commit a605d55

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

Controllers/PolychromeController/PolychromeController.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,10 @@ void PolychromeController::SetColorsAndSpeed(unsigned char led, unsigned char re
257257
}
258258
}
259259

260-
void PolychromeController::SetMode(unsigned char mode, unsigned char speed)
260+
void PolychromeController::SetMode(unsigned char zone,unsigned char mode, unsigned char speed)
261261
{
262262
unsigned char led_count_pkt[1] = { 0x00 };
263+
active_zone = zone;
263264
active_mode = mode;
264265
active_speed = speed;
265266

@@ -271,13 +272,22 @@ void PolychromeController::SetMode(unsigned char mode, unsigned char speed)
271272
break;
272273

273274
case ASROCK_TYPE_POLYCHROME_V1:
274-
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_MODE, 1, &active_mode);
275+
/*-----------------------------------------------------*\
276+
| Make sure set all register is set to 0 |
277+
\*-----------------------------------------------------*/
278+
bus->i2c_smbus_write_block_data(dev, POLYCHROME_V1_REG_SET_ALL, 1, led_count_pkt);
275279
std::this_thread::sleep_for(1ms);
276280

277281
/*-----------------------------------------------------*\
278-
| Select a single LED |
282+
| Set the zone we are working on |
279283
\*-----------------------------------------------------*/
280-
bus->i2c_smbus_write_block_data(dev, POLYCHROME_V1_REG_SET_ALL, 0, led_count_pkt);
284+
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_LED_SELECT, 1, &active_zone);
285+
std::this_thread::sleep_for(1ms);
286+
287+
/*-----------------------------------------------------*\
288+
| Write the mode |
289+
\*-----------------------------------------------------*/
290+
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_MODE, 1, &active_mode);
281291
std::this_thread::sleep_for(1ms);
282292
break;
283293

Controllers/PolychromeController/PolychromeController.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,14 @@ class PolychromeController
203203
unsigned int GetMode();
204204
unsigned int GetASRockType();
205205
void SetColorsAndSpeed(unsigned char led, unsigned char red, unsigned char green, unsigned char blue);
206-
void SetMode(unsigned char mode, unsigned char speed);
206+
void SetMode(unsigned char zone, unsigned char mode, unsigned char speed);
207207

208208
unsigned char zone_led_count[6];
209209

210210
private:
211211
unsigned int asrock_type;
212212
std::string device_name;
213+
unsigned char active_zone;
213214
unsigned char active_mode;
214215
unsigned char active_speed;
215216
i2c_smbus_interface* bus;

RGBController/RGBController_Polychrome.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,17 @@ void RGBController_Polychrome::SetCustomMode()
613613

614614
void RGBController_Polychrome::DeviceUpdateMode()
615615
{
616-
polychrome->SetMode(modes[active_mode].value, modes[active_mode].speed);
616+
if(polychrome->GetASRockType() == ASROCK_TYPE_POLYCHROME_V1)
617+
{
618+
for(unsigned int led_idx = 0; led_idx <= leds.size(); led_idx++)
619+
{
620+
polychrome->SetMode(led_idx, modes[active_mode].value, modes[active_mode].speed);
621+
}
622+
}
623+
else
624+
{
625+
polychrome->SetMode(0, modes[active_mode].value, modes[active_mode].speed);
626+
}
617627

618628
DeviceUpdateLEDs();
619629
}

0 commit comments

Comments
 (0)