/* * peripherals_rgb.hpp * * Created on: Mar 29, 2021 * Author: erki */ #ifndef PERIPHERALS_INC_PERIPHERALS_RGB_HPP_ #define PERIPHERALS_INC_PERIPHERALS_RGB_HPP_ #include "peripherals_io.hpp" namespace Peripherals { enum class RgbColor : std::uint32_t { OFF, RED, GREEN, BLUE, CYAN, PINK, YELLOW, WHITE }; template struct Rgb { using IOType = T; IOType red; IOType green; IOType blue; RgbColor color = RgbColor::OFF; Rgb() = delete; Rgb(const IOType& r, const IOType& g, const IOType& b) : red(r) , green(g) , blue(b) { Set(RgbColor::OFF); } void Set(const RgbColor& new_color) { color = new_color; switch (color) { case RgbColor::OFF: red.Set(false); green.Set(false); blue.Set(false); break; case RgbColor::RED: red.Set(true); green.Set(false); blue.Set(false); break; case RgbColor::GREEN: red.Set(false); green.Set(true); blue.Set(false); break; case RgbColor::BLUE: red.Set(false); green.Set(false); blue.Set(true); break; case RgbColor::CYAN: red.Set(false); green.Set(true); blue.Set(true); break; case RgbColor::PINK: red.Set(true); green.Set(false); blue.Set(true); break; case RgbColor::YELLOW: red.Set(true); green.Set(true); blue.Set(false); break; case RgbColor::WHITE: red.Set(true); green.Set(true); blue.Set(true); break; } } }; } #endif /* PERIPHERALS_INC_PERIPHERALS_RGB_HPP_ */