sqefqsdf

Dependencies:   C12832 EthernetInterface LM75B mbed-rtos mbed

Fork of app-board-LM75B by Chris Styles

Color.cpp

Committer:
gimohd
Date:
2017-05-09
Revision:
7:0618a1e407d0
Parent:
6:77a4c45f6416

File content as of revision 7:0618a1e407d0:


#include "Color.h"

Color::Color(int red, int green, int blue)
{
    this->red = red;
    this->green = green;
    this->blue = blue;
}

Color::Color(float red, float green, float blue)
{
    this->red = floatToColorValue(red);
    this->green = floatToColorValue(green);
    this->blue = floatToColorValue(blue);
}

Color::Color(int color)
{
    this->red = (color >> 16) & 0x0000FF;
    this->green = (color >> 8 ) & 0x0000FF;
    this->blue = (color >> 0 ) & 0x0000FF;
}

int Color::floatToColorValue(float value)
{
    return (int) (value * MAX_COLOR_VALUE);
};

int Color::getHex()
{
    return (red << 16) + (green<<8) + (blue <<0);
}

int Color::getRed()
{
    return red;
}

int Color::getGreen()
{
    return green;
}

int Color::getBlue()
{
    return blue;
}