mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Leddevice refactoring the next next part (#263)
* switch rs232 provider to completly async transfer * start of implementing a seperate init function for leddevices * rename setconfig to init * more fixes * implement missing code * fix code style * remove debug code * remove debug stuff * set loglevel to original state
This commit is contained in:
@@ -1,25 +1,48 @@
|
||||
#include <utils/ColorRgb.h>
|
||||
#include <utils/ColorRgbw.h>
|
||||
#include <utils/RgbToRgbw.h>
|
||||
#include <utils/Logger.h>
|
||||
|
||||
void Rgb_to_Rgbw(ColorRgb input, ColorRgbw * output, std::string _whiteAlgorithm) {
|
||||
if (_whiteAlgorithm == "subtract_minimum") {
|
||||
output->white = std::min(input.red, input.green);
|
||||
output->white = std::min(output->white, input.blue);
|
||||
output->red = input.red - output->white;
|
||||
output->green = input.green - output->white;
|
||||
output->blue = input.blue - output->white;
|
||||
}
|
||||
else if (_whiteAlgorithm == "sub_min_warm_adjust") {
|
||||
}
|
||||
else if ( (_whiteAlgorithm == "") || (_whiteAlgorithm == "white_off") ) {
|
||||
output->red = input.red;
|
||||
output->green = input.green;
|
||||
output->blue = input.blue;
|
||||
output->white = 0;
|
||||
}
|
||||
else {
|
||||
Error(Logger::getInstance("RGBtoRGBW"), "unknown whiteAlgorithm %s", _whiteAlgorithm.c_str());
|
||||
namespace RGBW {
|
||||
|
||||
WhiteAlgorithm stringToWhiteAlgorithm(std::string str)
|
||||
{
|
||||
if (str == "subtract_minimum") return SUBTRACT_MINIMUM;
|
||||
if (str == "sub_min_warm_adjust") return SUB_MIN_WARM_ADJUST;
|
||||
if (str.empty() || str == "white_off") return WHITE_OFF;
|
||||
return INVALID;
|
||||
}
|
||||
|
||||
void Rgb_to_Rgbw(ColorRgb input, ColorRgbw * output, const WhiteAlgorithm algorithm)
|
||||
{
|
||||
switch (algorithm)
|
||||
{
|
||||
case SUBTRACT_MINIMUM:
|
||||
{
|
||||
output->white = std::min(std::min(input.red, input.green), input.blue);
|
||||
output->red = input.red - output->white;
|
||||
output->green = input.green - output->white;
|
||||
output->blue = input.blue - output->white;
|
||||
break;
|
||||
}
|
||||
|
||||
case SUB_MIN_WARM_ADJUST:
|
||||
{
|
||||
Error(Logger::getInstance("RGBtoRGBW"), "white algorithm 'sub_min_warm_adjust' is not implemented yet." );
|
||||
break;
|
||||
}
|
||||
|
||||
case WHITE_OFF:
|
||||
{
|
||||
output->red = input.red;
|
||||
output->green = input.green;
|
||||
output->blue = input.blue;
|
||||
output->white = 0;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user