From f4ea0405cd2005b7681536af4e3d447d43f949f6 Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sun, 8 Jan 2017 03:23:13 +0100 Subject: [PATCH] Add FX features --- sample_profiles/all_blue_fxl_breathing_red | 5 + src/classes/Keyboard.cpp | 90 +++---- src/classes/Keyboard.h | 15 +- src/main.cpp | 269 +++++++++------------ 4 files changed, 165 insertions(+), 214 deletions(-) create mode 100644 sample_profiles/all_blue_fxl_breathing_red diff --git a/sample_profiles/all_blue_fxl_breathing_red b/sample_profiles/all_blue_fxl_breathing_red new file mode 100644 index 0000000..0898d67 --- /dev/null +++ b/sample_profiles/all_blue_fxl_breathing_red @@ -0,0 +1,5 @@ +a 0000ff # Set all keys blue + +c # Commit changes + +fxl-breathing ff0000 10 # Set breathing effect with red color and speed 10 diff --git a/src/classes/Keyboard.cpp b/src/classes/Keyboard.cpp index 58e68ab..f107cd5 100644 --- a/src/classes/Keyboard.cpp +++ b/src/classes/Keyboard.cpp @@ -883,7 +883,7 @@ bool Keyboard::setGroupKeys(KeyGroup keyGroup, KeyColors colors) { return true; } -bool Keyboard::setFXColor(KeyColors colors) { +bool Keyboard::setFXColorKeys(KeyColors colors) { bool retval = false; int data_size = 20; unsigned char *data = new unsigned char[data_size]; @@ -899,6 +899,15 @@ bool Keyboard::setFXColor(KeyColors colors) { for(int i = 10; i < data_size; i++) data[i] = 0x00; retval = sendDataInternal(data, data_size); + delete[] data; + return retval; +} + +bool Keyboard::setFXColorLogo(KeyColors colors) { + bool retval = false; + int data_size = 20; + unsigned char *data = new unsigned char[data_size]; + // Logo populateFXAddressInternal(data); data[4] = 0x01; // Logo @@ -914,7 +923,7 @@ bool Keyboard::setFXColor(KeyColors colors) { return retval; } -bool Keyboard::setFXBreathing(KeyColors colors, uint8_t speed) { +bool Keyboard::setFXBreathingKeys(KeyColors colors, uint8_t speed) { bool retval = false; int data_size = 20; unsigned char *data = new unsigned char[data_size]; @@ -933,6 +942,15 @@ bool Keyboard::setFXBreathing(KeyColors colors, uint8_t speed) { for(int i = 13; i < data_size; i++) data[i] = 0x00; retval = sendDataInternal(data, data_size); + delete[] data; + return retval; +} + +bool Keyboard::setFXBreathingLogo(KeyColors colors, uint8_t speed) { + bool retval = false; + int data_size = 20; + unsigned char *data = new unsigned char[data_size]; + // Logo populateFXAddressInternal(data); data[4] = 0x01; // Logo @@ -951,7 +969,7 @@ bool Keyboard::setFXBreathing(KeyColors colors, uint8_t speed) { return retval; } -bool Keyboard::setFXColorCycle(uint8_t speed) { +bool Keyboard::setFXColorCycleKeys(uint8_t speed) { bool retval = false; int data_size = 20; unsigned char *data = new unsigned char[data_size]; @@ -972,6 +990,15 @@ bool Keyboard::setFXColorCycle(uint8_t speed) { for(int i = 15; i < data_size; i++) data[i] = 0x00; retval = sendDataInternal(data, data_size); + delete[] data; + return retval; +} + +bool Keyboard::setFXColorCycleLogo(uint8_t speed) { + bool retval = false; + int data_size = 20; + unsigned char *data = new unsigned char[data_size]; + // Logo populateFXAddressInternal(data); data[4] = 0x01; // Logo @@ -992,7 +1019,7 @@ bool Keyboard::setFXColorCycle(uint8_t speed) { return retval; } -bool Keyboard::setFXHWave(uint8_t speed) { +bool Keyboard::setFXHWaveKeys(uint8_t speed) { bool retval = false; int data_size = 20; unsigned char *data = new unsigned char[data_size]; @@ -1014,28 +1041,11 @@ bool Keyboard::setFXHWave(uint8_t speed) { for(int i = 16; i < data_size; i++) data[i] = 0x00; retval = sendDataInternal(data, data_size); - // Logo - populateFXAddressInternal(data); - data[4] = 0x01; // Logo - data[5] = 0x03; // Effect - 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 Keyboard::setFXVWaveKeys(uint8_t speed) { bool retval = false; int data_size = 20; unsigned char *data = new unsigned char[data_size]; @@ -1057,28 +1067,11 @@ bool Keyboard::setFXVWave(uint8_t speed) { for(int i = 16; i < data_size; i++) data[i] = 0x00; retval = sendDataInternal(data, data_size); - // Logo - populateFXAddressInternal(data); - data[4] = 0x01; // Logo - data[5] = 0x03; // Effect - 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 Keyboard::setFXCWaveKeys(uint8_t speed) { bool retval = false; int data_size = 20; unsigned char *data = new unsigned char[data_size]; @@ -1100,23 +1093,6 @@ bool Keyboard::setFXCWave(uint8_t speed) { for(int i = 16; i < data_size; i++) data[i] = 0x00; retval = sendDataInternal(data, data_size); - // Logo - populateFXAddressInternal(data); - data[4] = 0x01; // Logo - data[5] = 0x03; // Effect - 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; } diff --git a/src/classes/Keyboard.h b/src/classes/Keyboard.h index 80c7107..5571e4e 100644 --- a/src/classes/Keyboard.h +++ b/src/classes/Keyboard.h @@ -52,12 +52,15 @@ class Keyboard { bool setKeys(KeyValue keyValue[], size_t keyValueCount); bool setAllKeys(KeyColors colors); bool setGroupKeys(KeyGroup keyGroup, KeyColors colors); - 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); + bool setFXColorKeys(KeyColors colors); + bool setFXColorLogo(KeyColors colors); + bool setFXBreathingKeys(KeyColors colors, uint8_t speed); + bool setFXBreathingLogo(KeyColors colors, uint8_t speed); + bool setFXColorCycleKeys(uint8_t speed); + bool setFXColorCycleLogo(uint8_t speed); + bool setFXHWaveKeys(uint8_t speed); + bool setFXVWaveKeys(uint8_t speed); + bool setFXCWaveKeys(uint8_t speed); private: diff --git a/src/main.cpp b/src/main.cpp index d513509..3c2c9f0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,7 +22,6 @@ void usage() { cout<<" -an color :\t\t\tSet all keys without commit"<