Osamu Koizumi / LEDUtil
Embed: (wiki syntax)

« Back to documentation index

LEDUtil Class Reference

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

Polarity of LED's configuration.

Enumerator:
HIGH_ON_LOW_OFF 

The target LED lights up when the pin level is high.

LOW_ON_HIGH_OFF 

The target LED lights up when the pin level is low.

Definition at line 33 of file LEDUtil.h.


Constructor & Destructor Documentation

LEDUtil ( PinName  targetPinName,
LEDUtil::Polarity  targetPinPolarity = HIGH_ON_LOW_OFF 
)

Constructor.

Parameters:
targetPinNamepin name of the target pin which is coneccted with the target LED.
targetPinPolaritypin 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.