j
Dependencies: mbed yeswecancoap C12832 LM75B
lib/Color.cpp@1:92958e26bf2e, 2015-10-23 (annotated)
- Committer:
- arnedesmet
- Date:
- Fri Oct 23 14:58:08 2015 +0000
- Revision:
- 1:92958e26bf2e
- Parent:
- 0:92d2ef9f009d
mlkj;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
arnedesmet | 0:92d2ef9f009d | 1 | |
arnedesmet | 0:92d2ef9f009d | 2 | #include "Color.h" |
arnedesmet | 0:92d2ef9f009d | 3 | |
arnedesmet | 0:92d2ef9f009d | 4 | Color::Color(int red, int green, int blue){ |
arnedesmet | 0:92d2ef9f009d | 5 | this->red = red; |
arnedesmet | 0:92d2ef9f009d | 6 | this->green = green; |
arnedesmet | 0:92d2ef9f009d | 7 | this->blue = blue; |
arnedesmet | 0:92d2ef9f009d | 8 | } |
arnedesmet | 0:92d2ef9f009d | 9 | |
arnedesmet | 0:92d2ef9f009d | 10 | Color::Color(float red, float green, float blue){ |
arnedesmet | 0:92d2ef9f009d | 11 | this->red = floatToColorValue(red); |
arnedesmet | 0:92d2ef9f009d | 12 | this->green = floatToColorValue(green); |
arnedesmet | 0:92d2ef9f009d | 13 | this->blue = floatToColorValue(blue); |
arnedesmet | 0:92d2ef9f009d | 14 | } |
arnedesmet | 0:92d2ef9f009d | 15 | |
arnedesmet | 0:92d2ef9f009d | 16 | int Color::floatToColorValue(float value){ |
arnedesmet | 0:92d2ef9f009d | 17 | return (int) (value * MAX_COLOR_VALUE); |
arnedesmet | 0:92d2ef9f009d | 18 | } |
arnedesmet | 0:92d2ef9f009d | 19 | |
arnedesmet | 0:92d2ef9f009d | 20 | Color::Color(int Color){ //AABBCC |
arnedesmet | 0:92d2ef9f009d | 21 | red = (Color >> 16) & 0x0000FF; |
arnedesmet | 0:92d2ef9f009d | 22 | green = (Color >> 8) & 0x0000FF; |
arnedesmet | 0:92d2ef9f009d | 23 | blue = Color & 0x0000FF; |
arnedesmet | 0:92d2ef9f009d | 24 | } |
arnedesmet | 0:92d2ef9f009d | 25 | |
arnedesmet | 0:92d2ef9f009d | 26 | int Color::getHex(){ |
arnedesmet | 1:92958e26bf2e | 27 | return (red << 16) + (green << 8) + (blue << 0); //verander shift register |
arnedesmet | 0:92d2ef9f009d | 28 | } |
arnedesmet | 0:92d2ef9f009d | 29 | |
arnedesmet | 0:92d2ef9f009d | 30 | int Color::getRed(){ |
arnedesmet | 0:92d2ef9f009d | 31 | return red; |
arnedesmet | 0:92d2ef9f009d | 32 | } |
arnedesmet | 0:92d2ef9f009d | 33 | |
arnedesmet | 0:92d2ef9f009d | 34 | int Color::getGreen(){ |
arnedesmet | 0:92d2ef9f009d | 35 | return green; |
arnedesmet | 0:92d2ef9f009d | 36 | } |
arnedesmet | 0:92d2ef9f009d | 37 | |
arnedesmet | 0:92d2ef9f009d | 38 | int Color::getBlue(){ |
arnedesmet | 0:92d2ef9f009d | 39 | return blue; |
arnedesmet | 0:92d2ef9f009d | 40 | } |
arnedesmet | 0:92d2ef9f009d | 41 | |
arnedesmet | 0:92d2ef9f009d | 42 | |
arnedesmet | 0:92d2ef9f009d | 43 | |
arnedesmet | 0:92d2ef9f009d | 44 | |
arnedesmet | 0:92d2ef9f009d | 45 |