diff --git a/Controllers/HIDLampArrayController/HIDLampArrayController.cpp b/Controllers/HIDLampArrayController/HIDLampArrayController.cpp index b02201bf8..ee1adb07f 100644 --- a/Controllers/HIDLampArrayController/HIDLampArrayController.cpp +++ b/Controllers/HIDLampArrayController/HIDLampArrayController.cpp @@ -147,7 +147,7 @@ void HIDLampArrayController::SetLampAttributesRequestReport(unsigned short LampI hid_send_feature_report(devs->hid_dev_LampAttributesRequestReport, usb_buf, sizeof(usb_buf)); } -void HIDLampArrayController::SetLampMultiUpdateReport(unsigned char LampCount, unsigned char LampUpdateFlags, unsigned char * LampIds, LampArrayColor * UpdateColors) +void HIDLampArrayController::SetLampMultiUpdateReport(unsigned char LampCount, unsigned char LampUpdateFlags, unsigned short * LampIds, LampArrayColor * UpdateColors) { unsigned char usb_buf[sizeof(LampMultiUpdate) + 1]; diff --git a/Controllers/HIDLampArrayController/HIDLampArrayController.h b/Controllers/HIDLampArrayController/HIDLampArrayController.h index 9819760e2..d828cea18 100644 --- a/Controllers/HIDLampArrayController/HIDLampArrayController.h +++ b/Controllers/HIDLampArrayController/HIDLampArrayController.h @@ -83,11 +83,12 @@ PACK(struct LampAttributesRequest }); #define LAMP_MULTI_UPDATE_LAMP_COUNT 8 +#define LAMP_UPDATE_FLAG_UPDATE_COMPLETE 1 PACK(struct LampMultiUpdate { unsigned char LampCount; unsigned char LampUpdateFlags; - unsigned char LampIds[LAMP_MULTI_UPDATE_LAMP_COUNT]; + unsigned short LampIds[LAMP_MULTI_UPDATE_LAMP_COUNT]; LampArrayColor UpdateColors[LAMP_MULTI_UPDATE_LAMP_COUNT]; }); @@ -125,14 +126,14 @@ public: std::string GetSerialString(); unsigned int GetLampCount(); - +void SetLampMultiUpdateReport(unsigned char LampCount, unsigned char LampUpdateFlags, unsigned short * LampIds, LampArrayColor * UpdateColors); private: void GetLampArrayAttributesReport(); void GetLampAttributesResponseReport(); void SetLampArrayControlReport(unsigned char AutonomousMode); void SetLampAttributesRequestReport(unsigned short LampId); - void SetLampMultiUpdateReport(unsigned char LampCount, unsigned char LampUpdateFlags, unsigned char * LampIds, LampArrayColor * UpdateColors); + lamparray_hid_devs * devs; std::string location; diff --git a/Controllers/HIDLampArrayController/RGBController_HIDLampArray.cpp b/Controllers/HIDLampArrayController/RGBController_HIDLampArray.cpp index ca61011d5..de75aeb57 100644 --- a/Controllers/HIDLampArrayController/RGBController_HIDLampArray.cpp +++ b/Controllers/HIDLampArrayController/RGBController_HIDLampArray.cpp @@ -65,7 +65,39 @@ void RGBController_HIDLampArray::ResizeZone(int zone, int new_size) void RGBController_HIDLampArray::DeviceUpdateLEDs() { + unsigned int leds_to_go = leds.size(); + while(leds_to_go > 0) + { + unsigned int leds_this_frame = LAMP_MULTI_UPDATE_LAMP_COUNT; + unsigned short LampIds[LAMP_MULTI_UPDATE_LAMP_COUNT]; + LampArrayColor UpdateColors[LAMP_MULTI_UPDATE_LAMP_COUNT]; + unsigned char LampUpdateFlags = 0; + + if(leds_to_go < leds_this_frame) + { + leds_to_go = leds_this_frame; + } + + for(unsigned int led_frame_idx = 0; led_frame_idx < leds_this_frame; led_frame_idx++) + { + unsigned short led_idx = (leds.size() - leds_to_go) + led_frame_idx; + LampIds[led_frame_idx] = led_idx; + UpdateColors[led_frame_idx].RedChannel = RGBGetRValue(colors[led_idx]); + UpdateColors[led_frame_idx].GreenChannel = RGBGetGValue(colors[led_idx]); + UpdateColors[led_frame_idx].BlueChannel = RGBGetBValue(colors[led_idx]); + UpdateColors[led_frame_idx].IntensityChannel = 255; + } + + leds_to_go -= leds_this_frame; + + if(leds_to_go <= 0) + { + LampUpdateFlags = LAMP_UPDATE_FLAG_UPDATE_COMPLETE; + } + + controller->SetLampMultiUpdateReport(leds_this_frame, LampUpdateFlags, LampIds, UpdateColors); + } } void RGBController_HIDLampArray::UpdateZoneLEDs(int zone)