2016-04-02 00:04:11 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// STL includes
|
|
|
|
#include <cstdint>
|
2017-01-10 19:58:41 +01:00
|
|
|
#include <QString>
|
|
|
|
#include <utils/Logger.h>
|
2016-04-02 00:04:11 +02:00
|
|
|
|
|
|
|
/// Correction for a single color byte value
|
|
|
|
/// All configuration values are unsigned int and assume the color value to be between 0 and 255
|
|
|
|
class RgbChannelAdjustment
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// Default constructor
|
2017-01-10 19:58:41 +01:00
|
|
|
RgbChannelAdjustment(QString channelName="");
|
2020-06-28 23:12:22 +02:00
|
|
|
|
2016-04-02 00:04:11 +02:00
|
|
|
/// Constructor
|
2020-06-28 23:12:22 +02:00
|
|
|
/// @param adjustR
|
|
|
|
/// @param adjustG
|
|
|
|
/// @param adjustB
|
2017-01-10 19:58:41 +01:00
|
|
|
RgbChannelAdjustment(uint8_t adjustR, uint8_t adjustG, uint8_t adjustB, QString channelName="");
|
2016-04-02 00:04:11 +02:00
|
|
|
|
2017-04-03 05:19:05 +02:00
|
|
|
///
|
2017-03-31 19:37:27 +02:00
|
|
|
/// Transform the given array value
|
2017-04-03 05:19:05 +02:00
|
|
|
///
|
2017-03-31 19:37:27 +02:00
|
|
|
/// @param input The input color bytes
|
2017-04-03 05:19:05 +02:00
|
|
|
/// @param brightness The current brightness value
|
|
|
|
/// @param red The red color component
|
|
|
|
/// @param green The green color component
|
|
|
|
/// @param blue The blue color component
|
|
|
|
///
|
|
|
|
/// @note The values are updated in place.
|
|
|
|
///
|
|
|
|
void apply(uint8_t input, uint8_t brightness, uint8_t & red, uint8_t & green, uint8_t & blue);
|
2016-04-02 00:04:11 +02:00
|
|
|
|
2017-04-03 05:19:05 +02:00
|
|
|
///
|
2016-07-02 14:00:48 +02:00
|
|
|
/// setAdjustment RGB
|
2017-04-03 05:19:05 +02:00
|
|
|
///
|
2020-06-28 23:12:22 +02:00
|
|
|
/// @param adjustR
|
|
|
|
/// @param adjustG
|
|
|
|
/// @param adjustB
|
2017-04-03 05:19:05 +02:00
|
|
|
///
|
2016-07-02 14:00:48 +02:00
|
|
|
void setAdjustment(uint8_t adjustR, uint8_t adjustG, uint8_t adjustB);
|
2016-04-02 00:04:11 +02:00
|
|
|
|
2016-07-04 00:43:41 +02:00
|
|
|
/// @return The current adjustR value
|
|
|
|
uint8_t getAdjustmentR() const;
|
|
|
|
|
2016-04-02 00:04:11 +02:00
|
|
|
/// @return The current adjustG value
|
2016-07-02 14:00:48 +02:00
|
|
|
uint8_t getAdjustmentG() const;
|
2016-04-02 00:04:11 +02:00
|
|
|
|
|
|
|
/// @return The current adjustB value
|
2016-07-02 14:00:48 +02:00
|
|
|
uint8_t getAdjustmentB() const;
|
2016-04-02 00:04:11 +02:00
|
|
|
|
|
|
|
private:
|
2016-07-02 14:00:48 +02:00
|
|
|
/// color channels
|
2017-04-03 05:19:05 +02:00
|
|
|
enum ColorChannel { RED=0, GREEN=1, BLUE=2 };
|
|
|
|
|
|
|
|
/// reset init of color mapping
|
|
|
|
void resetInitialized();
|
2016-07-02 14:00:48 +02:00
|
|
|
|
|
|
|
/// The adjustment of RGB channel
|
|
|
|
uint8_t _adjust[3];
|
2020-06-28 23:12:22 +02:00
|
|
|
|
2016-04-02 00:04:11 +02:00
|
|
|
/// The mapping from input color to output color
|
2016-07-02 14:00:48 +02:00
|
|
|
uint8_t _mapping[3][256];
|
2017-01-10 19:58:41 +01:00
|
|
|
|
|
|
|
/// Name of this channel, usefull for debug messages
|
|
|
|
QString _channelName;
|
|
|
|
|
|
|
|
/// Logger instance
|
|
|
|
Logger * _log;
|
2017-04-03 05:19:05 +02:00
|
|
|
|
|
|
|
/// bitfield to determine white value is alreade initialized
|
|
|
|
bool _initialized[256];
|
|
|
|
|
|
|
|
/// current brightness value
|
|
|
|
uint8_t _brightness;
|
2016-04-02 00:04:11 +02:00
|
|
|
};
|