Colorful turing color modes support
This commit is contained in:
1 parent
90db870161
commit
8202ef19e6
5 files changed
+210
-31
No files matched your search
@@ -22,23 +22,123 @@ std::string ColorfulTuringGPUController::GetDeviceLocation()
|
||||
return("I2C: " + return_string);
|
||||
}
|
||||
|
||||
void ColorfulTuringGPUController::SetDirect(RGBColor color)
|
||||
int ColorfulTuringGPUController::GetMode()
|
||||
{
|
||||
uint8_t data_pkt[COLORFUL_MODE_PACKET_LENGTH];
|
||||
int size = COLORFUL_MODE_PACKET_LENGTH;
|
||||
bus->i2c_read_block(dev, &size, data_pkt);
|
||||
|
||||
int mode = data_pkt[2]<<16 | data_pkt[3]<<8 | data_pkt[4];
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
RGBColor ColorfulTuringGPUController::GetColor()
|
||||
{
|
||||
uint8_t data_pkt[COLORFUL_MODE_PACKET_LENGTH];
|
||||
int size = COLORFUL_MODE_PACKET_LENGTH;
|
||||
bus->i2c_read_block(dev, &size, data_pkt);
|
||||
|
||||
RGBColor color = ToRGBColor(data_pkt[5], data_pkt[6], data_pkt[7]);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
void ColorfulTuringGPUController::SetStateDisplay(RGBColor color)
|
||||
{
|
||||
uint8_t r = RGBGetRValue(color);
|
||||
uint8_t g = RGBGetGValue(color);
|
||||
uint8_t b = RGBGetBValue(color);
|
||||
uint8_t data_pkt[COLORFUL_PACKET_LENGTH] = { 0x88, 0x02, 0x32, 0x02, r, g, b};
|
||||
uint8_t data_pkt[COLORFUL_COLOR_PACKET_LENGTH] = { 0x08, 0x01, 0x32, 0x04, r, g, b};
|
||||
|
||||
int crc = 1;
|
||||
|
||||
for(int i = 0; i < COLORFUL_PACKET_LENGTH - 1; ++i)
|
||||
for(int i = 0; i < COLORFUL_COLOR_PACKET_LENGTH - 1; ++i)
|
||||
{
|
||||
crc += data_pkt[i];
|
||||
}
|
||||
crc &= 0xFF;
|
||||
crc = 256-crc;
|
||||
|
||||
data_pkt[COLORFUL_PACKET_LENGTH - 1] = crc & 0xFF;
|
||||
data_pkt[COLORFUL_COLOR_PACKET_LENGTH - 1] = crc & 0xFF;
|
||||
|
||||
bus->i2c_write_block(dev, COLORFUL_PACKET_LENGTH, data_pkt);
|
||||
bus->i2c_write_block(dev, COLORFUL_COLOR_PACKET_LENGTH, data_pkt);
|
||||
}
|
||||
|
||||
void ColorfulTuringGPUController::SetDirect(RGBColor color)
|
||||
{
|
||||
uint8_t r = RGBGetRValue(color);
|
||||
uint8_t g = RGBGetGValue(color);
|
||||
uint8_t b = RGBGetBValue(color);
|
||||
uint8_t data_pkt[COLORFUL_COLOR_PACKET_LENGTH] = { 0x88, 0x02, 0x32, 0x02, r, g, b};
|
||||
|
||||
int crc = 1;
|
||||
|
||||
for(int i = 0; i < COLORFUL_COLOR_PACKET_LENGTH - 1; ++i)
|
||||
{
|
||||
crc += data_pkt[i];
|
||||
}
|
||||
crc &= 0xFF;
|
||||
crc = 256-crc;
|
||||
|
||||
data_pkt[COLORFUL_COLOR_PACKET_LENGTH - 1] = crc & 0xFF;
|
||||
|
||||
bus->i2c_write_block(dev, COLORFUL_COLOR_PACKET_LENGTH, data_pkt);
|
||||
}
|
||||
|
||||
void ColorfulTuringGPUController::SetBreathing(RGBColor color)
|
||||
{
|
||||
uint8_t r = RGBGetRValue(color);
|
||||
uint8_t g = RGBGetGValue(color);
|
||||
uint8_t b = RGBGetBValue(color);
|
||||
uint8_t data_pkt[COLORFUL_COLOR_PACKET_LENGTH] = { 0x88, 0x01, 0x32, 0x02, r, g, b};
|
||||
|
||||
int crc = 1;
|
||||
|
||||
for(int i = 0; i < COLORFUL_COLOR_PACKET_LENGTH - 1; ++i)
|
||||
{
|
||||
crc += data_pkt[i];
|
||||
}
|
||||
crc &= 0xFF;
|
||||
crc = 256-crc;
|
||||
|
||||
data_pkt[COLORFUL_COLOR_PACKET_LENGTH - 1] = crc & 0xFF;
|
||||
|
||||
bus->i2c_write_block(dev, COLORFUL_COLOR_PACKET_LENGTH, data_pkt);
|
||||
}
|
||||
|
||||
void ColorfulTuringGPUController::SetOff()
|
||||
{
|
||||
uint8_t data_pkt[COLORFUL_NON_COLOR_PACKET_LENGTH] = { 0x85, 0x00, 0x00, 0x0A };
|
||||
|
||||
int crc = 1;
|
||||
|
||||
for(int i = 0; i < COLORFUL_NON_COLOR_PACKET_LENGTH - 1; ++i)
|
||||
{
|
||||
crc += data_pkt[i];
|
||||
}
|
||||
crc &= 0xFF;
|
||||
crc = 256-crc;
|
||||
|
||||
data_pkt[COLORFUL_NON_COLOR_PACKET_LENGTH - 1] = crc & 0xFF;
|
||||
|
||||
bus->i2c_write_block(dev, COLORFUL_NON_COLOR_PACKET_LENGTH, data_pkt);
|
||||
}
|
||||
|
||||
void ColorfulTuringGPUController::SetRainbow()
|
||||
{
|
||||
uint8_t data_pkt[COLORFUL_NON_COLOR_PACKET_LENGTH] = { 0x85, 0x04, 0x32, 0x02 };
|
||||
|
||||
int crc = 1;
|
||||
|
||||
for(int i = 0; i < COLORFUL_NON_COLOR_PACKET_LENGTH - 1; ++i)
|
||||
{
|
||||
crc += data_pkt[i];
|
||||
}
|
||||
crc &= 0xFF;
|
||||
crc = 256-crc;
|
||||
|
||||
data_pkt[COLORFUL_NON_COLOR_PACKET_LENGTH - 1] = crc & 0xFF;
|
||||
|
||||
bus->i2c_write_block(dev, COLORFUL_NON_COLOR_PACKET_LENGTH, data_pkt);
|
||||
}
|
||||
Reference in new issue
Block a user