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.
6LedBar.h
- Committer:
 - kryksyh
 - Date:
 - 2017-05-21
 - Revision:
 - 1:248129e96f43
 - Parent:
 - 0:52b8975f1dd9
 - Child:
 - 2:70b58ce02820
 
File content as of revision 1:248129e96f43:
#ifndef LED_BAR_H
#define LED_BAR_H
#include "mbed.h"
/*
Example:
@code
#include "mbed.h"
#include "6LedBar.h"
LedBar leds (A0, A1, A2, A3, A4, A5);
int main() {
    leds.on_mask(0b010101);
    
    while(true) {
        leds.toggle_mask(0b111111);
        wait(0.5);
    }
}
@endcode
*/
class LedBar {
public:
    //Constructor, you need to specify pins to which
    //leds are connected
    LedBar(PinName p0,
           PinName p1,
           PinName p2,
           PinName p3,
           PinName p4,
           PinName p5);
           
    // Turn n-s led on
    void on(int n);
    
    //Turn n-s led off
    void off(int n);
    
    //Toggle n-s led
    void toggle(int n);
    
    //Set bit mask
    //i.e. mask 0b000101 will turn on leds 0 and 1, and off all others
    void set_mask(int m);
    
    //Turn on leds specified by bit-mask
    void on_mask(int m);
    
    //Turn off leds specified by bit-mask
    void off_mask(int m);
    
    //Toggle leds specified by bit-mask
    void toggle_mask(int m);
private:
    static const int LEDS_COUNT = 6;
    DigitalOut l0, l1, l2, l3, l4, l5;
    DigitalOut *m_leds[LEDS_COUNT];
};
#endif //LED_BAR_H