diff --git a/Controllers/Hue2Controller/Hue2Controller.cpp b/Controllers/Hue2Controller/Hue2Controller.cpp index 18f90fd1..f22846db 100644 --- a/Controllers/Hue2Controller/Hue2Controller.cpp +++ b/Controllers/Hue2Controller/Hue2Controller.cpp @@ -19,8 +19,9 @@ Hue2Controller::Hue2Controller(libusb_device_handle* dev_handle) Hue2Controller::~Hue2Controller() { - current_mode = HUE_2_MODE_FIXED; - current_speed = HUE_2_SPEED_NORMAL; + current_mode = HUE_2_MODE_FIXED; + current_speed = HUE_2_SPEED_NORMAL; + current_direction = false; } unsigned int Hue2Controller::GetStripsOnChannel(unsigned int /*channel*/) @@ -84,10 +85,11 @@ unsigned int Hue2Controller::GetStripsOnChannel(unsigned int /*channel*/) return(ret_val); } -void Hue2Controller::SetMode(unsigned char mode, unsigned char speed) +void Hue2Controller::SetMode(unsigned char mode, unsigned char speed, bool direction) { - current_mode = mode; - current_speed = speed; + current_mode = mode; + current_speed = speed; + current_direction = direction; } void Hue2Controller::SetChannelLEDs(unsigned char channel, std::vector colors) @@ -127,6 +129,12 @@ void Hue2Controller::SetChannelLEDs(unsigned char channel, std::vector | Set speed in USB packet | \*-----------------------------------------------------*/ usb_buf[0x05] = current_speed; + + /*-----------------------------------------------------*\ + | Set direction in USB packet | + \*-----------------------------------------------------*/ + usb_buf[0x06] = current_direction ? 0x01 : 0x00; + /*-----------------------------------------------------*\ | Set color count in USB packet | \*-----------------------------------------------------*/ diff --git a/Controllers/Hue2Controller/Hue2Controller.h b/Controllers/Hue2Controller/Hue2Controller.h index a02a4c80..14f0af0c 100644 --- a/Controllers/Hue2Controller/Hue2Controller.h +++ b/Controllers/Hue2Controller/Hue2Controller.h @@ -59,7 +59,7 @@ public: char* GetLEDString(); unsigned int GetStripsOnChannel(unsigned int channel); void SetChannelLEDs(unsigned char channel, std::vector colors); - void SetMode(unsigned char mode, unsigned char speed); + void SetMode(unsigned char mode, unsigned char speed, bool direction); unsigned int channel_leds[HUE_2_NUM_CHANNELS]; @@ -68,4 +68,5 @@ private: unsigned char current_mode; unsigned char current_speed; + bool current_direction; }; diff --git a/Controllers/HuePlusController/HuePlusController.cpp b/Controllers/HuePlusController/HuePlusController.cpp index 8e923b59..fb617f4a 100644 --- a/Controllers/HuePlusController/HuePlusController.cpp +++ b/Controllers/HuePlusController/HuePlusController.cpp @@ -24,8 +24,9 @@ static void Sleep(unsigned int milliseconds) HuePlusController::HuePlusController() { - current_mode = HUE_PLUS_MODE_FIXED; - current_speed = HUE_PLUS_SPEED_NORMAL; + current_mode = HUE_PLUS_MODE_FIXED; + current_speed = HUE_PLUS_SPEED_NORMAL; + current_direction = false; } HuePlusController::~HuePlusController() diff --git a/RGBController/RGBController_Hue2.cpp b/RGBController/RGBController_Hue2.cpp index 20b57424..1011742c 100644 --- a/RGBController/RGBController_Hue2.cpp +++ b/RGBController/RGBController_Hue2.cpp @@ -35,37 +35,41 @@ RGBController_Hue2::RGBController_Hue2(Hue2Controller* hue2_ptr) mode SpectrumCycle; SpectrumCycle.name = "Spectrum Cycle"; SpectrumCycle.value = HUE_2_MODE_SPECTRUM; - SpectrumCycle.flags = MODE_FLAG_HAS_SPEED; + SpectrumCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR; SpectrumCycle.speed_min = HUE_2_SPEED_SLOWEST; SpectrumCycle.speed_max = HUE_2_SPEED_FASTEST; SpectrumCycle.speed = HUE_2_SPEED_NORMAL; + SpectrumCycle.direction = MODE_DIRECTION_RIGHT; modes.push_back(SpectrumCycle); mode Marquee; Marquee.name = "Marquee"; Marquee.value = HUE_2_MODE_MARQUEE; - Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR; + Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR; Marquee.speed_min = HUE_2_SPEED_SLOWEST; Marquee.speed_max = HUE_2_SPEED_FASTEST; Marquee.speed = HUE_2_SPEED_NORMAL; + Marquee.direction = MODE_DIRECTION_RIGHT; modes.push_back(Marquee); mode CoverMarquee; CoverMarquee.name = "Cover Marquee"; CoverMarquee.value = HUE_2_MODE_COVER_MARQUEE; - CoverMarquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR; + CoverMarquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR; CoverMarquee.speed_min = HUE_2_SPEED_SLOWEST; CoverMarquee.speed_max = HUE_2_SPEED_FASTEST; CoverMarquee.speed = HUE_2_SPEED_NORMAL; + CoverMarquee.direction = MODE_DIRECTION_RIGHT; modes.push_back(CoverMarquee); mode Alternating; Alternating.name = "Alternating"; Alternating.value = HUE_2_MODE_ALTERNATING; - Alternating.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR; + Alternating.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR; Alternating.speed_min = HUE_2_SPEED_SLOWEST; Alternating.speed_max = HUE_2_SPEED_FASTEST; Alternating.speed = HUE_2_SPEED_NORMAL; + Alternating.direction = MODE_DIRECTION_RIGHT; modes.push_back(Alternating); mode Pulsing; @@ -163,7 +167,14 @@ void RGBController_Hue2::SetMode(int mode) if(channel_colors.size() > 0) { - hue2->SetMode(modes[mode].value, modes[mode].speed); + bool direction = false; + + if(modes[mode].direction == MODE_DIRECTION_LEFT) + { + direction = true; + } + + hue2->SetMode(modes[mode].value, modes[mode].speed, direction); hue2->SetChannelLEDs(channel, channel_colors); } }