fade red and blue separately instead of cross-fading
This commit is contained in:
parent
ee850d0b17
commit
5925eb0320
@ -499,10 +499,16 @@ DeviceManager::DeviceError DevicePluginElgato::executeAction(Device *device, con
|
|||||||
device->setStateValue(aveaColorStateTypeId, color);
|
device->setStateValue(aveaColorStateTypeId, color);
|
||||||
return DeviceManager::DeviceErrorNoError;
|
return DeviceManager::DeviceErrorNoError;
|
||||||
} else if (action.actionTypeId() == aveaColorTemperatureActionTypeId) {
|
} else if (action.actionTypeId() == aveaColorTemperatureActionTypeId) {
|
||||||
// (ct-153) : x = (500-153) : 255
|
|
||||||
int ctValue = action.param(aveaColorTemperatureActionParamTypeId).value().toInt();
|
int ctValue = action.param(aveaColorTemperatureActionParamTypeId).value().toInt();
|
||||||
int blue = (ctValue - 153) * 255 / (500-153);
|
// normalize from 0 to 347 instead of 153 to 500
|
||||||
int red = 255 - blue;
|
int ct = ctValue - 153;
|
||||||
|
// for blue: lower half fades blue from 255 to 0
|
||||||
|
// ct : (255-blue) = (347 / 2) : 255
|
||||||
|
int blue = qMax(0, 255 - (ct * 255 / (347 / 2)));
|
||||||
|
// for red: upper half fades red from 0 255
|
||||||
|
// ct - (347/2) : red = (347 / 2) : 255
|
||||||
|
int red = qMax(0, (ct - (347/2)) * 255 / ((500-153)/2));
|
||||||
|
|
||||||
QColor color;
|
QColor color;
|
||||||
color.setRed(red);
|
color.setRed(red);
|
||||||
color.setGreen(0);
|
color.setGreen(0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user