A simple library to handle LEDs a little bit easier.
Diff: LEDUtil.h
- Revision:
- 1:220396a0cb8a
- Parent:
- 0:3c77443bfb5b
--- a/LEDUtil.h Fri Jul 31 23:26:36 2015 +0000 +++ b/LEDUtil.h Fri Jul 31 23:36:45 2015 +0000 @@ -10,11 +10,11 @@ * #include "LEDUtil.h" * * // LED is connected to P0_19 on BLENano and it lights up when the pin state is high. - * #define LED_PIN_NAME P0_19 + * #define LED_PIN_NAME P0_19 * * void main() { * LEDUtil led1(P0_19, LEDUtil::HIGH_ON_LOW_OFF); - * + * * while(true) { * led1.turnOn(); * wait(0.5); @@ -24,18 +24,19 @@ * } * @endcode */ -class LEDUtil { +class LEDUtil +{ - public: - +public: + /** Polarity of LED's configuration. */ typedef enum { /** The target LED lights up when the pin level is high. */ HIGH_ON_LOW_OFF, /** The target LED lights up when the pin level is low. */ - LOW_ON_HIGH_OFF + LOW_ON_HIGH_OFF } Polarity; - + /** * Constructor. * @@ -48,24 +49,24 @@ * Turns on the LED. */ void turnOn(); - + /** * Turns off the LED. */ void turnOff(); - + /** * Returns if the LED is on. * @return Returns true if the LED is on. Otherwise returns false. */ bool isOn(); - + /** * Returns if the LED is off. * @return Returns true if the LED is off. Otherwise returns false. */ - bool isOff(); - + bool isOff(); + /** * Get polarity setting. * @return polarity setting of this LED configuration. @@ -73,14 +74,14 @@ Polarity getPolarity(); - private: - +private: + /* Holds the target LED's pin name. */ PinName pinName; - + /* Holds polarity of the target LED pin. */ Polarity polarity; - + /* State of the LED, i.e. on or off. */ typedef enum {LED_ON, LED_OFF} LedState; @@ -89,7 +90,7 @@ * @param state LED state to be set. */ void setLedState(LedState state); - + /* * Gets the LED state. * @return Returns LED state.