![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
thermostat
Dependencies: 4DGL-uLCD-SE PinDetect SDFileSystem mbed
Fork of mythermostat by
RGBLed.h@5:5376bccdf85a, 2016-02-01 (annotated)
- Committer:
- ssong86
- Date:
- Mon Feb 01 06:33:52 2016 +0000
- Revision:
- 5:5376bccdf85a
thermostat
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ssong86 | 5:5376bccdf85a | 1 | #include "mbed.h" |
ssong86 | 5:5376bccdf85a | 2 | //Class to control an RGB LED using three PWM pins |
ssong86 | 5:5376bccdf85a | 3 | class RGBLed |
ssong86 | 5:5376bccdf85a | 4 | { |
ssong86 | 5:5376bccdf85a | 5 | public: |
ssong86 | 5:5376bccdf85a | 6 | RGBLed(PinName redpin, PinName greenpin, PinName bluepin); |
ssong86 | 5:5376bccdf85a | 7 | void write(float red,float green, float blue); |
ssong86 | 5:5376bccdf85a | 8 | private: |
ssong86 | 5:5376bccdf85a | 9 | DigitalOut _redpin; |
ssong86 | 5:5376bccdf85a | 10 | DigitalOut _greenpin; |
ssong86 | 5:5376bccdf85a | 11 | DigitalOut _bluepin; |
ssong86 | 5:5376bccdf85a | 12 | }; |
ssong86 | 5:5376bccdf85a | 13 | |
ssong86 | 5:5376bccdf85a | 14 | RGBLed::RGBLed (PinName redpin, PinName greenpin, PinName bluepin) |
ssong86 | 5:5376bccdf85a | 15 | : _redpin(redpin), _greenpin(greenpin), _bluepin(bluepin) |
ssong86 | 5:5376bccdf85a | 16 | { |
ssong86 | 5:5376bccdf85a | 17 | //50Hz PWM clock default a bit too low, go to 2000Hz (less flicker) |
ssong86 | 5:5376bccdf85a | 18 | //_redpin.period(.0005); |
ssong86 | 5:5376bccdf85a | 19 | } |
ssong86 | 5:5376bccdf85a | 20 | |
ssong86 | 5:5376bccdf85a | 21 | void RGBLed::write(float red,float green, float blue) |
ssong86 | 5:5376bccdf85a | 22 | { |
ssong86 | 5:5376bccdf85a | 23 | _redpin = red; |
ssong86 | 5:5376bccdf85a | 24 | _greenpin = green; |
ssong86 | 5:5376bccdf85a | 25 | _bluepin = blue; |
ssong86 | 5:5376bccdf85a | 26 | } |