mirror of
https://github.com/MatMoul/g810-led.git
synced 2024-12-23 01:06:11 +00:00
Add first shot for effect code
This commit is contained in:
parent
c68a0f2d4f
commit
5a2bff5225
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
13
src/main.cpp
13
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;
|
||||
|
Loading…
Reference in New Issue
Block a user