sqefqsdf
Dependencies: C12832 EthernetInterface LM75B mbed-rtos mbed
Fork of app-board-LM75B by
RGB.h@6:77a4c45f6416, 2017-03-23 (annotated)
- Committer:
- gimohd
- Date:
- Thu Mar 23 12:51:27 2017 +0000
- Revision:
- 6:77a4c45f6416
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gimohd | 6:77a4c45f6416 | 1 | #ifndef RGB_H |
gimohd | 6:77a4c45f6416 | 2 | #define RGB_H |
gimohd | 6:77a4c45f6416 | 3 | #include <mbed.h> |
gimohd | 6:77a4c45f6416 | 4 | #include <Color.h> |
gimohd | 6:77a4c45f6416 | 5 | |
gimohd | 6:77a4c45f6416 | 6 | /** RGB class |
gimohd | 6:77a4c45f6416 | 7 | * Uses PWM modulation on each pin to control every color on a RGB led. |
gimohd | 6:77a4c45f6416 | 8 | */ |
gimohd | 6:77a4c45f6416 | 9 | |
gimohd | 6:77a4c45f6416 | 10 | class RGB |
gimohd | 6:77a4c45f6416 | 11 | { |
gimohd | 6:77a4c45f6416 | 12 | |
gimohd | 6:77a4c45f6416 | 13 | public: |
gimohd | 6:77a4c45f6416 | 14 | |
gimohd | 6:77a4c45f6416 | 15 | /** Creates an instance of RGB |
gimohd | 6:77a4c45f6416 | 16 | * @param r_pin the PinName of r_pin |
gimohd | 6:77a4c45f6416 | 17 | * @param g_pin the PinName of g_pin |
gimohd | 6:77a4c45f6416 | 18 | * @param b_pin the PinName of b_pin |
gimohd | 6:77a4c45f6416 | 19 | */ |
gimohd | 6:77a4c45f6416 | 20 | RGB(PinName r_pin, PinName g_pin, PinName b_pin); |
gimohd | 6:77a4c45f6416 | 21 | |
gimohd | 6:77a4c45f6416 | 22 | /** Destructor from the RGB |
gimohd | 6:77a4c45f6416 | 23 | */ |
gimohd | 6:77a4c45f6416 | 24 | ~RGB(); |
gimohd | 6:77a4c45f6416 | 25 | /** Sets the color by giving a color from the Color class |
gimohd | 6:77a4c45f6416 | 26 | * @param color sets the color to this instance of the class Color |
gimohd | 6:77a4c45f6416 | 27 | * @ref Color |
gimohd | 6:77a4c45f6416 | 28 | */ |
gimohd | 6:77a4c45f6416 | 29 | void setColor(Color color); |
gimohd | 6:77a4c45f6416 | 30 | |
gimohd | 6:77a4c45f6416 | 31 | /** Sets the color by setting a value (0-255) for each pin |
gimohd | 6:77a4c45f6416 | 32 | * |
gimohd | 6:77a4c45f6416 | 33 | * @param red Set the red value of the color 0-255 |
gimohd | 6:77a4c45f6416 | 34 | * @param green Set the green value of the color 0-255 |
gimohd | 6:77a4c45f6416 | 35 | * @param blue Set the blue value of the color 0-255 |
gimohd | 6:77a4c45f6416 | 36 | */ |
gimohd | 6:77a4c45f6416 | 37 | void setColor(int red, int green, int blue); |
gimohd | 6:77a4c45f6416 | 38 | |
gimohd | 6:77a4c45f6416 | 39 | /** Sets the color by giving a hexadecimal value of the color |
gimohd | 6:77a4c45f6416 | 40 | * @param color the hex value of the color u want to set |
gimohd | 6:77a4c45f6416 | 41 | */ |
gimohd | 6:77a4c45f6416 | 42 | void setColor(int color); |
gimohd | 6:77a4c45f6416 | 43 | |
gimohd | 6:77a4c45f6416 | 44 | /** Sets the color by giving a hexadecimal value of the color |
gimohd | 6:77a4c45f6416 | 45 | * @param color the hex value of the color u want to set |
gimohd | 6:77a4c45f6416 | 46 | */ |
gimohd | 6:77a4c45f6416 | 47 | void setRgbColor(int color); |
gimohd | 6:77a4c45f6416 | 48 | |
gimohd | 6:77a4c45f6416 | 49 | /** Gets the Color of the led |
gimohd | 6:77a4c45f6416 | 50 | * |
gimohd | 6:77a4c45f6416 | 51 | * @return the color |
gimohd | 6:77a4c45f6416 | 52 | * @ref Color |
gimohd | 6:77a4c45f6416 | 53 | */ |
gimohd | 6:77a4c45f6416 | 54 | Color* getColor(); |
gimohd | 6:77a4c45f6416 | 55 | |
gimohd | 6:77a4c45f6416 | 56 | /** Turns the led off |
gimohd | 6:77a4c45f6416 | 57 | * |
gimohd | 6:77a4c45f6416 | 58 | */ |
gimohd | 6:77a4c45f6416 | 59 | void off(); |
gimohd | 6:77a4c45f6416 | 60 | |
gimohd | 6:77a4c45f6416 | 61 | |
gimohd | 6:77a4c45f6416 | 62 | private: |
gimohd | 6:77a4c45f6416 | 63 | float toFloat(int value); |
gimohd | 6:77a4c45f6416 | 64 | PinName r_pin, g_pin, b_pin; |
gimohd | 6:77a4c45f6416 | 65 | PwmOut* r_out; |
gimohd | 6:77a4c45f6416 | 66 | PwmOut* g_out; |
gimohd | 6:77a4c45f6416 | 67 | PwmOut* b_out; |
gimohd | 6:77a4c45f6416 | 68 | Color* color; |
gimohd | 6:77a4c45f6416 | 69 | }; |
gimohd | 6:77a4c45f6416 | 70 | |
gimohd | 6:77a4c45f6416 | 71 | #endif |