Skip to content

Channel Selection, Bugfix #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions KeyboardVisualizerCommon/LEDStrip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,31 @@ void LEDStrip::Initialize(char* ledstring)

void LEDStrip::InitializeHuePlus(char* ledstring)
{
strcpy(led_string, ledstring);

LPSTR source = NULL;
LPSTR numleds = NULL;
LPSTR next = NULL;

source = strtok_s(ledstring, ",", &next);
strcpy(led_string, ledstring);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TABs instead of spaces


LPSTR source = NULL;
LPSTR channels = NULL;
Copy link
Contributor

@d-rez d-rez Feb 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's up with this alignment? :) You tried to align the first two and then gave up with the rest

LPSTR numleds = NULL;
LPSTR next = NULL;

source = strtok_s(ledstring, ",", &next);

//Check for selected channel 0=both, 1= Ch.1, 2= Ch.2
if (strlen(next))
{
channels = strtok_s(next, ",", &next);
}
switch (atoi(channels)) {
case 0:
channel = 0x00;
break;
case 1:
channel = 0x01;
break;
case 2:
channel = 0x02;
break;
}

//Check for the number of LEDs, sets the corresponding variable with the counter for the fans
if (strlen(next))
Expand Down Expand Up @@ -274,17 +292,17 @@ void LEDStrip::SetLEDsHuePlus(COLORREF pixels[64][256])
if (serialport != NULL)
{
unsigned char *serial_buf;

serial_buf = new unsigned char[250]; //Size of Message always 5 XX Blocks (Mode Selection) + 3 XX for each LED (1 color)
serial_buf = new unsigned char[hueSize]; //Size of Message always 5 XX Blocks (Mode Selection) + 3 XX for each LED (1 color)
//-> max of 40 LEDs per Channel (or 5 Fans a 8 LEDs) -> 125 Blocks (empty LEDs are written, too)

serial_buf[0] = 0x4b;
serial_buf[1] = 0x00;
serial_buf[2] = 0x0e;
serial_buf[1] = channel;
serial_buf[2] = 0x0e;
serial_buf[3] = fans;
serial_buf[4] = 0x00;

for (int i = 5; i < 250; i++)
for (int i = 5; i < hueSize; i++)
{
//clearing the buf otherwise sometimes strange things are written to the COM Port
serial_buf[i] = 0x00;
Expand All @@ -299,7 +317,7 @@ void LEDStrip::SetLEDsHuePlus(COLORREF pixels[64][256])
serial_buf[idx + 7] = GetBValue(color);
}

serialport->serial_write((char *)serial_buf,250);
serialport->serial_write((char *)serial_buf,hueSize);
serialport->serial_flush_tx();

delete[] serial_buf;
Expand Down
2 changes: 2 additions & 0 deletions KeyboardVisualizerCommon/LEDStrip.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class LEDStrip
int baud_rate;
int num_leds;
int fans;
int channel;
const int hueSize = 125;

int * LEDStripXIndex;
int * LEDStripYIndex;
Expand Down
2 changes: 2 additions & 0 deletions KeyboardVisualizerVC/KeyboardVisualizerVC.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
<ClCompile Include="..\KeyboardVisualizerCommon\LogitechSDK.cpp" />
<ClCompile Include="..\KeyboardVisualizerCommon\MSIKeyboard.cpp" />
<ClCompile Include="..\KeyboardVisualizerCommon\net_port.cpp" />
<ClCompile Include="..\KeyboardVisualizerCommon\PoseidonZRGBKeyboard.cpp" />
Copy link
Contributor

@d-rez d-rez Feb 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be merged to master yet, along with the other Poseidon include

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thought could be nice cause the project can't be build unless you manually add the poseidonz files to the project.

Regarding the other things. I will update my code :)

<ClCompile Include="..\KeyboardVisualizerCommon\RazerChroma.cpp" />
<ClCompile Include="..\KeyboardVisualizerCommon\serial_port.cpp" />
<ClCompile Include="..\KeyboardVisualizerCommon\SteelSeriesGameSense.cpp" />
Expand All @@ -199,6 +200,7 @@
<ClInclude Include="..\KeyboardVisualizerCommon\LogitechSDK.h" />
<ClInclude Include="..\KeyboardVisualizerCommon\MSIKeyboard.h" />
<ClInclude Include="..\KeyboardVisualizerCommon\net_port.h" />
<ClInclude Include="..\KeyboardVisualizerCommon\PoseidonZRGBKeyboard.h" />
<ClInclude Include="..\KeyboardVisualizerCommon\RazerChroma.h" />
<ClInclude Include="..\KeyboardVisualizerCommon\serial_port.h" />
<ClInclude Include="..\KeyboardVisualizerCommon\SteelSeriesGameSense.h" />
Expand Down
5 changes: 3 additions & 2 deletions KeyboardVisualizerVC/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,13 @@ boolean parse_command_line(char * command_line)
printf(" - (ex.ledstrip=udp:192.168.1.5,1234,30)\r\n");
printf(" xmas - COM port, ex. xmas=COM2\r\n");
printf(" hueplus - HUE+ config:\r\n");
printf(" - hueplus=port,num_leds\r\n");
printf(" - hueplus=port,channel,num_leds\r\n");
printf(" - channel: 0 -> both channels, 1 -> channel 1, 2 -> channel 2\r\n");
printf(" - num_leds: Fans * 8 ex. 3 Fans -> 24\r\n");
printf(" - Important for Fans: If you have connected fans on both channels only count the fans on the channel with the most fans\r\n");
printf(" ex. 3 Fans on Ch. 1 4 Fans on CH. 2: num_leds 32 for the 4 Fans\r\n");
printf(" For best Visualizer results don`t connect on one channel 3 fans more than on the other channel\r\n");
printf(" - (ex. hueplus=COM4,24\r\n");
printf(" - (ex. hueplus=COM4,1,24\r\n");
return FALSE;
}

Expand Down