Update Lighting Node detection to detect multiple of the same device. Add reads to Lighting Node driver to fix compatibility with Corsair Lighting Protocol Arduino project
This commit is contained in:
parent
5db888fba0
commit
39d451793b
3 changed files with 30 additions and 18 deletions
|
|
@ -65,8 +65,11 @@ void CorsairLightingNodeController::KeepaliveThread()
|
|||
{
|
||||
while(1)
|
||||
{
|
||||
SendCommit();
|
||||
std::this_thread::sleep_for(5s);
|
||||
if((clock() - last_commit_time) > 5000)
|
||||
{
|
||||
SendCommit();
|
||||
}
|
||||
std::this_thread::sleep_for(1s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -211,7 +214,7 @@ void CorsairLightingNodeController::SendFirmwareRequest()
|
|||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 64);
|
||||
actual = hid_read(dev, usb_buf, 64);
|
||||
actual = hid_read(dev, usb_buf, 16);
|
||||
|
||||
if(actual > 0)
|
||||
{
|
||||
|
|
@ -253,6 +256,7 @@ void CorsairLightingNodeController::SendDirect
|
|||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 16);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendCommit()
|
||||
|
|
@ -264,6 +268,11 @@ void CorsairLightingNodeController::SendCommit()
|
|||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Update last commit time |
|
||||
\*-----------------------------------------------------*/
|
||||
last_commit_time = clock();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
|
|
@ -274,6 +283,7 @@ void CorsairLightingNodeController::SendCommit()
|
|||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 16);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendBegin
|
||||
|
|
@ -298,6 +308,7 @@ void CorsairLightingNodeController::SendBegin
|
|||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 16);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendEffectConfig
|
||||
|
|
@ -374,6 +385,7 @@ void CorsairLightingNodeController::SendEffectConfig
|
|||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 16);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendTemperature()
|
||||
|
|
@ -403,6 +415,7 @@ void CorsairLightingNodeController::SendReset
|
|||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 16);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendPortState
|
||||
|
|
@ -429,6 +442,7 @@ void CorsairLightingNodeController::SendPortState
|
|||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 16);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendBrightness()
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ public:
|
|||
private:
|
||||
hid_device* dev;
|
||||
std::string firmware_version;
|
||||
clock_t last_commit_time;
|
||||
|
||||
void SendFirmwareRequest();
|
||||
|
||||
|
|
|
|||
|
|
@ -60,23 +60,20 @@ void DetectCorsairLightingNodeControllers(std::vector<RGBController*> &rgb_contr
|
|||
&&(info->product_id == device_list[device_idx].usb_pid))
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
break;
|
||||
|
||||
if( dev )
|
||||
{
|
||||
CorsairLightingNodeController* controller = new CorsairLightingNodeController(dev);
|
||||
|
||||
RGBController_CorsairLightingNode* rgb_controller = new RGBController_CorsairLightingNode(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
|
||||
if( dev )
|
||||
{
|
||||
CorsairLightingNodeController* controller = new CorsairLightingNodeController(dev);
|
||||
|
||||
RGBController_CorsairLightingNode* rgb_controller = new RGBController_CorsairLightingNode(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
} /* DetectCorsairLightingNodeControllers() */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue