diff --git a/src/classes/Keyboard.cpp b/src/classes/Keyboard.cpp index 45ba55f..48b07b3 100644 --- a/src/classes/Keyboard.cpp +++ b/src/classes/Keyboard.cpp @@ -843,3 +843,77 @@ bool Keyboard::setGroupKeys(KeyGroup keyGroup, KeyColors colors) { } return true; } + +bool Keyboard::setFXColor(KeyColors colors) { + bool retval = false; + int data_size = 20; + unsigned char *data = new unsigned char[data_size]; + + // Indicators + data[0] = 0x11; // Base address + data[1] = 0xff; // Base address + data[2] = 0x0c; // Base address + data[3] = 0x4c; // Base address + data[4] = 0x00; // Base address + data[5] = 0x40; // Base address + + data[6] = colors.red; + data[7] = colors.green; + data[8] = colors.blue; + + for(int i = 9; i < data_size; i++) data[i] = 0x00; + + retval = sendDataInternal(data, data_size); + + + data[0] = 0x11; // Base address + data[1] = 0xff; // Base address + data[2] = 0x0c; // Base address + data[3] = 0x5c; // Base address + + for(int i = 4; i < data_size; i++) data[i] = 0x00; + + retval = sendDataInternal(data, data_size); + + + + // Keys + data[0] = 0x11; // Base address + data[1] = 0xff; // Base address + data[2] = 0x0d; // Base address + data[3] = 0x3c; // Base address + data[4] = 0x00; // Base address + data[5] = 0x01; // Base address + + data[6] = colors.red; + data[7] = colors.green; + data[8] = colors.blue; + data[9] = 0x02; + + for(int i = 10; 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] = 0x3c; // Base address + data[4] = 0x01; // Base address + data[5] = 0x01; // Base address + + data[6] = colors.red; + data[7] = colors.green; + data[8] = colors.blue; + data[9] = 0x02; + + for(int i = 10; i < data_size; i++) data[i] = 0x00; + + retval = sendDataInternal(data, data_size); + + + delete[] data; + return retval; +} + diff --git a/src/classes/Keyboard.h b/src/classes/Keyboard.h index a2b563e..ebb847a 100644 --- a/src/classes/Keyboard.h +++ b/src/classes/Keyboard.h @@ -51,6 +51,7 @@ class Keyboard { bool setKeys(KeyValue keyValue[], size_t keyValueCount); bool setAllKeys(KeyColors colors); bool setGroupKeys(KeyGroup keyGroup, KeyColors colors); + bool setFXColor(KeyColors colors); private: diff --git a/src/main.cpp b/src/main.cpp index e1dd1ce..b434683 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -200,6 +200,18 @@ int setGroupKeys(string groupKeys, string color, bool commit) { return 1; } +int setFXColor(string color) { + Keyboard lg_kbd; + Keyboard::KeyColors colors; + if (lg_kbd.parseColor(color, colors) == true) { + lg_kbd.attach(); + lg_kbd.setFXColor(colors); + lg_kbd.detach(); + return 0; + } + return 1; +} + int loadProfile(string profileFile) { ifstream file; @@ -304,6 +316,7 @@ int main(int argc, char *argv[]) { else if (argCmd == "-kn" && argc == 4) return setKey(argv[2], argv[3], false); else if (argCmd == "-c" && argc == 2) return commit(); else if (argCmd == "-p" && argc == 3) return loadProfile(argv[2]); + else if (argCmd == "-fx-color" && argc == 3) return setFXColor(argv[2]); } usage(); return 1;