:)
Dependencies: MbedJSONValue DebounceIn TextLCD USBDevice mbed WebSocketClient cc3000_hostdriver_mbedsocket Adafruit_LEDBackpack_2
Diff: main.cpp
- Revision:
- 4:5d27966f93e4
- Parent:
- 3:161fed8bd027
- Child:
- 5:03d75ad40d5e
--- a/main.cpp Sun Nov 23 05:45:51 2014 +0000 +++ b/main.cpp Mon Nov 24 00:49:48 2014 +0000 @@ -11,10 +11,15 @@ //LED stuff I2C i2c(D7,D6); -Adafruit_24bargraph ledbar=Adafruit_24bargraph(&i2c); +Adafruit_24bargraph ledbar_left=Adafruit_24bargraph(&i2c); + +//I2C i2c(D7,D6); +//Adafruit_24bargraph ledbar_right=Adafruit_24bargraph(&i2c); + DebounceIn upbutton(D9); DebounceIn downbutton(D8); - +//DebounceIn leftbutton( ); +//DebounceIn rightbutton( ); //Scanner stuff @@ -58,16 +63,21 @@ float test_val = .001; float row_volt = 0; - int con_mat[8][8] = {}; + int con_mat[24][2] = {}; int a1,b1,c1,a2,b2,c2; + float volt_mat[24][2] = {}; //dac = test_val; //LED init - int redcount = 0, greencount = 0, rowselect = 0, rowselect_old = 0, moved = 1; - ledbar.begin(0x70); - ledbar.clear(); - ledbar.writeDisplay(); + int redcount = 0, greencount = 0, rowselect = 0, rowselect_old = 0, moved = 1, colselect = 0; + ledbar_left.begin(0x70); + ledbar_left.clear(); + ledbar_left.writeDisplay(); + + ledbar_right.begin(0x70); + ledbar_right.clear(); + ledbar_right.writeDisplay(); //LCD init lcd.cls(); @@ -79,10 +89,17 @@ //Display - ledbar.setBar(rowselect_old,LED_OFF); - ledbar.setBar(rowselect,LED_GREEN); - ledbar.writeDisplay(); - + if (colselect == 0) { + ledbar_left.setBar(rowselect_old,LED_OFF); + ledbar_left.setBar(rowselect,LED_GREEN); + ledbar_left.writeDisplay(); + ledbar_right.writeDisplay(); + } + else + ledbar_right.setBar(rowselect_old,LED_OFF); + ledbar_right.setBar(rowselect,LED_GREEN); + ledbar_right.writeDisplay(); + ledbar_left.writeDisplay(); //Moving the selected row if (upbutton.read() == 0) { @@ -98,6 +115,18 @@ moved = 1; wait(0.75); } + + if (leftbutton.read() == 0) { + colselect = 0; + wait(0.75); + ledbar_right.clear(); + } + + if (rightbutton.read() == 0) { + colselect = 1; + wait(0.75); + ledbar_left.clear(); + } //Boundary checking if (rowselect > 23) { @@ -183,5 +212,56 @@ } +/* + +//Scans rows connected to vdd and ground. Vdd = 2 in con mat, Ground = 3. Rows connected to selected row = 1. + +//SET MULTIPLEXER TO READ VDD +vddval = adc.read(); + +//SET MULTIPLEXER TO READ SELECTED ROW +rowval = adc.read(); + +for (int x = 0; x < 2; x++) { + for (int y = 0; y < 24; y++) { + A_in = x%2; + a1 = x%2; + B_in = (x/2)%2; + b1 = (x/2)%2; + C_in = (x/4)%2; + c1 = (x/4)%2; + + A_out = y%2; + int a2 = y%2; + B_out = (y/2)%2; + b2 = (y/2)%2; + C_out = (y/4)%2; + c2 = (y/4)%2; + + float in_val = adc.read(); + volt_mat[x][y] = in_val; + + if (in_val == vddval){ + con_mat[x][y] = 2; + } + if (in_val == 0){ + con_mat[x][y] = 3; + } + if (in_val == rowval){ + con_mat[x][y] = 1; + } + else + con_mat[x][y] = 0; + } + } + +//Q: Do we need to do the same test for ground or can 0.00 be assumed? +//Q: What is the most efficient way to compare all the "volt_mat" elements? +//Q: Do we need to add a "confidence interval" around the rowval and vdd tests? + + + +*/ +