Library for led

RGB LED library

users/gimohd/code/LED/

[Not found]

Committer:
gimohd
Date:
Thu Dec 10 15:11:14 2015 +0000
Revision:
1:3d9e5b4abecf
Parent:
0:5368b27ca9d0
Child:
2:86c0b50796cd
extra

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gimohd 1:3d9e5b4abecf 1 /** COLOR CLASS
gimohd 1:3d9e5b4abecf 2 * Used for printing "Hello World" on USB serial.
gimohd 1:3d9e5b4abecf 3 *
gimohd 1:3d9e5b4abecf 4 * Example:
gimohd 1:3d9e5b4abecf 5 * @code
gimohd 1:3d9e5b4abecf 6 * #include "mbed.h"
gimohd 1:3d9e5b4abecf 7 * #include "HelloWorld.h"
gimohd 1:3d9e5b4abecf 8 *
gimohd 1:3d9e5b4abecf 9 * HelloWorld hw();
gimohd 1:3d9e5b4abecf 10 *
gimohd 1:3d9e5b4abecf 11 * int main() {
gimohd 1:3d9e5b4abecf 12 * hw.printIt(2);
gimohd 1:3d9e5b4abecf 13 * }
gimohd 1:3d9e5b4abecf 14 * @endcode
gimohd 1:3d9e5b4abecf 15 */
gimohd 0:5368b27ca9d0 16 #ifndef COLOR_H
gimohd 0:5368b27ca9d0 17 #define COLOR_H
gimohd 0:5368b27ca9d0 18
gimohd 0:5368b27ca9d0 19 class Color{
gimohd 0:5368b27ca9d0 20
gimohd 0:5368b27ca9d0 21
gimohd 0:5368b27ca9d0 22
gimohd 0:5368b27ca9d0 23 public:
gimohd 0:5368b27ca9d0 24 /** Create color instance
gimohd 0:5368b27ca9d0 25 *
gimohd 0:5368b27ca9d0 26 * @param red Value of red 0-255
gimohd 0:5368b27ca9d0 27 * @param green Value of green 0-255
gimohd 0:5368b27ca9d0 28 * @param blue Value of blue 0-255
gimohd 0:5368b27ca9d0 29 */
gimohd 0:5368b27ca9d0 30 Color(int red, int green, int blue);
gimohd 0:5368b27ca9d0 31 /** Create color instance
gimohd 0:5368b27ca9d0 32 *
gimohd 0:5368b27ca9d0 33 * @param color Hex or int value of a color
gimohd 0:5368b27ca9d0 34 */
gimohd 0:5368b27ca9d0 35 Color(int color);
gimohd 0:5368b27ca9d0 36 /** Create color instance
gimohd 0:5368b27ca9d0 37 *
gimohd 0:5368b27ca9d0 38 * @param red Value of red 0-1
gimohd 0:5368b27ca9d0 39 * @param green Value of green 0-1
gimohd 0:5368b27ca9d0 40 * @param blue Value of blue 0-1
gimohd 0:5368b27ca9d0 41 */
gimohd 0:5368b27ca9d0 42 Color(float red, float green, float blue);
gimohd 0:5368b27ca9d0 43 /** Returns the hex value of the color
gimohd 0:5368b27ca9d0 44 *
gimohd 0:5368b27ca9d0 45 * @param delay Print delay in milliseconds
gimohd 0:5368b27ca9d0 46 * @returns
gimohd 0:5368b27ca9d0 47 * Hex value of the color
gimohd 0:5368b27ca9d0 48 */
gimohd 0:5368b27ca9d0 49 int getHex();
gimohd 0:5368b27ca9d0 50 /** Returns the red value of the color
gimohd 0:5368b27ca9d0 51 *
gimohd 0:5368b27ca9d0 52 * @param delay Print delay in milliseconds
gimohd 0:5368b27ca9d0 53 * @returns
gimohd 0:5368b27ca9d0 54 * red value of the color
gimohd 0:5368b27ca9d0 55 */
gimohd 0:5368b27ca9d0 56 int getRed();
gimohd 0:5368b27ca9d0 57 /** Returns the green value of the color
gimohd 0:5368b27ca9d0 58 *
gimohd 0:5368b27ca9d0 59 * @param delay Print delay in milliseconds
gimohd 0:5368b27ca9d0 60 * @returns
gimohd 0:5368b27ca9d0 61 * the red value of the color
gimohd 0:5368b27ca9d0 62 */
gimohd 0:5368b27ca9d0 63 int getGreen();
gimohd 0:5368b27ca9d0 64 /** Returns the blue value of the color
gimohd 0:5368b27ca9d0 65 *
gimohd 0:5368b27ca9d0 66 * @param delay Print delay in milliseconds
gimohd 0:5368b27ca9d0 67 * @returns
gimohd 0:5368b27ca9d0 68 * the blue value of the color
gimohd 0:5368b27ca9d0 69 */
gimohd 0:5368b27ca9d0 70 int getBlue();
gimohd 0:5368b27ca9d0 71 enum colors{RED = 0xFF0000,
gimohd 0:5368b27ca9d0 72 GREEN = 0x00FF00,
gimohd 0:5368b27ca9d0 73 BLUE= 0x0000FF,
gimohd 0:5368b27ca9d0 74 CYAN = 0x00FFFF,
gimohd 0:5368b27ca9d0 75 MAGENTA = 0xFF00FF,
gimohd 0:5368b27ca9d0 76 YELLOW = 0xFFFF00,
gimohd 0:5368b27ca9d0 77 WHITE = 0xFFFFFF};
gimohd 0:5368b27ca9d0 78
gimohd 0:5368b27ca9d0 79 private:
gimohd 0:5368b27ca9d0 80 static const int MAX_COLOR_VALUE = 255;
gimohd 0:5368b27ca9d0 81 int red;
gimohd 0:5368b27ca9d0 82 int green;
gimohd 0:5368b27ca9d0 83 int blue;
gimohd 0:5368b27ca9d0 84 int floatToColorValue(float value);
gimohd 0:5368b27ca9d0 85
gimohd 0:5368b27ca9d0 86 };
gimohd 0:5368b27ca9d0 87
gimohd 0:5368b27ca9d0 88 #endif