1
0
mirror of https://github.com/MatMoul/g810-led.git synced 2024-12-23 09:16:11 +00:00

Restore g910 native effect

This commit is contained in:
MatMoul 2017-02-11 22:28:53 +01:00
parent 9bd190331b
commit da8eb644eb

View File

@ -427,22 +427,38 @@ bool LedKeyboard::setStartupMode(StartupMode startupMode) {
bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, uint8_t speed, Color color) { bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, uint8_t speed, Color color) {
uint8_t protocolByte = 0;
switch (m_keyboardModel) {
case KeyboardModel::g410:
case KeyboardModel::g610:
case KeyboardModel::g810:
protocolByte = 0x0d;
break;
case KeyboardModel::g910:
protocolByte = 0x10;
break;
default:
return false;
}
byte_buffer_t data; byte_buffer_t data;
switch (effect) { switch (effect) {
case NativeEffect::color: case NativeEffect::color:
data = { 0x11, 0xff, 0x0d, 0x3c, (uint8_t)part, 0x01, color.red, color.green, color.blue, 0x02 }; data = { 0x11, 0xff, protocolByte, 0x3c, (uint8_t)part, 0x01, color.red, color.green, color.blue, 0x02 };
break; break;
case NativeEffect::breathing: case NativeEffect::breathing:
data = { data = {
0x11, 0xff, 0x0d, 0x3c, (uint8_t)part, 0x02, 0x11, 0xff, protocolByte, 0x3c, (uint8_t)part, 0x02,
color.red, color.green, color.blue, speed, color.red, color.green, color.blue, speed,
0x10, 0x00, 0x64 0x10, 0x00, 0x64
}; };
break; break;
case NativeEffect::cycle: case NativeEffect::cycle:
data = { data = {
0x11, 0xff, 0x0d, 0x3c, (uint8_t)part, 0x03, 0x11, 0xff, protocolByte, 0x3c, (uint8_t)part, 0x03,
0x00, 0x00, 0x00, 0x00, 0x00, speed, 0x00, 0x00, 0x64 0x00, 0x00, 0x00, 0x00, 0x00, speed, 0x00, 0x00, 0x64
}; };
break; break;
@ -453,7 +469,7 @@ bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, ui
break; break;
default: default:
data = { data = {
0x11, 0xff, 0x0d, 0x3c, (uint8_t)part, 0x04, 0x11, 0xff, protocolByte, 0x3c, (uint8_t)part, 0x04,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x01, 0x64, speed 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x01, 0x64, speed
}; };
break; break;
@ -466,7 +482,7 @@ bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, ui
break; break;
default: default:
data = { data = {
0x11, 0xff, 0x0d, 0x3c, (uint8_t)part, 0x04, 0x11, 0xff, protocolByte, 0x3c, (uint8_t)part, 0x04,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x02, 0x64, speed 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x02, 0x64, speed
}; };
break; break;
@ -479,7 +495,7 @@ bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, ui
break; break;
default: default:
data = { data = {
0x11, 0xff, 0x0d, 0x3c, (uint8_t)part, 0x04, 0x11, 0xff, protocolByte, 0x3c, (uint8_t)part, 0x04,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x03, 0x64, speed 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x03, 0x64, speed
}; };
break; break;