mirror of
https://github.com/MatMoul/g810-led.git
synced 2024-12-23 01:06:11 +00:00
Issue #158: Add "waves" effect found on G Pro
This commit is contained in:
parent
062ad6f9c4
commit
2426ef641d
@ -699,22 +699,21 @@ 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;
|
uint8_t protocolByte = 0;
|
||||||
|
NativeEffectGroup effectGroup = static_cast<NativeEffectGroup>(static_cast<uint16_t>(effect) >> 8);
|
||||||
|
|
||||||
// NativeEffectPart::all is not in the device protocol, but an alias for both keys and logo, plus indicators
|
// NativeEffectPart::all is not in the device protocol, but an alias for both keys and logo, plus indicators
|
||||||
if (part == LedKeyboard::NativeEffectPart::all) {
|
if (part == LedKeyboard::NativeEffectPart::all) {
|
||||||
switch (effect) {
|
switch (effectGroup) {
|
||||||
case LedKeyboard::NativeEffect::color:
|
case NativeEffectGroup::color:
|
||||||
if (! setGroupKeys(LedKeyboard::KeyGroup::indicators, color)) return false;
|
if (! setGroupKeys(LedKeyboard::KeyGroup::indicators, color)) return false;
|
||||||
if (! commit()) return false;
|
if (! commit()) return false;
|
||||||
break;
|
break;
|
||||||
case LedKeyboard::NativeEffect::breathing:
|
case NativeEffectGroup::breathing:
|
||||||
if (! setGroupKeys(LedKeyboard::KeyGroup::indicators, color)) return false;;
|
if (! setGroupKeys(LedKeyboard::KeyGroup::indicators, color)) return false;;
|
||||||
if (! commit()) return false;;
|
if (! commit()) return false;;
|
||||||
break;
|
break;
|
||||||
case LedKeyboard::NativeEffect::cycle:
|
case NativeEffectGroup::cycle:
|
||||||
case LedKeyboard::NativeEffect::hwave:
|
case NativeEffectGroup::waves:
|
||||||
case LedKeyboard::NativeEffect::vwave:
|
|
||||||
case LedKeyboard::NativeEffect::cwave:
|
|
||||||
if (! setGroupKeys(
|
if (! setGroupKeys(
|
||||||
LedKeyboard::KeyGroup::indicators,
|
LedKeyboard::KeyGroup::indicators,
|
||||||
LedKeyboard::Color({0xff, 0xff, 0xff}))
|
LedKeyboard::Color({0xff, 0xff, 0xff}))
|
||||||
@ -749,25 +748,25 @@ bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, ui
|
|||||||
|
|
||||||
byte_buffer_t data;
|
byte_buffer_t data;
|
||||||
|
|
||||||
switch (effect) {
|
switch (effectGroup) {
|
||||||
|
|
||||||
case NativeEffect::color:
|
case NativeEffectGroup::color:
|
||||||
data = { 0x11, 0xff, protocolByte, 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 NativeEffectGroup::breathing:
|
||||||
data = {
|
data = {
|
||||||
0x11, 0xff, protocolByte, 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 NativeEffectGroup::cycle:
|
||||||
data = {
|
data = {
|
||||||
0x11, 0xff, protocolByte, 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;
|
||||||
case NativeEffect::hwave:
|
case NativeEffectGroup::waves:
|
||||||
switch (part) {
|
switch (part) {
|
||||||
case NativeEffectPart::logo:
|
case NativeEffectPart::logo:
|
||||||
setNativeEffect(NativeEffect::color, part, 0, Color({0x00, 0xff, 0xff}));
|
setNativeEffect(NativeEffect::color, part, 0, Color({0x00, 0xff, 0xff}));
|
||||||
@ -775,33 +774,9 @@ bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, ui
|
|||||||
default:
|
default:
|
||||||
data = {
|
data = {
|
||||||
0x11, 0xff, protocolByte, 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,
|
||||||
};
|
static_cast<uint8_t>(static_cast<uint16_t>(effect) & 0xff),
|
||||||
break;
|
0x64, speed
|
||||||
}
|
|
||||||
break;
|
|
||||||
case NativeEffect::vwave:
|
|
||||||
switch (part) {
|
|
||||||
case NativeEffectPart::logo:
|
|
||||||
setNativeEffect(NativeEffect::color, part, 0, Color({0x00, 0xff, 0xff}));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
data = {
|
|
||||||
0x11, 0xff, protocolByte, 0x3c, (uint8_t)part, 0x04,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x02, 0x64, speed
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case NativeEffect::cwave:
|
|
||||||
switch (part) {
|
|
||||||
case NativeEffectPart::logo:
|
|
||||||
setNativeEffect(NativeEffect::color, part, 0, Color({0x00, 0xff, 0xff}));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
data = {
|
|
||||||
0x11, 0xff, protocolByte, 0x3c, (uint8_t)part, 0x04,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x03, 0x64, speed
|
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -56,10 +56,17 @@ class LedKeyboard {
|
|||||||
wave = 0x01,
|
wave = 0x01,
|
||||||
color
|
color
|
||||||
};
|
};
|
||||||
enum class NativeEffect : uint8_t {
|
enum class NativeEffectGroup : uint8_t {
|
||||||
color = 0x01,
|
color = 0x01,
|
||||||
breathing,
|
breathing,
|
||||||
cycle,
|
cycle,
|
||||||
|
waves
|
||||||
|
};
|
||||||
|
enum class NativeEffect : uint16_t {
|
||||||
|
color = static_cast<uint16_t>(NativeEffectGroup::color) << 8,
|
||||||
|
breathing = static_cast<uint16_t>(NativeEffectGroup::breathing) << 8,
|
||||||
|
cycle = static_cast<uint16_t>(NativeEffectGroup::cycle) << 8,
|
||||||
|
waves = static_cast<uint16_t>(NativeEffectGroup::waves) << 8,
|
||||||
hwave,
|
hwave,
|
||||||
vwave,
|
vwave,
|
||||||
cwave
|
cwave
|
||||||
|
@ -248,6 +248,7 @@ namespace help {
|
|||||||
cout<<" -fx color {target} {color}"<<endl;
|
cout<<" -fx color {target} {color}"<<endl;
|
||||||
cout<<" -fx breathing {target} {color} {speed}"<<endl;
|
cout<<" -fx breathing {target} {color} {speed}"<<endl;
|
||||||
cout<<" -fx cycle {target} {speed}"<<endl;
|
cout<<" -fx cycle {target} {speed}"<<endl;
|
||||||
|
cout<<" -fx waves {target} {speed}"<<endl;
|
||||||
cout<<" -fx hwave {target} {speed}"<<endl;
|
cout<<" -fx hwave {target} {speed}"<<endl;
|
||||||
cout<<" -fx vwave {target} {speed}"<<endl;
|
cout<<" -fx vwave {target} {speed}"<<endl;
|
||||||
cout<<" -fx cwave {target} {speed}"<<endl;
|
cout<<" -fx cwave {target} {speed}"<<endl;
|
||||||
|
@ -25,6 +25,7 @@ namespace utils {
|
|||||||
if (val == "color") nativeEffect = LedKeyboard::NativeEffect::color;
|
if (val == "color") nativeEffect = LedKeyboard::NativeEffect::color;
|
||||||
else if (val == "cycle") nativeEffect = LedKeyboard::NativeEffect::cycle;
|
else if (val == "cycle") nativeEffect = LedKeyboard::NativeEffect::cycle;
|
||||||
else if (val == "breathing") nativeEffect = LedKeyboard::NativeEffect::breathing;
|
else if (val == "breathing") nativeEffect = LedKeyboard::NativeEffect::breathing;
|
||||||
|
else if (val == "waves") nativeEffect = LedKeyboard::NativeEffect::waves;
|
||||||
else if (val == "hwave") nativeEffect = LedKeyboard::NativeEffect::hwave;
|
else if (val == "hwave") nativeEffect = LedKeyboard::NativeEffect::hwave;
|
||||||
else if (val == "vwave") nativeEffect = LedKeyboard::NativeEffect::vwave;
|
else if (val == "vwave") nativeEffect = LedKeyboard::NativeEffect::vwave;
|
||||||
else if (val == "cwave") nativeEffect = LedKeyboard::NativeEffect::cwave;
|
else if (val == "cwave") nativeEffect = LedKeyboard::NativeEffect::cwave;
|
||||||
|
@ -121,6 +121,7 @@ int setFX(LedKeyboard &kbd, std::string arg2, std::string arg3, std::string arg4
|
|||||||
if (! utils::parseSpeed(arg5, speed)) return 1;
|
if (! utils::parseSpeed(arg5, speed)) return 1;
|
||||||
break;
|
break;
|
||||||
case LedKeyboard::NativeEffect::cycle:
|
case LedKeyboard::NativeEffect::cycle:
|
||||||
|
case LedKeyboard::NativeEffect::waves:
|
||||||
case LedKeyboard::NativeEffect::hwave:
|
case LedKeyboard::NativeEffect::hwave:
|
||||||
case LedKeyboard::NativeEffect::vwave:
|
case LedKeyboard::NativeEffect::vwave:
|
||||||
case LedKeyboard::NativeEffect::cwave:
|
case LedKeyboard::NativeEffect::cwave:
|
||||||
|
Loading…
Reference in New Issue
Block a user