THW-Funk-Audio-Switch/Programm/Audio-Switch/io/LED.hpp

64 lines
1.2 KiB
C++
Raw Normal View History

2020-10-30 23:22:11 +01:00
/*
* LED.hpp
*
* Created: 30.10.2020 22:05:41
* Author: netz
*/
#ifndef LED_HPP_
#define LED_HPP_
#include "ports/pin.hpp"
#include "ports/portc.hpp"
template<typename led_pin_r, typename led_pin_g, typename led_pin_b>
class LedT {
//ENUMS
public:
enum Led_Color {
BLACK = 0,
RED = 1,
GREEN = 2,
YELLOW = 3,
BLUE = 4,
MAGENTA = 5,
CYAN = 6,
WHITE = 7
};
// Methods
private:
void Init() {
led_r.MakeLow();
led_g.MakeLow();
led_b.MakeLow();
}
protected:
public:
LedT() {
this->Init();
}
/**
* \brief
* Set a color in the RGB Led
* \param color
*
* \return void
*/
void SetColor(Led_Color color) {
led_r.Set(color & (1<<0) ? true : false);
led_g.Set(color & (1<<1) ? true : false);
led_b.Set(color & (1<<2) ? true : false);
}
// Variables
private:
led_pin_r led_r;
led_pin_g led_g;
led_pin_b led_b;
};
typedef LedT<blubblib::pin<blubblib::portc, PINC1>, blubblib::pin<blubblib::portc, PINC2>, blubblib::pin<blubblib::portc, PINC0> > Led;
#endif /* LED_HPP_ */