Hotboards MX / Hotboards_leds

Dependents:   handling_leds leds toggle writing ... more

Embed: (wiki syntax)

« Back to documentation index

Hotboards_leds Class Reference

Hotboards_leds Class Reference

Hotboards_leds class. More...

#include <Hotboards_leds.h>

Public Member Functions

 Hotboards_leds (PinName led0, bool on=1)
 Create Hotboards_leds instance for one led.
 Hotboards_leds (PinName led1, PinName led0, bool on=1)
 Create Hotboards_leds instance for two leds.
 Hotboards_leds (PinName led2, PinName led1, PinName led0, bool on=1)
 Create Hotboards_leds instance for three leds.
 Hotboards_leds (PinName led3, PinName led2, PinName led1, PinName led0, bool on=1)
 Create Hotboards_leds instance for four leds.
 Hotboards_leds (PinName led4, PinName led3, PinName led2, PinName led1, PinName led0, bool on=1)
 Create Hotboards_leds instance for five leds.
 Hotboards_leds (PinName led5, PinName led4, PinName led3, PinName led2, PinName led1, PinName led0, bool on=1)
 Create Hotboards_leds instance for six leds.
 Hotboards_leds (PinName led6, PinName led5, PinName led4, PinName led3, PinName led2, PinName led1, PinName led0, bool on=1)
 Create Hotboards_leds instance for seven leds.
 Hotboards_leds (PinName led7, PinName led6, PinName led5, PinName led4, PinName led3, PinName led2, PinName led1, PinName led0, bool on=1)
 Create Hotboards_leds instance for eight leds.
void turnOn (uint8_t led=0)
 Turn on a single led.
void turnOff (uint8_t led=0)
 Turn off a single led.
void toggle (uint8_t led=0)
 Toggle a single led.
void write (uint8_t val)
 Write to a single led or the entire bus.
uint8_t read (uint8_t led=0xff)
 Read a single led or the entire bus.

Detailed Description

Hotboards_leds class.

Used to control general purpose leds

Example:

 #include "mbed.h"
 #include "Hotboards_leds.h"

 Hotboards_leds led( PB_5 );
 
 int main( void ) 
 {
     for(;;){  
         led.toggle( );
         wait( 0.2 );
     }
 }

Definition at line 31 of file Hotboards_leds.h.


Constructor & Destructor Documentation

Hotboards_leds ( PinName  led0,
bool  on = 1 
)

Create Hotboards_leds instance for one led.

Parameters:
led0pin where the led 0 will be connected
onlogic level to turn on the led

Example:

   // instance one led on pin 5
   Hotboards_leds led( 5 );

Definition at line 13 of file Hotboards_leds.cpp.

Hotboards_leds ( PinName  led1,
PinName  led0,
bool  on = 1 
)

Create Hotboards_leds instance for two leds.

Parameters:
led1pin where the led 1 will be connected
led0pin where the led 0 will be connected
onlogic level to turn on the leds

Example:

   // one instance with 2 leds on pins 5 and 6
   Hotboards_leds led( 5, 6 );

Definition at line 21 of file Hotboards_leds.cpp.

Hotboards_leds ( PinName  led2,
PinName  led1,
PinName  led0,
bool  on = 1 
)

Create Hotboards_leds instance for three leds.

Parameters:
led2pin where the led 2 will be connected
led1pin where the led 1 will be connected
led0pin where the led 0 will be connected
onlogic level to turn on the leds

Example:

   // one instance with 3 leds on pins 5, 6 and 7
   Hotboards_leds led( 5, 6, 7 );

Definition at line 30 of file Hotboards_leds.cpp.

Hotboards_leds ( PinName  led3,
PinName  led2,
PinName  led1,
PinName  led0,
bool  on = 1 
)

Create Hotboards_leds instance for four leds.

Parameters:
led3pin where the led 3 will be connected
led2pin where the led 2 will be connected
led1pin where the led 1 will be connected
led0pin where the led 0 will be connected
onlogic level to turn on the leds

Example:

   // one instance with 4 leds on pins 5, 6, 7 and 8
   Hotboards_leds led( 5, 6, 7, 8 );

Definition at line 40 of file Hotboards_leds.cpp.

Hotboards_leds ( PinName  led4,
PinName  led3,
PinName  led2,
PinName  led1,
PinName  led0,
bool  on = 1 
)

Create Hotboards_leds instance for five leds.

Parameters:
led4pin where the led 4 will be connected
led3pin where the led 3 will be connected
led2pin where the led 2 will be connected
led1pin where the led 1 will be connected
led0pin where the led 0 will be connected
onlogic level to turn on the leds

Example:

   // one instance with 5 leds on pins 5, 6, 7, 8 and 9
   Hotboards_leds led( 5, 6, 7, 8, 9 );

Definition at line 51 of file Hotboards_leds.cpp.

Hotboards_leds ( PinName  led5,
PinName  led4,
PinName  led3,
PinName  led2,
PinName  led1,
PinName  led0,
bool  on = 1 
)

Create Hotboards_leds instance for six leds.

Parameters:
led5pin where the led 5 will be connected
led4pin where the led 4 will be connected
led3pin where the led 3 will be connected
led2pin where the led 2 will be connected
led1pin where the led 1 will be connected
led0pin where the led 0 will be connected
onlogic level to turn on the leds

Example:

   // one instance with 6 leds on pins 5, 6, 7, 8, 9 and 10
   Hotboards_leds led( 5, 6, 7, 8, 9, 10 );

Definition at line 63 of file Hotboards_leds.cpp.

Hotboards_leds ( PinName  led6,
PinName  led5,
PinName  led4,
PinName  led3,
PinName  led2,
PinName  led1,
PinName  led0,
bool  on = 1 
)

Create Hotboards_leds instance for seven leds.

Parameters:
led6pin where the led 6 will be connected
led5pin where the led 5 will be connected
led4pin where the led 4 will be connected
led3pin where the led 3 will be connected
led2pin where the led 2 will be connected
led1pin where the led 1 will be connected
led0pin where the led 0 will be connected
onlogic level to turn on the leds

Example:

   // one instance with 7 leds on pins 5, 6, 7, 8, 9, 10 and 11
   Hotboards_leds led( 5, 6, 7, 8, 9, 10, 11 );

Definition at line 76 of file Hotboards_leds.cpp.

Hotboards_leds ( PinName  led7,
PinName  led6,
PinName  led5,
PinName  led4,
PinName  led3,
PinName  led2,
PinName  led1,
PinName  led0,
bool  on = 1 
)

Create Hotboards_leds instance for eight leds.

Parameters:
led7pin where the led 7 will be connected
led6pin where the led 6 will be connected
led5pin where the led 5 will be connected
led4pin where the led 4 will be connected
led3pin where the led 3 will be connected
led2pin where the led 2 will be connected
led1pin where the led 1 will be connected
led0pin where the led 0 will be connected
onlogic level to turn on the leds

Example:

   // one instance with 8 leds on pins 5, 6, 7, 8, 9, 10, 11 and 12
   Hotboards_leds led( 5, 6, 7, 8, 9, 10, 11, 12 );

Definition at line 90 of file Hotboards_leds.cpp.


Member Function Documentation

uint8_t read ( uint8_t  led = 0xff )

Read a single led or the entire bus.

Returns:
led states

Example:

   // instance on led on 7 and read its state (0 o 1)
   Hotboards_leds led( 7 );
   uint8_t var = led.read( );
    
   // instance an 8 leds bus (pin9->led7 ..... pin2->led0)
   Hotboards_leds leds( 9, 8, 7, 6, 5, 4, 3, 2 );
   // read the leds value (from 0 to 255) 
   uint8_t var = leds.read( );
  
   // nstance a 4 leds bus (pin2->led3 ..... pin5->led0)
   Hotboards_leds leds( 2, 3, 4, 5 );
   // read led 1 state (pin 4) 
   uint8_t val1 = leds.write( 1 );
   // read led 0 state (pin 5) 
   uint8_t val2 = leds.write( 0 );

Definition at line 130 of file Hotboards_leds.cpp.

void toggle ( uint8_t  led = 0 )

Toggle a single led.

Parameters:
ledled number to be toggled

Example:

   // instance one led on pin 7 and toggle it
   Hotboards_leds led( 7 );
   led.toggle( );
     
   // instance a bus with 3 leds
   Hotboards_leds leds( 2, 3, 4 );
   // toggle led 2 on pin 2
   leds.toggle( 2 );
   // toggle led 1 on pin 3
   leds.toggle( 1 );

Definition at line 118 of file Hotboards_leds.cpp.

void turnOff ( uint8_t  led = 0 )

Turn off a single led.

Parameters:
ledled number to be turn off

Example:

   // instance one led on pin 5 and turn it off
   Hotboards_leds led( 5 );
   led.turnOff( );
     
   // instance a bus with 4 leds
   Hotboards_leds leds( 8, 7, 6, 5 );
   // turn off led 3 on pin 8
   leds.turnOff( 3 );
   // turn off led 0 on pin 5
   leds.turnOff( 0 );

Definition at line 111 of file Hotboards_leds.cpp.

void turnOn ( uint8_t  led = 0 )

Turn on a single led.

Parameters:
ledled number to be turn on

Example:

   // instance one led on pin 5 and turn it on
   Hotboards_leds led( 5 );
   led.turnOn( );
     
   // instance a bus with 4 leds
   Hotboards_leds leds( 8, 7, 6, 5 );
   // turn on led 2 on pin 7
   leds.turnOn( 2 );
   // turn on led 0 on pin 5
   leds.turnOn( 0 );

Definition at line 105 of file Hotboards_leds.cpp.

void write ( uint8_t  val )

Write to a single led or the entire bus.

Parameters:
valvalue to be written

Example:

   // instance one led on pin 7 and write a 1 (aceptara valores de 0 a 1) 
   Hotboards_leds led( 7 );
   led.write( 1 );
    
   // instance a 4 leds bus (pin2->led3 ..... pin5->led0)
   Hotboards_leds leds( 2, 3, 4, 5 );
   // write the 10 value (it will accept values from 0 to 15) 
   leds.write( 10 );
      
   // instance an 8 leds bus (pin4->led7 ..... pin3->led0)
   Hotboards_leds leds( 4, 3, 2, 6, 5, 7, 8, 9 );
   // write the 134 value (it will accept values from 0 to 255)
   leds.write( 134 );

Definition at line 149 of file Hotboards_leds.cpp.