change in mbed rtos library
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed
Fork of rtos_basic by
RGB_LED.h@13:b0bfe7f4472a, 2018-02-28 (annotated)
- Committer:
- bjs9
- Date:
- Wed Feb 28 09:54:23 2018 +0000
- Revision:
- 13:b0bfe7f4472a
- Parent:
- 12:fb46c68fa360
Changes to Lab3_Part31;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bjs9 | 12:fb46c68fa360 | 1 | #include "mbed.h" |
bjs9 | 12:fb46c68fa360 | 2 | |
bjs9 | 12:fb46c68fa360 | 3 | class RGBLed |
bjs9 | 12:fb46c68fa360 | 4 | { |
bjs9 | 12:fb46c68fa360 | 5 | public: |
bjs9 | 12:fb46c68fa360 | 6 | RGBLed(PinName redpin, PinName greenpin, PinName bluepin); |
bjs9 | 12:fb46c68fa360 | 7 | void write(float red,float green, float blue); |
bjs9 | 12:fb46c68fa360 | 8 | private: |
bjs9 | 12:fb46c68fa360 | 9 | PwmOut _redpin; |
bjs9 | 12:fb46c68fa360 | 10 | PwmOut _greenpin; |
bjs9 | 12:fb46c68fa360 | 11 | PwmOut _bluepin; |
bjs9 | 12:fb46c68fa360 | 12 | }; |
bjs9 | 12:fb46c68fa360 | 13 | |
bjs9 | 12:fb46c68fa360 | 14 | RGBLed::RGBLed (PinName redpin, PinName greenpin, PinName bluepin) |
bjs9 | 12:fb46c68fa360 | 15 | : _redpin(redpin), _greenpin(greenpin), _bluepin(bluepin) |
bjs9 | 12:fb46c68fa360 | 16 | { |
bjs9 | 12:fb46c68fa360 | 17 | //50Hz PWM clock default a bit too low, go to 2000Hz (less flicker) |
bjs9 | 12:fb46c68fa360 | 18 | _redpin.period(0.0005); |
bjs9 | 12:fb46c68fa360 | 19 | } |
bjs9 | 12:fb46c68fa360 | 20 | |
bjs9 | 12:fb46c68fa360 | 21 | void RGBLed::write(float red,float green, float blue) |
bjs9 | 12:fb46c68fa360 | 22 | { |
bjs9 | 12:fb46c68fa360 | 23 | _redpin = red; |
bjs9 | 12:fb46c68fa360 | 24 | _greenpin = green; |
bjs9 | 12:fb46c68fa360 | 25 | _bluepin = blue; |
bjs9 | 12:fb46c68fa360 | 26 | } |
bjs9 | 12:fb46c68fa360 | 27 | //class could be moved to include file |
bjs9 | 12:fb46c68fa360 | 28 | |
bjs9 | 12:fb46c68fa360 | 29 | |
bjs9 | 12:fb46c68fa360 | 30 | //Sestup RGB led using PWM pins and class |