Add support for multiple addressable channels in Aura addressable controller. Direct mode only for now

master
Adam Honse 6 years ago
parent 1e171fcfb0
commit ba2ce98a3e

@ -34,25 +34,30 @@ AuraAddressableController::~AuraAddressableController()
}
unsigned int AuraAddressableController::GetChannelCount()
{
return( 1 );
}
std::string AuraAddressableController::GetDeviceName()
{
return(device_name);
}
void AuraAddressableController::SetLEDsDirect(std::vector<RGBColor> colors)
void AuraAddressableController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
{
unsigned char led_data[60];
unsigned int leds_sent = 0;
SendDirectBegin();
SendDirectBegin(channel);
while(leds_sent < colors.size())
while(leds_sent < num_colors)
{
unsigned int leds_to_send = 20;
if((colors.size() - leds_sent) < leds_to_send)
if((num_colors - leds_sent) < leds_to_send)
{
leds_to_send = colors.size() - leds_sent;
leds_to_send = num_colors - leds_sent;
}
for(int led_idx = 0; led_idx < leds_to_send; led_idx++)
@ -64,7 +69,7 @@ void AuraAddressableController::SetLEDsDirect(std::vector<RGBColor> colors)
SendDirect
(
0,
channel,
leds_sent,
leds_to_send,
led_data
@ -73,7 +78,7 @@ void AuraAddressableController::SetLEDsDirect(std::vector<RGBColor> colors)
leds_sent += leds_to_send;
}
SendDirectApply();
SendDirectApply(channel);
}
void AuraAddressableController::SetMode
@ -235,7 +240,10 @@ void AuraAddressableController::SendDirect
hid_write(dev, usb_buf, 65);
}
void AuraAddressableController::SendDirectBegin()
void AuraAddressableController::SendDirectBegin
(
unsigned char channel
)
{
unsigned char usb_buf[65];
@ -249,6 +257,7 @@ void AuraAddressableController::SendDirectBegin()
\*-----------------------------------------------------*/
usb_buf[0x00] = 0xEC;
usb_buf[0x01] = AURA_CONTROL_MODE_EFFECT;
usb_buf[0x02] = channel;
usb_buf[0x04] = 0xFF;
/*-----------------------------------------------------*\
@ -257,7 +266,10 @@ void AuraAddressableController::SendDirectBegin()
hid_write(dev, usb_buf, 65);
}
void AuraAddressableController::SendDirectApply()
void AuraAddressableController::SendDirectApply
(
unsigned char channel
)
{
unsigned char usb_buf[65];
@ -271,7 +283,7 @@ void AuraAddressableController::SendDirectApply()
\*-----------------------------------------------------*/
usb_buf[0x00] = 0xEC;
usb_buf[0x01] = AURA_CONTROL_MODE_DIRECT;
usb_buf[0x02] = 0x80;
usb_buf[0x02] = 0x80 | channel;
/*-----------------------------------------------------*\
| Send packet |

@ -47,11 +47,16 @@ public:
AuraAddressableController(hid_device* dev_handle);
~AuraAddressableController();
std::string GetDeviceName();
unsigned int GetChannelCount();
int GetChannelCount();
std::string GetDeviceName();
void SetLEDsDirect(std::vector<RGBColor> colors);
void SetChannelLEDs
(
unsigned char channel,
RGBColor * colors,
unsigned int num_colors
);
void SetMode
(
@ -87,7 +92,13 @@ private:
unsigned char* led_data
);
void SendDirectBegin();
void SendDirectBegin
(
unsigned char channel
);
void SendDirectApply();
void SendDirectApply
(
unsigned char channel
);
};

@ -121,12 +121,12 @@ void RGBController_AuraAddressable::SetupZones()
\*-------------------------------------------------*/
leds.clear();
colors.clear();
zones.resize(AURA_ADDRESSABLE_NUM_CHANNELS);
zones.resize(aura->GetChannelCount());
/*-------------------------------------------------*\
| Set zones and leds |
\*-------------------------------------------------*/
for (unsigned int channel_idx = 0; channel_idx < AURA_ADDRESSABLE_NUM_CHANNELS; channel_idx++)
for (unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++)
{
char ch_idx_string[2];
sprintf(ch_idx_string, "%d", channel_idx + 1);
@ -153,9 +153,9 @@ void RGBController_AuraAddressable::SetupZones()
new_led.name.append(ch_idx_string);
new_led.name.append(", LED ");
new_led.name.append(led_idx_string);
new_led.value = channel_idx;
leds.push_back(new_led);
leds_channel.push_back(channel_idx);
}
}
@ -174,20 +174,22 @@ void RGBController_AuraAddressable::ResizeZone(int zone, int new_size)
void RGBController_AuraAddressable::UpdateLEDs()
{
if(modes[active_mode].value == 0xFFFF)
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
aura->SetLEDsDirect(colors);
aura->SetChannelLEDs(zone_idx, zones[zone_idx].colors, zones[zone_idx].leds_count);
}
}
void RGBController_AuraAddressable::UpdateZoneLEDs(int zone)
{
UpdateLEDs();
aura->SetChannelLEDs(zone, zones[zone].colors, zones[zone].leds_count);
}
void RGBController_AuraAddressable::UpdateSingleLED(int led)
{
UpdateLEDs();
unsigned int channel = leds[led].value;
aura->SetChannelLEDs(channel, zones[channel].colors, zones[channel].leds_count);
}
void RGBController_AuraAddressable::SetCustomMode()

@ -12,7 +12,6 @@
#include "AuraAddressableController.h"
#define AURA_ADDRESSABLE_MAX_LEDS 120
#define AURA_ADDRESSABLE_NUM_CHANNELS 1
class RGBController_AuraAddressable : public RGBController
{
@ -35,4 +34,4 @@ private:
AuraAddressableController* aura;
std::vector<unsigned int> leds_channel;
std::vector<unsigned int> zones_channel;
};
};

Loading…
Cancel
Save