Add message queue to speed up FanBus updates
This commit is contained in:
parent
15829e4dfe
commit
03bf5eb50d
3 changed files with 41 additions and 4 deletions
|
|
@ -37,10 +37,12 @@ void FanBusController::SetLEDs(std::vector<RGBColor> colors)
|
|||
unsigned char grn = RGBGetGValue(colors[led_idx]);
|
||||
unsigned char blu = RGBGetBValue(colors[led_idx]);
|
||||
|
||||
bus->write(dev, 0x10 + (led_idx * 3), red);
|
||||
bus->write(dev, 0x11 + (led_idx * 3), grn);
|
||||
bus->write(dev, 0x12 + (led_idx * 3), blu);
|
||||
bus->write_queue(dev, 0x10 + (led_idx * 3), red);
|
||||
bus->write_queue(dev, 0x11 + (led_idx * 3), grn);
|
||||
bus->write_queue(dev, 0x12 + (led_idx * 3), blu);
|
||||
}
|
||||
|
||||
bus->write(dev, 0x0C, 0x01);
|
||||
bus->write_queue(dev, 0x0C, 0x01);
|
||||
|
||||
bus->process_queue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,6 +104,30 @@ int FanBusInterface::write
|
|||
return(serialport->serial_write((char *)fanbus_msg, 5));
|
||||
}
|
||||
|
||||
void FanBusInterface::write_queue
|
||||
(
|
||||
unsigned char dev_addr,
|
||||
unsigned char int_addr,
|
||||
unsigned char val
|
||||
)
|
||||
{
|
||||
unsigned char fanbus_msg[] = { 0x00, int_addr, dev_addr, val, 0xFF };
|
||||
|
||||
for(int i = 0; i < sizeof(fanbus_msg); i++)
|
||||
{
|
||||
fanbus_msg_queued.push_back(fanbus_msg[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int FanBusInterface::process_queue()
|
||||
{
|
||||
int return_val = serialport->serial_write((char *)&fanbus_msg_queued[0], fanbus_msg_queued.size());
|
||||
|
||||
fanbus_msg_queued.clear();
|
||||
|
||||
return(return_val);
|
||||
}
|
||||
|
||||
std::vector<unsigned char> FanBusInterface::DetectControllers()
|
||||
{
|
||||
std::vector<unsigned char> detected_controllers;
|
||||
|
|
|
|||
|
|
@ -32,8 +32,19 @@ public:
|
|||
unsigned char val
|
||||
);
|
||||
|
||||
void write_queue
|
||||
(
|
||||
unsigned char dev_addr,
|
||||
unsigned char int_addr,
|
||||
unsigned char val
|
||||
);
|
||||
|
||||
int process_queue();
|
||||
|
||||
private:
|
||||
serial_port * serialport;
|
||||
std::string port_name;
|
||||
bool half_duplex;
|
||||
|
||||
std::vector<unsigned char> fanbus_msg_queued;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue