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

Add ripple and off effects

NOTE: Ripple effect (0x05) seems to have a conflict with an unadvertised
"stars"-like effect for the G410 and G810. Did not explore setting
timing for the G410/G810 effect, but is likely contrasted greatly with
the timing of the new Ripple effect. GHub limits ripple timing between
20ms and 200ms, but actual values are arbitrary and were tested up to
5000ms. Ideally should be kept within the 20-200ms range for best feel
of the effect. Logo does not honor the effect, and GHub simply sets to
the default "Logitech Blue".

Signed-off-by: Kevin Pearson <kevin.pearson@ortmanconsulting.com>
This commit is contained in:
Kevin Pearson 2019-09-26 08:50:46 -04:00
parent 1a26bf7e64
commit b938bf6c1d
2 changed files with 27 additions and 3 deletions

View File

@ -739,12 +739,15 @@ bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part,
break; break;
case NativeEffectGroup::cycle: case NativeEffectGroup::cycle:
case NativeEffectGroup::waves: case NativeEffectGroup::waves:
case NativeEffectGroup::ripple:
if (! setGroupKeys( if (! setGroupKeys(
LedKeyboard::KeyGroup::indicators, LedKeyboard::KeyGroup::indicators,
LedKeyboard::Color({0xff, 0xff, 0xff})) LedKeyboard::Color({0xff, 0xff, 0xff}))
) return false; ) return false;
if (! commit()) return false; if (! commit()) return false;
break; break;
default:
break;
} }
return ( return (
setNativeEffect(effect, LedKeyboard::NativeEffectPart::keys, period, color, storage) && setNativeEffect(effect, LedKeyboard::NativeEffectPart::keys, period, color, storage) &&
@ -810,6 +813,19 @@ bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part,
switch (part) { switch (part) {
case NativeEffectPart::keys: case NativeEffectPart::keys:
data[4] = 0x01; data[4] = 0x01;
//Seems to conflict with a star-like effect on G410 and G810
switch (effect) {
case NativeEffect::ripple:
//Adjust periodicity
data[9]=0x00;
data[10]=period.count() >> 8 & 0xff;;
data[11]=period.count() & 0xff;
data[12]=0x00;
break;
default:
break;
}
break; break;
case NativeEffectPart::logo: case NativeEffectPart::logo:
data[4] = 0x00; data[4] = 0x00;
@ -827,6 +843,10 @@ bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part,
case NativeEffect::cycle: case NativeEffect::cycle:
data[5]=0x02; data[5]=0x02;
break; break;
case NativeEffect::ripple:
case NativeEffect::off:
data[5]=0x00;
break;
default: default:
data[5]=0x01; data[5]=0x01;
break; break;

View File

@ -79,19 +79,23 @@ class LedKeyboard {
color color
}; };
enum class NativeEffectGroup : uint8_t { enum class NativeEffectGroup : uint8_t {
color = 0x01, off,
color,
breathing, breathing,
cycle, cycle,
waves waves,
ripple
}; };
enum class NativeEffect : uint16_t { enum class NativeEffect : uint16_t {
off,
color = static_cast<uint16_t>(NativeEffectGroup::color) << 8, color = static_cast<uint16_t>(NativeEffectGroup::color) << 8,
breathing = static_cast<uint16_t>(NativeEffectGroup::breathing) << 8, breathing = static_cast<uint16_t>(NativeEffectGroup::breathing) << 8,
cycle = static_cast<uint16_t>(NativeEffectGroup::cycle) << 8, cycle = static_cast<uint16_t>(NativeEffectGroup::cycle) << 8,
waves = static_cast<uint16_t>(NativeEffectGroup::waves) << 8, waves = static_cast<uint16_t>(NativeEffectGroup::waves) << 8,
hwave, hwave,
vwave, vwave,
cwave cwave,
ripple = static_cast<uint16_t>(NativeEffectGroup::ripple) << 8
}; };
enum class NativeEffectPart : uint8_t { enum class NativeEffectPart : uint8_t {
all = 0xff, all = 0xff,