1
0
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:
Daniel Eble 2018-12-31 18:56:30 -05:00
parent 062ad6f9c4
commit 2426ef641d
5 changed files with 25 additions and 40 deletions

View File

@ -699,22 +699,21 @@ bool LedKeyboard::setStartupMode(StartupMode startupMode) {
bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, uint8_t speed, Color color) {
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
if (part == LedKeyboard::NativeEffectPart::all) {
switch (effect) {
case LedKeyboard::NativeEffect::color:
switch (effectGroup) {
case NativeEffectGroup::color:
if (! setGroupKeys(LedKeyboard::KeyGroup::indicators, color)) return false;
if (! commit()) return false;
break;
case LedKeyboard::NativeEffect::breathing:
case NativeEffectGroup::breathing:
if (! setGroupKeys(LedKeyboard::KeyGroup::indicators, color)) return false;;
if (! commit()) return false;;
break;
case LedKeyboard::NativeEffect::cycle:
case LedKeyboard::NativeEffect::hwave:
case LedKeyboard::NativeEffect::vwave:
case LedKeyboard::NativeEffect::cwave:
case NativeEffectGroup::cycle:
case NativeEffectGroup::waves:
if (! setGroupKeys(
LedKeyboard::KeyGroup::indicators,
LedKeyboard::Color({0xff, 0xff, 0xff}))
@ -749,25 +748,25 @@ bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, ui
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 };
break;
case NativeEffect::breathing:
case NativeEffectGroup::breathing:
data = {
0x11, 0xff, protocolByte, 0x3c, (uint8_t)part, 0x02,
color.red, color.green, color.blue, speed,
0x10, 0x00, 0x64
};
break;
case NativeEffect::cycle:
case NativeEffectGroup::cycle:
data = {
0x11, 0xff, protocolByte, 0x3c, (uint8_t)part, 0x03,
0x00, 0x00, 0x00, 0x00, 0x00, speed, 0x00, 0x00, 0x64
};
break;
case NativeEffect::hwave:
case NativeEffectGroup::waves:
switch (part) {
case NativeEffectPart::logo:
setNativeEffect(NativeEffect::color, part, 0, Color({0x00, 0xff, 0xff}));
@ -775,33 +774,9 @@ bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, ui
default:
data = {
0x11, 0xff, protocolByte, 0x3c, (uint8_t)part, 0x04,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x01, 0x64, speed
};
break;
}
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
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88,
static_cast<uint8_t>(static_cast<uint16_t>(effect) & 0xff),
0x64, speed
};
break;
}

View File

@ -56,10 +56,17 @@ class LedKeyboard {
wave = 0x01,
color
};
enum class NativeEffect : uint8_t {
enum class NativeEffectGroup : uint8_t {
color = 0x01,
breathing,
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,
vwave,
cwave

View File

@ -248,6 +248,7 @@ namespace help {
cout<<" -fx color {target} {color}"<<endl;
cout<<" -fx breathing {target} {color} {speed}"<<endl;
cout<<" -fx cycle {target} {speed}"<<endl;
cout<<" -fx waves {target} {speed}"<<endl;
cout<<" -fx hwave {target} {speed}"<<endl;
cout<<" -fx vwave {target} {speed}"<<endl;
cout<<" -fx cwave {target} {speed}"<<endl;

View File

@ -25,6 +25,7 @@ namespace utils {
if (val == "color") nativeEffect = LedKeyboard::NativeEffect::color;
else if (val == "cycle") nativeEffect = LedKeyboard::NativeEffect::cycle;
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 == "vwave") nativeEffect = LedKeyboard::NativeEffect::vwave;
else if (val == "cwave") nativeEffect = LedKeyboard::NativeEffect::cwave;

View File

@ -121,6 +121,7 @@ int setFX(LedKeyboard &kbd, std::string arg2, std::string arg3, std::string arg4
if (! utils::parseSpeed(arg5, speed)) return 1;
break;
case LedKeyboard::NativeEffect::cycle:
case LedKeyboard::NativeEffect::waves:
case LedKeyboard::NativeEffect::hwave:
case LedKeyboard::NativeEffect::vwave:
case LedKeyboard::NativeEffect::cwave: