OAdd strip autodetection to NZXT Hue+ interface, group zones into channels
This commit is contained in:
parent
d2acc75ba8
commit
1a5b12c7a0
5 changed files with 166 additions and 113 deletions
|
|
@ -11,33 +11,59 @@
|
|||
|
||||
RGBController_HuePlus::RGBController_HuePlus(HuePlusController* hueplus_ptr)
|
||||
{
|
||||
strip = hueplus_ptr;
|
||||
hueplus = hueplus_ptr;
|
||||
|
||||
name = "LED Strip";
|
||||
name = "NZXT Hue+";
|
||||
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
|
||||
location = hueplus->GetLEDString();
|
||||
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
|
||||
for (int i = 0; i < strip->num_leds; i++)
|
||||
{
|
||||
colors.push_back(0x00000000);
|
||||
led new_led;
|
||||
new_led.name = "LED Strip";
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
unsigned int led_idx = 0;
|
||||
|
||||
zone led_zone;
|
||||
led_zone.name = "LED Strip";
|
||||
std::vector<int> led_zone_map;
|
||||
for (int i = 0; i < strip->num_leds; i++)
|
||||
for (int channel_idx = 0; channel_idx < HUE_PLUS_NUM_CHANNELS; channel_idx++)
|
||||
{
|
||||
led_zone_map.push_back(i);
|
||||
if(hueplus->channel_leds[channel_idx] > 0)
|
||||
{
|
||||
zone* new_zone = new zone;
|
||||
|
||||
char ch_idx_string[2];
|
||||
sprintf(ch_idx_string, "%d", channel_idx + 1);
|
||||
|
||||
new_zone->name = "Hue+ Channel ";
|
||||
new_zone->name.append(ch_idx_string);
|
||||
|
||||
std::vector<int> *new_zone_map = new std::vector<int>();
|
||||
|
||||
for (int led_ch_idx = 0; led_ch_idx < hueplus->channel_leds[channel_idx]; led_ch_idx++)
|
||||
{
|
||||
colors.push_back(0x00000000);
|
||||
|
||||
char led_idx_string[3];
|
||||
sprintf(led_idx_string, "%d", led_ch_idx + 1);
|
||||
|
||||
led new_led;
|
||||
new_led.name = "Hue+ Channel ";
|
||||
new_led.name.append(ch_idx_string);
|
||||
new_led.name.append(", LED ");
|
||||
new_led.name.append(led_idx_string);
|
||||
|
||||
leds.push_back(new_led);
|
||||
leds_channel.push_back(channel_idx + 1);
|
||||
|
||||
new_zone_map->push_back(led_idx);
|
||||
led_idx++;
|
||||
}
|
||||
|
||||
new_zone->map.push_back(*new_zone_map);
|
||||
zones.push_back(*new_zone);
|
||||
zones_channel.push_back(channel_idx + 1);
|
||||
}
|
||||
}
|
||||
led_zone.map.push_back(led_zone_map);
|
||||
zones.push_back(led_zone);
|
||||
}
|
||||
|
||||
int RGBController_HuePlus::GetMode()
|
||||
|
|
@ -62,27 +88,52 @@ void RGBController_HuePlus::SetAllLEDs(RGBColor color)
|
|||
colors[i] = color;
|
||||
}
|
||||
|
||||
strip->SetLEDs(colors);
|
||||
hueplus->SetChannelLEDs(0, colors);
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
int channel = zones_channel[zone];
|
||||
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
colors[i] = color;
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
colors[zones[zone].map[x][y]] = color;
|
||||
}
|
||||
}
|
||||
|
||||
strip->SetLEDs(colors);
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(int color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
|
||||
hueplus->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetLED(int led, RGBColor color)
|
||||
{
|
||||
int channel = leds_channel[led];
|
||||
colors[led] = color;
|
||||
|
||||
strip->SetLEDs(colors);
|
||||
std::vector<RGBColor> channel_colors;
|
||||
|
||||
for(int color = 0; color < colors.size(); color++)
|
||||
{
|
||||
if(leds_channel[color] == channel)
|
||||
{
|
||||
channel_colors.push_back(colors[color]);
|
||||
}
|
||||
}
|
||||
hueplus->SetChannelLEDs(channel, channel_colors);
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::UpdateLEDs()
|
||||
{
|
||||
strip->SetLEDs(colors);
|
||||
hueplus->SetChannelLEDs(0, colors);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,5 +24,7 @@ public:
|
|||
void UpdateLEDs();
|
||||
|
||||
private:
|
||||
HuePlusController* strip;
|
||||
HuePlusController* hueplus;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
std::vector<unsigned int> zones_channel;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue