2013-07-26 22:38:34 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// STL includes
|
2013-11-11 10:00:37 +01:00
|
|
|
#include <cstdint>
|
2013-07-26 22:38:34 +02:00
|
|
|
#include <iostream>
|
|
|
|
|
2013-11-11 10:00:37 +01:00
|
|
|
struct ColorRgb;
|
2013-07-26 22:38:34 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// Plain-Old-Data structure containing the red-green-blue color specification. Size of the
|
|
|
|
/// structure is exactly 3-bytes for easy writing to led-device
|
|
|
|
///
|
2013-11-11 10:00:37 +01:00
|
|
|
struct ColorRgb
|
2013-07-26 22:38:34 +02:00
|
|
|
{
|
2013-09-09 04:54:13 +02:00
|
|
|
/// The red color channel
|
2013-07-26 22:38:34 +02:00
|
|
|
uint8_t red;
|
2013-09-09 04:54:13 +02:00
|
|
|
/// The green color channel
|
2013-07-26 22:38:34 +02:00
|
|
|
uint8_t green;
|
2013-09-09 04:54:13 +02:00
|
|
|
/// The blue color channel
|
2013-07-26 22:38:34 +02:00
|
|
|
uint8_t blue;
|
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
/// 'Black' RgbColor (0, 0, 0)
|
2013-11-11 10:00:37 +01:00
|
|
|
static ColorRgb BLACK;
|
2013-09-09 04:54:13 +02:00
|
|
|
/// 'Red' RgbColor (255, 0, 0)
|
2013-11-11 10:00:37 +01:00
|
|
|
static ColorRgb RED;
|
2013-09-09 04:54:13 +02:00
|
|
|
/// 'Green' RgbColor (0, 255, 0)
|
2013-11-11 10:00:37 +01:00
|
|
|
static ColorRgb GREEN;
|
2013-09-09 04:54:13 +02:00
|
|
|
/// 'Blue' RgbColor (0, 0, 255)
|
2013-11-11 10:00:37 +01:00
|
|
|
static ColorRgb BLUE;
|
2013-09-09 04:54:13 +02:00
|
|
|
/// 'Yellow' RgbColor (255, 255, 0)
|
2013-11-11 10:00:37 +01:00
|
|
|
static ColorRgb YELLOW;
|
2013-09-09 04:54:13 +02:00
|
|
|
/// 'White' RgbColor (255, 255, 255)
|
2013-11-11 10:00:37 +01:00
|
|
|
static ColorRgb WHITE;
|
2013-07-26 22:38:34 +02:00
|
|
|
};
|
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
/// Assert to ensure that the size of the structure is 'only' 3 bytes
|
2013-11-11 10:00:37 +01:00
|
|
|
static_assert(sizeof(ColorRgb) == 3, "Incorrect size of ColorRgb");
|
2013-08-13 11:10:45 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2013-11-11 10:00:37 +01:00
|
|
|
/// Stream operator to write ColorRgb to an outputstream (format "'{'[red]','[green]','[blue]'}'")
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
|
|
|
/// @param os The output stream
|
|
|
|
/// @param color The color to write
|
|
|
|
/// @return The output stream (with the color written to it)
|
|
|
|
///
|
2013-11-11 10:00:37 +01:00
|
|
|
inline std::ostream& operator<<(std::ostream& os, const ColorRgb& color)
|
2013-07-26 22:38:34 +02:00
|
|
|
{
|
|
|
|
os << "{" << unsigned(color.red) << "," << unsigned(color.green) << "," << unsigned(color.blue) << "}";
|
|
|
|
return os;
|
|
|
|
}
|