Skip to content
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

Added: Bulgarian flag visualization #233

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
132 changes: 132 additions & 0 deletions KeyboardVisualizerCommon/Visualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,102 @@ Visualizer::Visualizer()

}

void Visualizer::BeginLEDMatrix(int size)
{
matrix_setup_size = size;
matrix_setup_pos = 1;
}

void Visualizer::LEDStripSections(int size)
{
ledstrip_sections_size = size;
}

void Visualizer::LEDMirrorX()
{
ledstrip_mirror_x = true;
}

void Visualizer::LEDMirrorY()
{
ledstrip_mirror_y = true;
}

void Visualizer::LEDSingleColor()
{
ledstrip_single_color = true;
}

void Visualizer::LEDRotateX(int rotate)
{
ledstrip_rotate_x = rotate;
}

void Visualizer::AddLEDStrip(int led_type, char* ledstring)
{
//Scan through already registered LED strips and
//verify that the port name is not already in use
for (unsigned int i = 0; i < str.size(); i++)
{
if (strcmp(str[i]->GetLEDString(), ledstring) == 0)
{
return;
}
}

LEDStrip *newstr = new LEDStrip();
newstr->Initialize(led_type, ledstring, matrix_setup_size, matrix_setup_pos, ledstrip_sections_size, ledstrip_rotate_x, ledstrip_mirror_x, ledstrip_mirror_y, ledstrip_single_color);
str.push_back(newstr);

ledstrip_sections_size = 1;
ledstrip_mirror_x = false;
ledstrip_mirror_y = false;
ledstrip_single_color = false;
ledstrip_rotate_x = 0;

if (matrix_setup_pos < matrix_setup_size)
{
matrix_setup_pos += ledstrip_sections_size;
}
else
{
matrix_setup_size = 0;
matrix_setup_pos = 0;
}
}

void Visualizer::SetDeviceProperty(char * devprop, char * argument)
{
//Save device property to list of device properties
char * buf = new char[strlen(devprop) + 1];
strcpy(buf, devprop);
device_properties.push_back(buf);

//Parse device properties exclusive to Windows
#ifdef WIN32
if (strcmp(devprop, "razer_use_keyboard_custom_effect") == 0)
{
rkb.use_keyboard_custom_effect = true;
}
else if (strcmp(devprop, "razer_use_headset_custom_effect") == 0)
{
rkb.use_headset_custom_effect = true;
}
else if (strcmp(devprop, "razer_use_chromalink_single_color") == 0)
{
rkb.use_chromalink_single_color = true;
}
else if (strcmp(devprop, "razer_disable_chromalink") == 0)
{
rkb.disable_chromalink = true;
}
else if (strcmp(devprop, "razer_chroma_box_mode") == 0)
{
rkb.chroma_box_mode = atoi(argument);
}
#endif
}

void Visualizer::InitAudioDeviceList()
{
#ifdef WIN32
Expand Down Expand Up @@ -396,6 +492,31 @@ void Visualizer::SaveSettings()
snprintf(out_str, 1024, "audio_device_idx=%d\r\n", audio_device_idx);
outfile.write(out_str, strlen(out_str));

//Save LED Strip Configurations
for (unsigned int i = 0; i < str.size(); i++)
{
switch (str[i]->led_type)
{
case LED_STRIP_NORMAL:
//Save LED Strip Configuration
snprintf(out_str, 1024, "ledstrip=%s\r\n", str[i]->GetLEDString());
outfile.write(out_str, strlen(out_str));
break;

case LED_STRIP_XMAS:
//Save Xmas Strip Configuration
snprintf(out_str, 1024, "xmas=%s\r\n", str[i]->GetLEDString());
outfile.write(out_str, strlen(out_str));
break;

case LED_STRIP_HUE_PLUS:
//Save HuePlus Configuration
snprintf(out_str, 1024, "hueplus=%s\r\n", str[i]->GetLEDString());
outfile.write(out_str, strlen(out_str));
break;
}
}

//Save Network Mode
switch (netmode)
{
Expand Down Expand Up @@ -951,6 +1072,13 @@ void Visualizer::DrawPattern(VISUALIZER_PATTERN pattern, int bright, vis_pixels
}
break;

case VISUALIZER_PATTERN_STATIC_FLAG_BULGARIA:
{
COLORREF colors[] = { 0x000000FF, 0x0000FF00, 0x00FFFFFF };
DrawHorizontalBars(bright, colors, 3, pixels);
}
break;

case VISUALIZER_PATTERN_STATIC_BLUE_CYAN_WHITE:
{
RGBColor colors[] = { 0x00FF0000, 0x00FFFF00, 0x00FFFFFF };
Expand Down Expand Up @@ -1499,6 +1627,8 @@ void Visualizer::LEDUpdateThreadFunction()

for(int z = 0; z < rgb_controllers[c]->zones.size(); z++)
{
str[i]->SetPixels(pixels_out->pixels);
str[i]->SetDelay(delay);
int x_count = rgb_controllers[c]->zones[z].leds_count;
int y_count = 0;
zone_type type = rgb_controllers[c]->zones[z].type;
Expand Down Expand Up @@ -1605,6 +1735,8 @@ void Visualizer::LEDUpdateThreadFunction()
controller_found = true;
}
}

Sleep(delay);

if(controller_found == false)
{
Expand Down
2 changes: 2 additions & 0 deletions KeyboardVisualizerCommon/VisualizerDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ enum
VISUALIZER_PATTERN_STATIC_RED_WHITE_BLUE,
VISUALIZER_PATTERN_STATIC_RAINBOW,
VISUALIZER_PATTERN_STATIC_RAINBOW_INVERSE,
VISUALIZER_PATTERN_STATIC_FLAG_BULGARIA,
//Animated Patterns
VISUALIZER_PATTERN_ANIM_RAINBOW_SINUSOIDAL,
VISUALIZER_PATTERN_ANIM_RAINBOW_HSV,
Expand Down Expand Up @@ -90,6 +91,7 @@ const char * const visualizer_pattern_labels[VISUALIZER_NUM_PATTERNS] =
"Red/White/Blue",
"Rainbow Bars",
"Rainbow Bars Inverse",
"Bulgarian flag",
"Original",
"Rainbow",
"Color Wheel",
Expand Down
Binary file added Settings/CUESDK_2013.dll
Binary file not shown.
Binary file added Settings/KeyboardVisualizerVC.ilk
Binary file not shown.
Binary file added Settings/KeyboardVisualizerVC.pdb
Binary file not shown.
Binary file added Settings/SDKDLL.dll
Binary file not shown.
18 changes: 18 additions & 0 deletions Settings/settings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
amplitude=1300
bkgd_bright=100
avg_size=8
decay=80
delay=50
nrml_ofst=0.040000
nrml_scl=0.500000
fltr_const=1.000000
window_mode=1
bkgd_mode=0
frgd_mode=15
single_color_mode=11
avg_mode=0
anim_speed=100.000000
reactive_bkgd=0
silent_bkgd=0
background_timeout=120
audio_device_idx=9
Expand Down