#include "rgb.h"

struct Led_s
{
  uint8_t LED_R;
  uint8_t LED_B;
  uint8_t LED_G;
};
struct Led_s Led;

void RGB_Init(void)
{
  Led.LED_R = rt_pin_get("PE.1");
  Led.LED_G = rt_pin_get("PE.3");
  Led.LED_B = rt_pin_get("PE.2");

  rt_pin_mode(Led.LED_R, PIN_MODE_OUTPUT);
  rt_pin_mode(Led.LED_G, PIN_MODE_OUTPUT);
  rt_pin_mode(Led.LED_B, PIN_MODE_OUTPUT);
}

void RGB_Red(rt_int8_t on)
{
 rt_pin_write(Led.LED_G, PIN_HIGH);
 rt_pin_write(Led.LED_B, PIN_HIGH);
 if (on) {
 rt_pin_write(Led.LED_R, PIN_LOW);
 }else {
 rt_pin_write(Led.LED_R, PIN_HIGH);
 }
}

void RGB_Blue(rt_int8_t on)
{
 rt_pin_write(Led.LED_G, PIN_HIGH);
 rt_pin_write(Led.LED_R, PIN_HIGH);
 if (on) {
 rt_pin_write(Led.LED_B, PIN_LOW);
 }else {
 rt_pin_write(Led.LED_B, PIN_HIGH);
 }
}

void RGB_Green(rt_int8_t on)
{
 rt_pin_write(Led.LED_R, PIN_HIGH);
 rt_pin_write(Led.LED_B, PIN_HIGH);
 if (on) {
 rt_pin_write(Led.LED_G, PIN_LOW);
 }else {
 rt_pin_write(Led.LED_G, PIN_HIGH);
 }
}

