:)
Dependencies: MbedJSONValue DebounceIn TextLCD USBDevice mbed WebSocketClient cc3000_hostdriver_mbedsocket Adafruit_LEDBackpack_2
Revision 17:fcc378db08f4, committed 2014-12-09
- Comitter:
- ddrew73
- Date:
- Tue Dec 09 22:27:02 2014 +0000
- Parent:
- 16:028a8548ab22
- Child:
- 18:f7a00c31ff58
- Commit message:
- This code doesn't work due to Wifi.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Dec 09 20:06:17 2014 +0000
+++ b/main.cpp Tue Dec 09 22:27:02 2014 +0000
@@ -85,9 +85,9 @@
// - SPI CLK => (pin D13)
// plus wifi network SSID, password, security level and smart-configuration flag.
-/*
+
-mbed_cc3000::cc3000 wifi(D8, D9, D10, SPI(D11, D12, D13),
+mbed_cc3000::cc3000 wifi(D8, D9, D10, SPI(D11, D12, D13), // spi goes mosi, miso, clk
"SSID", "PASSWORD", WPA2, false);
Websocket ws("ws://sockets.mbed.org/ws/toastboard/rw");
@@ -136,10 +136,10 @@
add_to_json("]}",json_str);
return s;
}
-*/
+
bool voltages_equal(float voltage1,float voltage2) {
- return (voltage1 > voltage2-0.01) && (voltage1 < voltage2+0.01);
+ return (voltage1 > voltage2-0.008) && (voltage1 < voltage2+0.008);
}
void read_voltages(float voltages[48]) {
@@ -174,19 +174,19 @@
scan_select = 1;
scan_select = 0;
- wait(0.01);
+ wait(0.02);
float in_val = adc.read();
voltages[sn] = in_val;
- wait(0.01);
+ wait(0.035);
scan_select = 1;
scan_select = 0;
- wait(0.01);
+ wait(0.02);
in_val = adc.read();
- if ((in_val < voltages[sn]-0.004) || (in_val > voltages[sn]+0.004)){
+ if ((in_val < voltages[sn]-0.006) || (in_val > voltages[sn]+0.006)){
voltages[sn] = 100;
}
@@ -249,14 +249,12 @@
//Scan init
float originalvoltages[48] = {};
- float newvoltages[48] = {};
float clientdata[48] = {};
float vddval = 0.0;
float rowval = 0.0;
float dacval = 0.1;
float floatout[48] = {};
- float floatoutsecond[48] = {};
//LED init
int rowselect = 0, moved = 1, colselect = 0, selected = 0, oldselected = 49;
@@ -272,7 +270,7 @@
lcd.cls();
int written = 0;
- //wifi.init();
+ wifi.init();
//Osci
int loopcount = 0, pressed = 0;
@@ -280,7 +278,7 @@
while(1) {
- /*
+
if (wifi.is_connected() == false) {
pc.printf("trying to connect to wifi\r\n");
if (wifi.connect() == -1) {
@@ -293,7 +291,7 @@
ws.connect();
}
- */
+
//Display
@@ -361,18 +359,18 @@
ledbar_right.clear();
// first set of voltages read into old_volt_mat
+ float_check(floatout,dacval);
+ wait(0.2);
read_voltages(originalvoltages);
- wait(0.4);
- read_voltages(newvoltages);
+
// second set for comparison, read into clientdata
- wait(0.4);
+ wait(0.2);
compare_voltages(originalvoltages,clientdata,colselect,rowselect,vddval,floatout);
- wait(0.2);
- float_check(floatout,dacval);
+
selected = (colselect * 24) + (rowselect+1);
- rowval = newvoltages[selected-1];
+ rowval = originalvoltages[selected-1];
written = 0;
moved = 0;
@@ -385,12 +383,12 @@
}
pc.printf(" \r\n \r\n ");
for (int x = 0; x < 48; x++) {
- pc.printf("%1.3f %1.3f %1.3f \r\n", originalvoltages[x], newvoltages[x], floatout[x]);
+ pc.printf("%1.4f %1.4f %d \r\n", originalvoltages[x], floatout[x], x+1);
}
////////////////////////
- wait(0.1); //THIS NEEDS TO GO AWAY!
+ //THIS NEEDS TO GO AWAY!
} // END OF SCANBUTTON IF STATEMENT
@@ -399,7 +397,7 @@
ledbar_right.writeDisplay();
lcd_write_voltage_info(vddval*3.3,selected,rowval*3.3);
- /*
+
// send data to websocket
if (wifi.is_connected()) {
std::string json = build_json(vddval,selected,clientdata);
@@ -410,7 +408,7 @@
delete[] writable;
delete[] &json;
}
- */
+
written = 1;
} else if (oldselected != selected) {