Two simple classes for using the RGB led
Dependents: 4180-lab3-RTOS 4180-FinalProject
SimpleRGB.h@0:7a3ee33c0a53, 2016-10-10 (annotated)
- Committer:
- kswanson31
- Date:
- Mon Oct 10 00:32:31 2016 +0000
- Revision:
- 0:7a3ee33c0a53
- Child:
- 1:0008e30a2bda
Two simple classes for using RGB led
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kswanson31 | 0:7a3ee33c0a53 | 1 | #ifndef SIMPLERGB_H |
kswanson31 | 0:7a3ee33c0a53 | 2 | #define SIMPLERGB_H |
kswanson31 | 0:7a3ee33c0a53 | 3 | |
kswanson31 | 0:7a3ee33c0a53 | 4 | #include "mbed.h" |
kswanson31 | 0:7a3ee33c0a53 | 5 | |
kswanson31 | 0:7a3ee33c0a53 | 6 | class LightColor |
kswanson31 | 0:7a3ee33c0a53 | 7 | { |
kswanson31 | 0:7a3ee33c0a53 | 8 | public: |
kswanson31 | 0:7a3ee33c0a53 | 9 | LightColor(float r, float g, float b); |
kswanson31 | 0:7a3ee33c0a53 | 10 | float red; |
kswanson31 | 0:7a3ee33c0a53 | 11 | float green; |
kswanson31 | 0:7a3ee33c0a53 | 12 | float blue; |
kswanson31 | 0:7a3ee33c0a53 | 13 | }; |
kswanson31 | 0:7a3ee33c0a53 | 14 | |
kswanson31 | 0:7a3ee33c0a53 | 15 | class RGBLed |
kswanson31 | 0:7a3ee33c0a53 | 16 | { |
kswanson31 | 0:7a3ee33c0a53 | 17 | public: |
kswanson31 | 0:7a3ee33c0a53 | 18 | RGBLed(PinName rpin, PinName gpin, PinName bpin); |
kswanson31 | 0:7a3ee33c0a53 | 19 | void write(float red, float green, float blue); |
kswanson31 | 0:7a3ee33c0a53 | 20 | void write(LightColor color); |
kswanson31 | 0:7a3ee33c0a53 | 21 | |
kswanson31 | 0:7a3ee33c0a53 | 22 | private: |
kswanson31 | 0:7a3ee33c0a53 | 23 | PwmOut _rpin; |
kswanson31 | 0:7a3ee33c0a53 | 24 | PwmOut _gpin; |
kswanson31 | 0:7a3ee33c0a53 | 25 | PwmOut _bpin; |
kswanson31 | 0:7a3ee33c0a53 | 26 | }; |
kswanson31 | 0:7a3ee33c0a53 | 27 | |
kswanson31 | 0:7a3ee33c0a53 | 28 | #endif |
kswanson31 | 0:7a3ee33c0a53 | 29 | |
kswanson31 | 0:7a3ee33c0a53 | 30 | |
kswanson31 | 0:7a3ee33c0a53 | 31 |