mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-04-28 18:01:39 -04:00
CrucialController: keep track of the last set mode
This saves an extra control transfer when applying settings that have already been applied. Mostly useful for direct mode.
This commit is contained in:
@@ -15,6 +15,9 @@ CrucialController::CrucialController(i2c_smbus_interface* bus, crucial_dev_id de
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
// We don't know what mode the sticks are in until we set one.
|
||||
this->last_mode = CRUCIAL_MODE_UNKNOWN;
|
||||
}
|
||||
|
||||
CrucialController::~CrucialController()
|
||||
@@ -44,7 +47,11 @@ unsigned int CrucialController::GetLEDCount()
|
||||
|
||||
void CrucialController::SetMode(unsigned char mode)
|
||||
{
|
||||
// Don't set a mode if we've already set the same one before.
|
||||
// This is mostly useful for direct mode and updating colors often.
|
||||
if (mode == last_mode) return;
|
||||
SendEffectMode(mode, 0x10);
|
||||
last_mode = mode;
|
||||
}
|
||||
|
||||
void CrucialController::SetAllColorsDirect(RGBColor* colors)
|
||||
|
||||
@@ -18,6 +18,7 @@ typedef unsigned short crucial_register;
|
||||
|
||||
enum
|
||||
{
|
||||
CRUCIAL_MODE_UNKNOWN = 0x00, /* We don't know what the mode is */
|
||||
CRUCIAL_MODE_SHIFT = 0x1F, /* Shift effect mode */
|
||||
CRUCIAL_MODE_GRADIENT_SHIFT = 0x2F, /* Gradient shift mode */
|
||||
CRUCIAL_MODE_FILL = 0x3F, /* Fill effect mode */
|
||||
@@ -53,6 +54,7 @@ private:
|
||||
unsigned char config_table[64];
|
||||
unsigned int led_count;
|
||||
unsigned char channel_cfg;
|
||||
unsigned char last_mode;
|
||||
i2c_smbus_interface * bus;
|
||||
crucial_dev_id dev;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user