Simple 6-LED bar library. Provides some useful functions.

Simple 6 leds bar library. It allows you to control individual leds, and provides masks.

Revision:
1:248129e96f43
Parent:
0:52b8975f1dd9
Child:
2:70b58ce02820
--- a/6LedBar.h	Sun May 21 13:10:19 2017 +0000
+++ b/6LedBar.h	Sun May 21 14:07:51 2017 +0000
@@ -3,15 +3,73 @@
 
 #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];
 
 };