Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LEDUtil Class Reference
A simple class to handle LED. More...
#include <LEDUtil.h>
Public Types | |
| enum | Polarity { HIGH_ON_LOW_OFF, LOW_ON_HIGH_OFF } |
Polarity of LED's configuration. More... | |
Public Member Functions | |
| LEDUtil (PinName targetPinName, Polarity targetPinPolarity=HIGH_ON_LOW_OFF) | |
| Constructor. | |
| void | turnOn () |
| Turns on the LED. | |
| void | turnOff () |
| Turns off the LED. | |
| bool | isOn () |
| Returns if the LED is on. | |
| bool | isOff () |
| Returns if the LED is off. | |
| Polarity | getPolarity () |
| Get polarity setting. | |
Detailed Description
A simple class to handle LED.
Example (tested on BLENano):
#include "mbed.h" #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 void main() { LEDUtil led1(P0_19, LEDUtil::HIGH_ON_LOW_OFF); while(true) { led1.turnOn(); wait(0.5); led1.turnOff(); wait(0.5); } }
Definition at line 27 of file LEDUtil.h.
Member Enumeration Documentation
| enum Polarity |
Constructor & Destructor Documentation
| LEDUtil | ( | PinName | targetPinName, |
| LEDUtil::Polarity | targetPinPolarity = HIGH_ON_LOW_OFF |
||
| ) |
Constructor.
- Parameters:
-
targetPinName pin name of the target pin which is coneccted with the target LED. targetPinPolarity pin polarity of the target. The default value is POLARITY_HIGH_ON_LOW_OFF
Definition at line 7 of file LEDUtil.cpp.
Member Function Documentation
| Polarity getPolarity | ( | ) |
Get polarity setting.
- Returns:
- polarity setting of this LED configuration.
| bool isOff | ( | ) |
Returns if the LED is off.
- Returns:
- Returns true if the LED is off. Otherwise returns false.
Definition at line 46 of file LEDUtil.cpp.
| bool isOn | ( | ) |
Returns if the LED is on.
- Returns:
- Returns true if the LED is on. Otherwise returns false.
Definition at line 37 of file LEDUtil.cpp.
| void turnOff | ( | ) |
Turns off the LED.
Definition at line 32 of file LEDUtil.cpp.
| void turnOn | ( | ) |
Turns on the LED.
Definition at line 27 of file LEDUtil.cpp.
Generated on Sat Jul 16 2022 11:12:23 by
1.7.2