Dmitry Makarenko / 6LedBar

Files at this revision

API Documentation at this revision

Comitter:
kryksyh
Date:
Sun May 21 14:59:47 2017 +0000
Parent:
3:bb53fa90af91
Commit message:
set_mask method

Changed in this revision

6LedBar.cpp Show annotated file Show diff for this revision Revisions of this file
6LedBar.h Show annotated file Show diff for this revision Revisions of this file
--- a/6LedBar.cpp	Sun May 21 14:29:24 2017 +0000
+++ b/6LedBar.cpp	Sun May 21 14:59:47 2017 +0000
@@ -53,4 +53,15 @@
             toggle(i);
         }
     }
+}
+
+void LedBar::set_mask(int m) {
+    for(int i = 0; i < LEDS_COUNT; i++) {
+        if(m & (1 << i)) {
+            on(i);
+        }
+        else {
+            off(i);
+        }
+    }
 }
\ No newline at end of file
--- a/6LedBar.h	Sun May 21 14:29:24 2017 +0000
+++ b/6LedBar.h	Sun May 21 14:59:47 2017 +0000
@@ -30,7 +30,7 @@
 *
 *  Example using on, off, toggle methods:
 *  
-*@code
+* @code
 *  
 *  #include "mbed.h"
 *  #include "6LedBar.h"
@@ -52,13 +52,13 @@
 *  }
 *  
 *  
-*@endcode
+* @endcode
 *  
 *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  
 *  
 *  Example using mask methods:
 *  
-*@code
+* @code
 *  
 *  #include "mbed.h"
 *  #include "6LedBar.h"
@@ -68,7 +68,7 @@
 *  
 *  int main() {
 *  
-*      leds.on_mask(0b010101);
+*      leds.set_mask(0b010101);
 *      
 *      while(true) {
 *          leds.toggle_mask(0b111111);
@@ -76,7 +76,7 @@
 *      }
 *  }
 *  
-*@endcode
+* @endcode
 *
 **/