Update zones on mode update

Minor cleanup, logic tweak to only update per-zone modes for Polychrome V1 by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
TheRogueZeta 2020-09-07 00:24:53 -07:00 committed by Adam Honse
parent 759e09b3a3
commit a605d5581a
3 changed files with 27 additions and 6 deletions

View file

@ -257,9 +257,10 @@ void PolychromeController::SetColorsAndSpeed(unsigned char led, unsigned char re
}
}
void PolychromeController::SetMode(unsigned char mode, unsigned char speed)
void PolychromeController::SetMode(unsigned char zone,unsigned char mode, unsigned char speed)
{
unsigned char led_count_pkt[1] = { 0x00 };
active_zone = zone;
active_mode = mode;
active_speed = speed;
@ -271,13 +272,22 @@ void PolychromeController::SetMode(unsigned char mode, unsigned char speed)
break;
case ASROCK_TYPE_POLYCHROME_V1:
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_MODE, 1, &active_mode);
/*-----------------------------------------------------*\
| Make sure set all register is set to 0 |
\*-----------------------------------------------------*/
bus->i2c_smbus_write_block_data(dev, POLYCHROME_V1_REG_SET_ALL, 1, led_count_pkt);
std::this_thread::sleep_for(1ms);
/*-----------------------------------------------------*\
| Select a single LED |
| Set the zone we are working on |
\*-----------------------------------------------------*/
bus->i2c_smbus_write_block_data(dev, POLYCHROME_V1_REG_SET_ALL, 0, led_count_pkt);
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_LED_SELECT, 1, &active_zone);
std::this_thread::sleep_for(1ms);
/*-----------------------------------------------------*\
| Write the mode |
\*-----------------------------------------------------*/
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_MODE, 1, &active_mode);
std::this_thread::sleep_for(1ms);
break;

View file

@ -203,13 +203,14 @@ public:
unsigned int GetMode();
unsigned int GetASRockType();
void SetColorsAndSpeed(unsigned char led, unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char mode, unsigned char speed);
void SetMode(unsigned char zone, unsigned char mode, unsigned char speed);
unsigned char zone_led_count[6];
private:
unsigned int asrock_type;
std::string device_name;
unsigned char active_zone;
unsigned char active_mode;
unsigned char active_speed;
i2c_smbus_interface* bus;

View file

@ -613,7 +613,17 @@ void RGBController_Polychrome::SetCustomMode()
void RGBController_Polychrome::DeviceUpdateMode()
{
polychrome->SetMode(modes[active_mode].value, modes[active_mode].speed);
if(polychrome->GetASRockType() == ASROCK_TYPE_POLYCHROME_V1)
{
for(unsigned int led_idx = 0; led_idx <= leds.size(); led_idx++)
{
polychrome->SetMode(led_idx, modes[active_mode].value, modes[active_mode].speed);
}
}
else
{
polychrome->SetMode(0, modes[active_mode].value, modes[active_mode].speed);
}
DeviceUpdateLEDs();
}