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

Add wave effect

This commit is contained in:
MatMoul 2016-12-30 21:35:26 +01:00
parent 3b13f247b5
commit 4bfa9811b3
3 changed files with 213 additions and 0 deletions

View File

@ -978,3 +978,149 @@ bool Keyboard::setFXColorCycle(uint8_t speed) {
return retval;
}
bool Keyboard::setFXHWave(uint8_t speed) {
bool retval = false;
int data_size = 20;
unsigned char *data = new unsigned char[data_size];
// Keys
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3b; // Base address
data[4] = 0x00; // Base address
data[5] = 0x04; // Base address
data[6] = 0x00;
data[7] = 0x00;
data[8] = 0x00;
data[9] = 0x00;
data[10] = 0x00;
data[11] = 0x00;
data[12] = 0x88;
data[13] = 0x01;
data[14] = 0x64;
data[15] = speed; // Speed
for(int i = 16; i < data_size; i++) data[i] = 0x00;
retval = sendDataInternal(data, data_size);
// Logo
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3b; // Base address
data[4] = 0x01; // Base address
data[5] = 0x03; // Base address
data[6] = 0x00;
data[7] = 0x00;
data[8] = 0x00;
data[9] = 0x00;
data[10] = 0x00;
data[11] = speed; // Speed
data[12] = 0x88;
data[13] = 0x64;
data[14] = 0x00;
data[15] = 0x00;
for(int i = 16; i < data_size; i++) data[i] = 0x00;
retval = sendDataInternal(data, data_size);
delete[] data;
return retval;
}
bool Keyboard::setFXVWave(uint8_t speed) {
bool retval = false;
int data_size = 20;
unsigned char *data = new unsigned char[data_size];
// Keys
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3b; // Base address
data[4] = 0x00; // Base address
data[5] = 0x04; // Base address
data[6] = 0x00;
data[7] = 0x00;
data[8] = 0x00;
data[9] = 0x00;
data[10] = 0x00;
data[11] = 0x00;
data[12] = 0x88;
data[13] = 0x02;
data[14] = 0x64;
data[15] = speed; // Speed
for(int i = 16; i < data_size; i++) data[i] = 0x00;
retval = sendDataInternal(data, data_size);
// Logo
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3b; // Base address
data[4] = 0x01; // Base address
data[5] = 0x03; // Base address
data[6] = 0x00;
data[7] = 0x00;
data[8] = 0x00;
data[9] = 0x00;
data[10] = 0x00;
data[11] = speed; // Speed
data[12] = 0x88;
data[13] = 0x64;
data[14] = 0x00;
data[15] = 0x00;
for(int i = 16; i < data_size; i++) data[i] = 0x00;
retval = sendDataInternal(data, data_size);
delete[] data;
return retval;
}
bool Keyboard::setFXCWave(uint8_t speed) {
bool retval = false;
int data_size = 20;
unsigned char *data = new unsigned char[data_size];
// Keys
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3b; // Base address
data[4] = 0x00; // Base address
data[5] = 0x04; // Base address
data[6] = 0x00;
data[7] = 0x00;
data[8] = 0x00;
data[9] = 0x00;
data[10] = 0x00;
data[11] = 0x00;
data[12] = 0x88;
data[13] = 0x03;
data[14] = 0x64;
data[15] = speed; // Speed
for(int i = 16; i < data_size; i++) data[i] = 0x00;
retval = sendDataInternal(data, data_size);
// Logo
data[0] = 0x11; // Base address
data[1] = 0xff; // Base address
data[2] = 0x0d; // Base address
data[3] = 0x3b; // Base address
data[4] = 0x01; // Base address
data[5] = 0x03; // Base address
data[6] = 0x00;
data[7] = 0x00;
data[8] = 0x00;
data[9] = 0x00;
data[10] = 0x00;
data[11] = speed; // Speed
data[12] = 0x88;
data[13] = 0x64;
data[14] = 0x00;
data[15] = 0x00;
for(int i = 16; i < data_size; i++) data[i] = 0x00;
retval = sendDataInternal(data, data_size);
delete[] data;
return retval;
}

View File

@ -55,6 +55,9 @@ class Keyboard {
bool setFXColor(KeyColors colors);
bool setFXBreathing(KeyColors colors, uint8_t speed);
bool setFXColorCycle(uint8_t speed);
bool setFXHWave(uint8_t speed);
bool setFXVWave(uint8_t speed);
bool setFXCWave(uint8_t speed);
private:

View File

@ -25,6 +25,9 @@ void usage() {
cout<<" -fx-color color :\t\tSet static color effect\n";
cout<<" -fx-breathing color, speed :\tSet breathing effect\n";
cout<<" -fx-cycle speed :\t\tSet color cycle effect\n";
cout<<" -fx-hwave speed :\t\tSet horizontal color wave effect\n";
cout<<" -fx-vwave speed :\t\tSet vertical color wave effect\n";
cout<<" -fx-cwave speed :\t\tSet center color wave effect\n";
cout<<"\n";
cout<<" -p profilefile :\t\tLoad a profile\n";
cout<<"\n";
@ -261,8 +264,66 @@ int setFXColorCycle(string speed) {
return 1;
}
int setFXHWave(string speed) {
Keyboard lg_kbd;
Keyboard::KeyColors colors;
uint8_t speedValue;
if (lg_kbd.parseSpeed(speed, speedValue) == true) {
colors.red = 0xff;
colors.green = 0xff;
colors.blue = 0xff;
lg_kbd.attach();
lg_kbd.setGroupKeys(Keyboard::KeyGroup::indicators, colors);
lg_kbd.commit();
lg_kbd.detach();
lg_kbd.attach();
lg_kbd.setFXHWave(speedValue);
lg_kbd.detach();
return 0;
}
return 1;
}
int setFXVWave(string speed) {
Keyboard lg_kbd;
Keyboard::KeyColors colors;
uint8_t speedValue;
if (lg_kbd.parseSpeed(speed, speedValue) == true) {
colors.red = 0xff;
colors.green = 0xff;
colors.blue = 0xff;
lg_kbd.attach();
lg_kbd.setGroupKeys(Keyboard::KeyGroup::indicators, colors);
lg_kbd.commit();
lg_kbd.detach();
lg_kbd.attach();
lg_kbd.setFXVWave(speedValue);
lg_kbd.detach();
return 0;
}
return 1;
}
int setFXCWave(string speed) {
Keyboard lg_kbd;
Keyboard::KeyColors colors;
uint8_t speedValue;
if (lg_kbd.parseSpeed(speed, speedValue) == true) {
colors.red = 0xff;
colors.green = 0xff;
colors.blue = 0xff;
lg_kbd.attach();
lg_kbd.setGroupKeys(Keyboard::KeyGroup::indicators, colors);
lg_kbd.commit();
lg_kbd.detach();
lg_kbd.attach();
lg_kbd.setFXCWave(speedValue);
lg_kbd.detach();
return 0;
}
return 1;
return 1;
}
int loadProfile(string profileFile) {
ifstream file;
@ -371,6 +432,9 @@ int main(int argc, char *argv[]) {
else if (argCmd == "-fx-color" && argc == 3) return setFXColor(argv[2]);
else if (argCmd == "-fx-breathing" && argc == 4) return setFXBreathing(argv[2], argv[3]);
else if (argCmd == "-fx-cycle" && argc == 3) return setFXColorCycle(argv[2]);
else if (argCmd == "-fx-hwave" && argc == 3) return setFXHWave(argv[2]);
else if (argCmd == "-fx-vwave" && argc == 3) return setFXVWave(argv[2]);
else if (argCmd == "-fx-cwave" && argc == 3) return setFXCWave(argv[2]);
}
usage();
return 1;