Library for led
RGB LED library
users/gimohd/code/LED/
[Not found]
lib/RGB.h@4:dc9ce1a68604, 2015-12-10 (annotated)
- Committer:
- gimohd
- Date:
- Thu Dec 10 15:45:22 2015 +0000
- Revision:
- 4:dc9ce1a68604
- Parent:
- 0:5368b27ca9d0
documentation not ready
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gimohd | 0:5368b27ca9d0 | 1 | |
gimohd | 0:5368b27ca9d0 | 2 | #ifndef RGB_H |
gimohd | 0:5368b27ca9d0 | 3 | #define RGB_H |
gimohd | 0:5368b27ca9d0 | 4 | #include <mbed.h> |
gimohd | 0:5368b27ca9d0 | 5 | #include <Color.h> |
gimohd | 0:5368b27ca9d0 | 6 | |
gimohd | 0:5368b27ca9d0 | 7 | |
gimohd | 0:5368b27ca9d0 | 8 | class RGB{ |
gimohd | 0:5368b27ca9d0 | 9 | |
gimohd | 0:5368b27ca9d0 | 10 | public: |
gimohd | 0:5368b27ca9d0 | 11 | /** Creates an instance of RGB |
gimohd | 0:5368b27ca9d0 | 12 | * |
gimohd | 0:5368b27ca9d0 | 13 | * @param r_pin the PinName of r_pin |
gimohd | 0:5368b27ca9d0 | 14 | * @param g_pin the PinName of g_pin |
gimohd | 0:5368b27ca9d0 | 15 | * @param b_pin the PinName of b_pin |
gimohd | 0:5368b27ca9d0 | 16 | */ |
gimohd | 0:5368b27ca9d0 | 17 | RGB(PinName r_pin, PinName g_pin, PinName b_pin); |
gimohd | 0:5368b27ca9d0 | 18 | /** Sets the color |
gimohd | 0:5368b27ca9d0 | 19 | * |
gimohd | 0:5368b27ca9d0 | 20 | * @param color sets the color to this instance of the class Color |
gimohd | 0:5368b27ca9d0 | 21 | */ |
gimohd | 0:5368b27ca9d0 | 22 | void setColor(Color color); |
gimohd | 0:5368b27ca9d0 | 23 | /** Sets the color |
gimohd | 0:5368b27ca9d0 | 24 | * |
gimohd | 0:5368b27ca9d0 | 25 | * @param red Set the red value of the color 0-255 |
gimohd | 0:5368b27ca9d0 | 26 | * @param green Set the green value of the color 0-255 |
gimohd | 0:5368b27ca9d0 | 27 | * @param blue Set the blue value of the color 0-255 |
gimohd | 0:5368b27ca9d0 | 28 | */ |
gimohd | 0:5368b27ca9d0 | 29 | void setColor(int red, int green, int blue); |
gimohd | 0:5368b27ca9d0 | 30 | /** Sets the color |
gimohd | 0:5368b27ca9d0 | 31 | * |
gimohd | 0:5368b27ca9d0 | 32 | * @param color the hex value of the color u want to set |
gimohd | 0:5368b27ca9d0 | 33 | */ |
gimohd | 0:5368b27ca9d0 | 34 | void setColor(int color); |
gimohd | 0:5368b27ca9d0 | 35 | |
gimohd | 0:5368b27ca9d0 | 36 | /** Sets the color |
gimohd | 0:5368b27ca9d0 | 37 | * |
gimohd | 0:5368b27ca9d0 | 38 | * @return the color |
gimohd | 0:5368b27ca9d0 | 39 | */ |
gimohd | 0:5368b27ca9d0 | 40 | Color* getColor(); |
gimohd | 0:5368b27ca9d0 | 41 | /** Turns the led off |
gimohd | 0:5368b27ca9d0 | 42 | * |
gimohd | 0:5368b27ca9d0 | 43 | */ |
gimohd | 0:5368b27ca9d0 | 44 | void off(); |
gimohd | 0:5368b27ca9d0 | 45 | |
gimohd | 0:5368b27ca9d0 | 46 | |
gimohd | 0:5368b27ca9d0 | 47 | private: |
gimohd | 0:5368b27ca9d0 | 48 | float toFloat(int value); |
gimohd | 0:5368b27ca9d0 | 49 | PinName r_pin; |
gimohd | 0:5368b27ca9d0 | 50 | PinName g_pin; |
gimohd | 0:5368b27ca9d0 | 51 | PinName b_pin; |
gimohd | 0:5368b27ca9d0 | 52 | PwmOut* r_out; |
gimohd | 0:5368b27ca9d0 | 53 | PwmOut* g_out; |
gimohd | 0:5368b27ca9d0 | 54 | PwmOut* b_out; |
gimohd | 0:5368b27ca9d0 | 55 | }; |
gimohd | 0:5368b27ca9d0 | 56 | |
gimohd | 0:5368b27ca9d0 | 57 | #endif |