:)

Dependencies:   MbedJSONValue DebounceIn TextLCD USBDevice mbed WebSocketClient cc3000_hostdriver_mbedsocket Adafruit_LEDBackpack_2

Files at this revision

API Documentation at this revision

Comitter:
ddrew73
Date:
Tue Dec 02 23:25:02 2014 +0000
Parent:
10:cfd60b63ed11
Child:
13:209da1dcb6e1
Commit message:
Float checker implemented (not checked);

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Dec 02 23:17:59 2014 +0000
+++ b/main.cpp	Tue Dec 02 23:25:02 2014 +0000
@@ -73,7 +73,7 @@
 {
 
     //Scan init
-    
+
     int con_mat[24][2] = {};
     float volt_mat[24][2] = {};
     float clientdata[48] = {};
@@ -91,11 +91,11 @@
 
     //LCD init
     lcd.cls();
-    
+
     //Osci
     int loopcount = 0, pressed = 0;
     float begintime = 0, endtime = 0, elapsed = 0;
-    
+
 
     while(1) {
 
@@ -107,24 +107,23 @@
             ledbar_left.setBar(rowselect,LED_GREEN);
             ledbar_left.writeDisplay();
             ledbar_right.writeDisplay();
-        } 
-        else if (colselect == 1 && moved == 1) {
-        ledbar_left.clear();
-        ledbar_right.clear();
-        ledbar_right.setBar(rowselect,LED_GREEN);
-        ledbar_right.writeDisplay();
-        ledbar_left.writeDisplay();
+        } else if (colselect == 1 && moved == 1) {
+            ledbar_left.clear();
+            ledbar_right.clear();
+            ledbar_right.setBar(rowselect,LED_GREEN);
+            ledbar_right.writeDisplay();
+            ledbar_left.writeDisplay();
         }
         //Moving the selected row
         if (upbutton.read() == 0) {
-            
+
             rowselect = rowselect-1;
             moved = 1;
             wait(0.75);
         }
 
         if (downbutton.read() == 0) {
-            
+
             rowselect = rowselect+1;
             moved = 1;
             wait(0.75);
@@ -164,12 +163,12 @@
             D_in = 1;
             E_in = 1;
             F_in = 1;
-            
+
             vddval = adc.read();
 
             //SET MULTIPLEXER TO READ SELECTED ROW
             // Sample the 'selected' node
-            
+
             int sn = (colselect + 1)*(rowselect + 1);
             A_in = (sn-1)&2;
             B_in = ((sn-1)/2)%2;
@@ -182,69 +181,79 @@
             ledbar_left.clear();
             ledbar_right.clear();
 
-            for (int x = 0; x < 2; x++) {
-                for (int y = 0; y < 24; y++) {
-                    
-                    
-                    int sn = (colselect+1)*(rowselect+1);
-                    A_in = (sn-1)&2;
-                    B_in = ((sn-1)/2)%2;
-                    C_in = ((sn-1)/4)%2;
-                    D_in = ((sn-1)/8)%2;
-                    E_in = ((sn-1)/16)%2;
-                    F_in = ((sn-1)/32)%2;
+            for (int u = 0; u < 2; u++) {
 
-                    float in_val = adc.read();
-                    
-                    
+                for (int x = 0; x < 2; x++) {
+                    for (int y = 0; y < 24; y++) {
+
 
-                    volt_mat[x][y] = in_val;
-                    
-                    if (x == 1){
-                    int z = y+24;
-                    clientdata[z] = in_val;
-                    }
-                    else {
-                    clientdata[y] = in_val;
-                    }
-                   
-                    
-                    if ((in_val > vddval-0.01) && (in_val < vddval+0.01)) {
-                        con_mat[x][y] = 2;
-                        if (x == 0) {
-                            ledbar_left.setBar(y,LED_RED);
+                        int sn = (colselect+1)*(rowselect+1);
+                        A_in = (sn-1)&2;
+                        B_in = ((sn-1)/2)%2;
+                        C_in = ((sn-1)/4)%2;
+                        D_in = ((sn-1)/8)%2;
+                        E_in = ((sn-1)/16)%2;
+                        F_in = ((sn-1)/32)%2;
+
+                        float in_val = adc.read();
+
+
+                        if (u == 0) {
+                            old_volt_map[x][y] = in_val
                         } else {
-                            ledbar_right.setBar(y,LED_RED);
-                        }
-                    } 
-                    else if (in_val == 0) {
-                        con_mat[x][y] = 3;
-                        if (x == 0) {
-                            ledbar_left.setBar(y,LED_YELLOW);
-                        } else {
-                            ledbar_right.setBar(y,LED_YELLOW);
-                        }
-                    } 
-                    else if ((in_val > rowval-0.01) && (in_val < rowval+0.01)) {
-                        con_mat[x][y] = 1;
-                        if (x == 0) {
-                            ledbar_left.setBar(y,LED_GREEN);
-                        } else {
-                            ledbar_right.setBar(y,LED_GREEN);
-                        }
-                    } 
-                    else {
-                        con_mat[x][y] = 0;
-                    }
-                  
-                    
-               } } //END OF ROWSCAN FOR LOOP
-                
-                 selected = rowselect;
-                    if (colselect == 1){
-                      selected = selected+24;
-                      }
-                
+                            volt_map[x][y] = in_val
+                            if (old_volt_map[x][y] != volt_map[x][y] ) {
+                                volt_map[x][y] = 100;
+                            }
+                            if (x == 1) {
+                                int z = y+24;
+                                clientdata[z] = in_val;
+                            } else {
+                                clientdata[y] = in_val;
+                            }
+
+                           
+                            if ((in_val > vddval-0.01) && (in_val < vddval+0.01)) {
+                                con_mat[x][y] = 2;
+                                if (x == 0) {
+                                    ledbar_left.setBar(y,LED_RED);
+                                } else {
+                                    ledbar_right.setBar(y,LED_RED);
+                                }
+                            } else if (in_val == 0) {
+                                con_mat[x][y] = 3;
+                                if (x == 0) {
+                                    ledbar_left.setBar(y,LED_YELLOW);
+                                } else {
+                                    ledbar_right.setBar(y,LED_YELLOW);
+                                }
+                            } else if ((in_val > rowval-0.01) && (in_val < rowval+0.01)) {
+                                con_mat[x][y] = 1;
+                                if (x == 0) {
+                                    ledbar_left.setBar(y,LED_GREEN);
+                                } else {
+                                    ledbar_right.setBar(y,LED_GREEN);
+                                }
+                            } 
+                            else if (volt_mat[x][y]==100) {
+                                con_mat[x][y] = 4;
+                                if (x == 0) {
+                                    ledbar_left.setBar(y,LED_OFF);
+                                } else {
+                                    ledbar_right.setBar(y,LED_OFF);
+                                }
+                            }
+                            else {
+                                con_mat[x][y] = 0;
+                            }
+
+                }}} //END OF ROWSCAN FOR LOOP
+
+                selected = rowselect;
+                if (colselect == 1) {
+                    selected = selected+24;
+                }
+
                 /*
                 //STUFF INTO JSON FORMAT
                 char str[1];
@@ -254,33 +263,34 @@
                     }
                 demo["vdd"] = vddval;
                 demo["rowval"] = rowval;
-          
+
                 demo["selected"] = selected;
                 */
-                
-                
+
+
                 moved = 0;
-                
-                
+
+
                 //DEBUGGING TOOLS //////////////
-                
-                pc.printf("\r\n%1.3f %1.3f \r\n", vddval, rowval); 
-                for (int i = 0; i<48; i++){
-                pc.printf(" %1.3f ", clientdata[i]);
+
+                pc.printf("\r\n%1.3f %1.3f \r\n", vddval, rowval);
+                for (int i = 0; i<48; i++) {
+                    pc.printf(" %1.3f ", clientdata[i]);
                 }
                 pc.printf(" \r\n \r\n ");
                 for (int x = 0; x < 2; x++) {
-                for (int y = 0; y < 24; y++) {
-                pc.printf("%1.3f \r\n", volt_mat[x][y]);
-                }}
+                    for (int y = 0; y < 24; y++) {
+                        pc.printf("%1.3f \r\n", volt_mat[x][y]);
+                    }
+                }
                 ////////////////////////
-                
-                 
+
+
                 wait(1);  //THIS NEEDS TO GO AWAY! :}
-                
-                } // END OF SCANBUTTON IF STATEMENT
-                
-                if (moved==0)  {
+
+            } // END OF SCANBUTTON IF STATEMENT
+
+            if (moved==0)  {
                 ledbar_left.writeDisplay();
                 ledbar_right.writeDisplay();
                 lcd.cls();
@@ -288,8 +298,7 @@
                 lcd.printf("Vdd: %1.1f V",vddval);
                 lcd.locate(0,0);
                 lcd.printf("Row %d: %1.1f V",selected,rowval);
-                    }
-                else {
+            } else {
                 lcd.cls();
                 string programname = "The ToastBoard";
                 string instructions = "Select a row";
@@ -297,13 +306,13 @@
                 lcd.printf("%s",programname.c_str());
                 lcd.locate(0,1);
                 lcd.printf("%s",instructions.c_str());
-                    }
+            }
 
 
 
 
 
-            
+
 
 
 
@@ -319,57 +328,57 @@
     }  // END OF INT MAIN
 
 
-/*
-FLOAT NODE CHECKER
- add another "for" around the two for the 48 row checker:
+    /*
+    FLOAT NODE CHECKER
+     add another "for" around the two for the 48 row checker:
 
-if (u == 0){
-old_volt_map[x,y] = in_val
-}
-else{
-volt_map[x,y] = in_val
-if (old_volt_map[x,y] != volt_map[x,y] ) {
-    volt_map[x,y] = 100;
+    if (u == 0){
+    old_volt_map[x,y] = in_val
+    }
+    else{
+    volt_map[x,y] = in_val
+    if (old_volt_map[x,y] != volt_map[x,y] ) {
+        volt_map[x,y] = 100;
+        }
+
+    PUT ALL ROW LIGHTING (CON_MAT) STUFF HERE
     }
 
-PUT ALL ROW LIGHTING (CON_MAT) STUFF HERE
-}
+    */
 
-*/
-
-/*
-OSCILLISCOPE
+    /*
+    OSCILLISCOPE
 
 
-while (scanbutton == 0){
-if (loopcount = 0){
-timer.reset();
-timer.start();
-begintime = timer.read_ms();
-pressed == 1;
-}
+    while (scanbutton == 0){
+    if (loopcount = 0){
+    timer.reset();
+    timer.start();
+    begintime = timer.read_ms();
+    pressed == 1;
+    }
 
-int sn = (colselect + 1)*(rowselect + 1);
-            A_in = (sn-1)&2;
-            B_in = ((sn-1)/2)%2;
-            C_in = ((sn-1)/4)%2;
-            D_in = ((sn-1)/8)%2;
-            E_in = ((sn-1)/16)%2;
-            F_in = ((sn-1)/32)%2;
-            volt_buffer[loopcount] = adc.read();
-            
+    int sn = (colselect + 1)*(rowselect + 1);
+                A_in = (sn-1)&2;
+                B_in = ((sn-1)/2)%2;
+                C_in = ((sn-1)/4)%2;
+                D_in = ((sn-1)/8)%2;
+                E_in = ((sn-1)/16)%2;
+                F_in = ((sn-1)/32)%2;
+                volt_buffer[loopcount] = adc.read();
+
 
-loopcount = loopcount +1;
-} // BREAK THE WHILE SCANBUTTON
+    loopcount = loopcount +1;
+    } // BREAK THE WHILE SCANBUTTON
 
-if (pressed == 1){
-timer.stop();
-endtime = timer.read_ms();
-elapsed = endtime - begintime;
+    if (pressed == 1){
+    timer.stop();
+    endtime = timer.read_ms();
+    elapsed = endtime - begintime;
 
-DO ENTIRE SCAN STUFF
+    DO ENTIRE SCAN STUFF
 
-pressed = 0;
-}
+    pressed = 0;
+    }
 
-*/
\ No newline at end of file
+    */
\ No newline at end of file