:)
Dependencies: MbedJSONValue DebounceIn TextLCD USBDevice mbed WebSocketClient cc3000_hostdriver_mbedsocket Adafruit_LEDBackpack_2
Revision 5:03d75ad40d5e, committed 2014-11-24
- Comitter:
- ddrew73
- Date:
- Mon Nov 24 17:52:11 2014 +0000
- Parent:
- 4:5d27966f93e4
- Child:
- 6:d0a1eba7f943
- Commit message:
- LED/LCD code included in commented loop...
Changed in this revision
| Adafruit_LEDBackpack_2.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Adafruit_LEDBackpack_2.lib Mon Nov 24 17:52:11 2014 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/ddrew73/code/Adafruit_LEDBackpack_2/#0491b3f9a639
--- a/main.cpp Mon Nov 24 00:49:48 2014 +0000
+++ b/main.cpp Mon Nov 24 17:52:11 2014 +0000
@@ -13,13 +13,13 @@
I2C i2c(D7,D6);
Adafruit_24bargraph ledbar_left=Adafruit_24bargraph(&i2c);
-//I2C i2c(D7,D6);
-//Adafruit_24bargraph ledbar_right=Adafruit_24bargraph(&i2c);
+I2C i2c(D7,D6);
+Adafruit_24bargraph ledbar_right=Adafruit_24bargraph(&i2c);
DebounceIn upbutton(D9);
DebounceIn downbutton(D8);
-//DebounceIn leftbutton( );
-//DebounceIn rightbutton( );
+DebounceIn leftbutton( );
+DebounceIn rightbutton( );
//Scanner stuff
@@ -74,7 +74,7 @@
ledbar_left.begin(0x70);
ledbar_left.clear();
ledbar_left.writeDisplay();
-
+
ledbar_right.begin(0x70);
ledbar_right.clear();
ledbar_right.writeDisplay();
@@ -86,17 +86,18 @@
lcd.printf("%s",programname.c_str());
while(1) {
-
+
//Display
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_left.clear();
+ ledbar_right.clear();
+ ledbar_left.setBar(rowselect,LED_GREEN);
+ ledbar_left.writeDisplay();
+ ledbar_right.writeDisplay();
+ } else
+ ledbar_left.clear();
+ ledbar_right.clear();
ledbar_right.setBar(rowselect,LED_GREEN);
ledbar_right.writeDisplay();
ledbar_left.writeDisplay();
@@ -115,18 +116,23 @@
moved = 1;
wait(0.75);
}
-
+
if (leftbutton.read() == 0) {
colselect = 0;
+ ledbar_right.clear();
+ moved =1;
wait(0.75);
- ledbar_right.clear();
+
}
-
+
if (rightbutton.read() == 0) {
colselect = 1;
+ ledbar_left.clear();
+ moved =1;
wait(0.75);
- ledbar_left.clear();
- }
+
+
+ }
//Boundary checking
if (rowselect > 23) {
@@ -186,7 +192,6 @@
}
}
ledbar.writeDisplay();
- moved = 0;
float vddmeasure = 3.14259;
float vrowmeasure = 1.1234;
@@ -214,6 +219,7 @@
/*
+///// PUT ALL BELOW IN SCAN BUTTON IF ////////
//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
@@ -222,6 +228,9 @@
//SET MULTIPLEXER TO READ SELECTED ROW
rowval = adc.read();
+ledbar_left.clear();
+ledbar_right.clear();
+
for (int x = 0; x < 2; x++) {
for (int y = 0; y < 24; y++) {
A_in = x%2;
@@ -240,23 +249,69 @@
float in_val = adc.read();
volt_mat[x][y] = in_val;
-
+
if (in_val == vddval){
con_mat[x][y] = 2;
+ if (x == 0){
+ ledbar_left.setBar(y,LED_RED);
+ }
+ else {
+ ledbar_right.setBar(y,LED_RED);
+ }
}
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);
+ }
}
if (in_val == rowval){
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;
}
}
+moved = 0;
+
+//// PUT ALL ABOVE IN SCAN BUTTON IF /////
+
+
+
+if (moved==0) {
+ledbar_left.writeDisplay();
+ledbar_right.writeDisplay();
+lcd.cls();
+lcd.locate(0,1);
+lcd.printf("Vdd: %1.1f V",vddval);
+lcd.locate(0,0);
+lcd.printf("Row: %1.1f V",rowval);
+}
+else {
+ lcd.cls();
+ string programname = "Dan's UI Test";
+ string instructions = "Select a row and scan it";
+ lcd.locate(0,0);
+ lcd.printf("%s",programname.c_str());
+ lcd.locate(0,1);
+ lcd.printf("%s",instructions.c_str());
+}
+
+
+
+
//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: 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?