hyperion.ng/libsrc/utils/RgbChannelAdjustment.cpp
redPanther 921f164b26 refactoring of RgbChannelAdjustment (#79)
* common ledbuffer for color transform

hyperion class uses a common buffer for all operations on ledColors got from muxer
all color transforms uses new ledBuffer instead of making copies of ledbuffer

other fixes:
fix compile bug in profiler
update doxygen config

* migrate logging for color transform classes

* prepare new logger in hyperion class

* implement hwledcount

* Update Hyperion.cpp

Fix off color

* remove ledscount equivalent from apa102
migrate logging in hyperion.cpp
remove unused and duuplicate colorcorrection - but same is available through tempertature

* remove colorcorrection completly
fix compile

* set colororder back to static

* in remote: using correction is the same as using temperature - correction is obsolete, command not delete atm for compat reasons

* refactoring of RgbChannelAdjustment
2016-07-02 14:00:48 +02:00

85 lines
1.8 KiB
C++

// STL includes
#include <cmath>
#include <cstdint>
#include <algorithm>
// Utils includes
#include <utils/RgbChannelAdjustment.h>
RgbChannelAdjustment::RgbChannelAdjustment()
{
setAdjustment(UINT8_MAX, UINT8_MAX, UINT8_MAX);
}
RgbChannelAdjustment::RgbChannelAdjustment(uint8_t adjustR, uint8_t adjustG, uint8_t adjustB)
{
setAdjustment(adjustR, adjustG, adjustB);
}
RgbChannelAdjustment::~RgbChannelAdjustment()
{
}
void RgbChannelAdjustment::setAdjustment(uint8_t adjustR, uint8_t adjustG, uint8_t adjustB)
{
_adjust[RED] = adjustR;
_adjust[GREEN] = adjustG;
_adjust[BLUE] = adjustB;
initializeMapping();
}
uint8_t RgbChannelAdjustment::getAdjustmentR() const
{
return _adjust[RED];
}
void RgbChannelAdjustment::setAdjustmentR(uint8_t adjustR)
{
setAdjustment(adjustR, _adjust[GREEN], _adjust[BLUE]);
}
uint8_t RgbChannelAdjustment::getAdjustmentG() const
{
return _adjust[GREEN];
}
void RgbChannelAdjustment::setAdjustmentG(uint8_t adjustG)
{
setAdjustment(_adjust[RED], adjustG, _adjust[BLUE]);
}
uint8_t RgbChannelAdjustment::getAdjustmentB() const
{
return _adjust[BLUE];
}
void RgbChannelAdjustment::setAdjustmentB(uint8_t adjustB)
{
setAdjustment(_adjust[RED], _adjust[GREEN], adjustB);
}
uint8_t RgbChannelAdjustment::adjustmentR(uint8_t inputR) const
{
return _mapping[RED][inputR];
}
uint8_t RgbChannelAdjustment::adjustmentG(uint8_t inputG) const
{
return _mapping[GREEN][inputG];
}
uint8_t RgbChannelAdjustment::adjustmentB(uint8_t inputB) const
{
return _mapping[BLUE][inputB];
}
void RgbChannelAdjustment::initializeMapping()
{
// initialize linear mapping
for (unsigned channel=0; channel<3; channel++)
for (unsigned idx=0; idx<=UINT8_MAX; idx++)
{
_mapping[channel][idx] = std::min( ((idx * _adjust[channel]) / UINT8_MAX), (unsigned)UINT8_MAX);
}
}