Charles Tritt / Mbed 2 deprecated FlexiBarDemo

Dependencies:   mbed

Fork of BinaryCount by Charles Tritt

Revision:
8:8a2d07e4a8c3
Parent:
7:031078522195
--- a/main.cpp	Fri Oct 20 17:27:02 2017 +0000
+++ b/main.cpp	Mon Oct 23 19:10:39 2017 +0000
@@ -8,15 +8,11 @@
     Created: 9/13/17 (v. 1.0)
 */
 #include "mbed.h"
+#include <flexiBar.h>
 
 // Create 10-bit BusOut object called barGraph.
 BusOut barGraph(D11, D10, D9, D8, D7, D6, D5, D4, D3, D2);
 
-// Displays specified digit on theBar. Returns non-zero in case of errors. Mbed 
-// objects generally must be based by reference. See function definition for 
-// more information.
-int flexiBar(int value, BusOut &theBar, bool single, bool active);
-
 int main() {
 
     printf("flexiBar Test Harness\n"); // ID software.
@@ -43,49 +39,4 @@
         flexiBar(-1, barGraph, false, true);
         wait(2.0);   
     }
-}
-
-int flexiBar(int value, BusOut &theBar, bool single, bool active) {
-/*
-    Function: flexiBar (v. 1.0)
-    Created by: Dr. C. S. Tritt, 10/20/17
-    
-    Displays value (range 0 to 9) on the specified bar graph display. If solid 
-    is true, all the lower order bars will be on. Otherwise they will be off. 
-    Active being true indicates the display is wired active high. Otherwise, it
-    is assumed to be active low. To assure display is operational, the 
-    display will show at least one bar lit at all times (0 is indicated by a 
-    single bar and 9 by 10 bars). A special case is a value of -1 which will 
-    light no bars.
-    
-    I previously thought pow would be better than left shift (<<), but now I see
-    that left shift really is the best approach.
-    
-    Mbed objects generally must be passed by reference (with &).
-    
-    Pass theBar (rather than use a global symbol) for flexibility.
-    
-    Note there are 2 returns in this function! One for value being out of range
-    errors. The other for no error.
-*/
-    if (value < -1 || value > 9) return -1; // Value out of range error.
-    
-    int output; // Use variable to make active low case easy to compute.
-    
-    if (value == -1) {
-        output = 0;  // Special case of all bars off.
-    } else {
-        if (single) {
-             output = 1 << value; // Light single bars by shifting 1 left.
-        } else {
-             output = (1 << (value + 1)) - 1; // Light a stack of bars.
-        }
-    }
-    
-    if (active) { // Deal with active low vs. active high.
-        theBar = output;
-    } else {
-        theBar = ~output; // Invert bits for actived low.
-    }
-    return 0; // 
-}    
\ No newline at end of file
+}
\ No newline at end of file