:)

Dependencies:   MbedJSONValue DebounceIn TextLCD USBDevice mbed WebSocketClient cc3000_hostdriver_mbedsocket Adafruit_LEDBackpack_2

Committer:
jn80842
Date:
Tue Dec 02 23:55:01 2014 +0000
Revision:
12:c4b046975527
Parent:
8:725d938b301b
Child:
13:209da1dcb6e1
add in json formatting code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ddrew73 0:16d2619002d7 1 #include "mbed.h"
ddrew73 1:0183a7d38878 2 #include <string>
ddrew73 0:16d2619002d7 3 #include "Adafruit_LEDBackpack.h"
ddrew73 0:16d2619002d7 4 #include "Adafruit_GFX.h"
ddrew73 0:16d2619002d7 5 #include "TextLCD.h"
ddrew73 0:16d2619002d7 6 #include "DebounceIn.h"
jn80842 3:161fed8bd027 7 #include "cc3000.h"
jn80842 3:161fed8bd027 8 #include "Websocket.h"
ddrew73 0:16d2619002d7 9
ddrew73 8:725d938b301b 10 //Debug
ddrew73 8:725d938b301b 11 Serial pc(USBTX, USBRX); // tx, rx
ddrew73 8:725d938b301b 12
ddrew73 8:725d938b301b 13 //For oscilliscope
ddrew73 8:725d938b301b 14 Timer timer;
ddrew73 8:725d938b301b 15
ddrew73 0:16d2619002d7 16 //LED stuff
ddrew73 7:7fbe8dc5e4fa 17 I2C i2c_left(D7,D6);
ddrew73 7:7fbe8dc5e4fa 18 Adafruit_24bargraph ledbar_left=Adafruit_24bargraph(&i2c_left);
ddrew73 4:5d27966f93e4 19
ddrew73 7:7fbe8dc5e4fa 20 I2C i2c_right(D5,D4);
ddrew73 7:7fbe8dc5e4fa 21 Adafruit_24bargraph ledbar_right=Adafruit_24bargraph(&i2c_right);
ddrew73 4:5d27966f93e4 22
ddrew73 0:16d2619002d7 23 DebounceIn upbutton(D9);
ddrew73 0:16d2619002d7 24 DebounceIn downbutton(D8);
ddrew73 7:7fbe8dc5e4fa 25 DebounceIn leftbutton(D3);
ddrew73 7:7fbe8dc5e4fa 26 DebounceIn rightbutton(D2);
ddrew73 0:16d2619002d7 27
ddrew73 0:16d2619002d7 28 //Scanner stuff
ddrew73 0:16d2619002d7 29
ddrew73 0:16d2619002d7 30 DebounceIn scanbutton(D10);
ddrew73 0:16d2619002d7 31
ddrew73 0:16d2619002d7 32 DigitalOut A_in(D0);
ddrew73 0:16d2619002d7 33 DigitalOut B_in(D1);
ddrew73 0:16d2619002d7 34 DigitalOut C_in(D2);
fil 6:d0a1eba7f943 35 DigitalOut D_in(D3);
fil 6:d0a1eba7f943 36 DigitalOut E_in(D4);
fil 6:d0a1eba7f943 37 DigitalOut F_in(D5);
ddrew73 0:16d2619002d7 38
ddrew73 0:16d2619002d7 39 DigitalOut A_out(PTC7);
ddrew73 0:16d2619002d7 40 DigitalOut B_out(PTC0);
ddrew73 0:16d2619002d7 41 DigitalOut C_out(PTC3);
ddrew73 0:16d2619002d7 42
ddrew73 0:16d2619002d7 43 AnalogOut dac(PTE30);
ddrew73 0:16d2619002d7 44 AnalogIn adc(PTB0);
ddrew73 0:16d2619002d7 45
ddrew73 8:725d938b301b 46
ddrew73 0:16d2619002d7 47
ddrew73 0:16d2619002d7 48
ddrew73 0:16d2619002d7 49 //LCD stuff
ddrew73 1:0183a7d38878 50 TextLCD lcd(D13,D12,PTA17,PTA16,PTC17,PTC16,TextLCD::LCD20x4);
ddrew73 0:16d2619002d7 51
jn80842 3:161fed8bd027 52 // cc3000 KL25Z wifi connection
jn80842 3:161fed8bd027 53 // we need to define connection pins for:
jn80842 3:161fed8bd027 54 // - IRQ => (pin D3)
jn80842 3:161fed8bd027 55 // - Enable => (pin D5)
jn80842 3:161fed8bd027 56 // - SPI CS => (pin D10)
jn80842 3:161fed8bd027 57 // - SPI MOSI => (pin D11)
jn80842 3:161fed8bd027 58 // - SPI MISO => (pin D12)
jn80842 3:161fed8bd027 59 // - SPI CLK => (pin D13)
jn80842 3:161fed8bd027 60 // plus wifi network SSID, password, security level and smart-configuration flag.
jn80842 3:161fed8bd027 61
jn80842 3:161fed8bd027 62 mbed_cc3000::cc3000 wifi(D3, D5, D10, SPI(D11, D12, D13),
jn80842 3:161fed8bd027 63 "SSID", "PASSWORD", WPA2, false);
jn80842 3:161fed8bd027 64 Websocket ws("ws://sockets.mbed.org/ws/toastboard/rw");
jn80842 3:161fed8bd027 65
jn80842 12:c4b046975527 66 // json encoding
jn80842 12:c4b046975527 67 std::string s;
jn80842 12:c4b046975527 68 std::string t;
jn80842 12:c4b046975527 69 std::back_insert_iterator<std::string> json_str = std::back_inserter(t);
jn80842 12:c4b046975527 70 char row[1] = ""; // holder for row tokens
jn80842 12:c4b046975527 71 char rowvoltage[4] = ""; // holder for voltage values
jn80842 12:c4b046975527 72
jn80842 12:c4b046975527 73 void jsoncopy(const std::string& s, std::back_insert_iterator<std::string> oi) {
jn80842 12:c4b046975527 74 std::copy(s.begin(), s.end(), oi);
jn80842 12:c4b046975527 75 }
jn80842 12:c4b046975527 76
jn80842 12:c4b046975527 77 void add_to_json(const std::string& s, std::back_insert_iterator<std::string> oi) {
jn80842 12:c4b046975527 78 // this chunk of code lifted from the MbedJSONValue library
jn80842 12:c4b046975527 79 for (std::string::const_iterator i = s.begin(); i != s.end(); ++i) {
jn80842 12:c4b046975527 80 switch (*i) {
jn80842 12:c4b046975527 81 #define MAP(val, sym) case val: jsoncopy(sym, oi); break
jn80842 12:c4b046975527 82 MAP('"', "\\\"");
jn80842 12:c4b046975527 83 MAP('\\', "\\\\");
jn80842 12:c4b046975527 84 MAP('/', "\\/");
jn80842 12:c4b046975527 85 MAP('\b', "\\b");
jn80842 12:c4b046975527 86 MAP('\f', "\\f");
jn80842 12:c4b046975527 87 MAP('\n', "\\n");
jn80842 12:c4b046975527 88 MAP('\r', "\\r");
jn80842 12:c4b046975527 89 MAP('\t', "\\t");
jn80842 12:c4b046975527 90 #undef MAP
jn80842 12:c4b046975527 91 default:
jn80842 12:c4b046975527 92 if ((unsigned char)*i < 0x20 || *i == 0x7f) {
jn80842 12:c4b046975527 93 char buf[7];
jn80842 12:c4b046975527 94 sprintf(buf, "\\u%04x", *i & 0xff);
jn80842 12:c4b046975527 95 copy(buf, buf + 6, oi);
jn80842 12:c4b046975527 96 } else {
jn80842 12:c4b046975527 97 *oi++ = *i;
jn80842 12:c4b046975527 98 }
jn80842 12:c4b046975527 99 break;
jn80842 12:c4b046975527 100 }
jn80842 12:c4b046975527 101 }
jn80842 12:c4b046975527 102 }
jn80842 12:c4b046975527 103
ddrew73 7:7fbe8dc5e4fa 104
ddrew73 0:16d2619002d7 105 int main()
ddrew73 0:16d2619002d7 106 {
ddrew73 0:16d2619002d7 107
ddrew73 0:16d2619002d7 108 //Scan init
ddrew73 7:7fbe8dc5e4fa 109
ddrew73 4:5d27966f93e4 110 int con_mat[24][2] = {};
ddrew73 4:5d27966f93e4 111 float volt_mat[24][2] = {};
ddrew73 7:7fbe8dc5e4fa 112 float clientdata[48] = {};
ddrew73 7:7fbe8dc5e4fa 113 float rowval = 0, vddval = 0;
ddrew73 0:16d2619002d7 114
ddrew73 0:16d2619002d7 115 //LED init
ddrew73 7:7fbe8dc5e4fa 116 int rowselect = 0, moved = 1, colselect = 0, selected = 0;
ddrew73 4:5d27966f93e4 117 ledbar_left.begin(0x70);
ddrew73 4:5d27966f93e4 118 ledbar_left.clear();
ddrew73 4:5d27966f93e4 119 ledbar_left.writeDisplay();
ddrew73 5:03d75ad40d5e 120
ddrew73 4:5d27966f93e4 121 ledbar_right.begin(0x70);
ddrew73 4:5d27966f93e4 122 ledbar_right.clear();
ddrew73 4:5d27966f93e4 123 ledbar_right.writeDisplay();
ddrew73 0:16d2619002d7 124
ddrew73 0:16d2619002d7 125 //LCD init
ddrew73 0:16d2619002d7 126 lcd.cls();
ddrew73 0:16d2619002d7 127
ddrew73 0:16d2619002d7 128
ddrew73 0:16d2619002d7 129 while(1) {
ddrew73 5:03d75ad40d5e 130
ddrew73 0:16d2619002d7 131 //Display
ddrew73 0:16d2619002d7 132
ddrew73 4:5d27966f93e4 133 if (colselect == 0) {
ddrew73 5:03d75ad40d5e 134 ledbar_left.clear();
ddrew73 5:03d75ad40d5e 135 ledbar_right.clear();
ddrew73 5:03d75ad40d5e 136 ledbar_left.setBar(rowselect,LED_GREEN);
ddrew73 5:03d75ad40d5e 137 ledbar_left.writeDisplay();
ddrew73 5:03d75ad40d5e 138 ledbar_right.writeDisplay();
ddrew73 7:7fbe8dc5e4fa 139 }
ddrew73 7:7fbe8dc5e4fa 140 else {
ddrew73 8:725d938b301b 141 ledbar_left.clear();
ddrew73 5:03d75ad40d5e 142 ledbar_right.clear();
ddrew73 4:5d27966f93e4 143 ledbar_right.setBar(rowselect,LED_GREEN);
ddrew73 4:5d27966f93e4 144 ledbar_right.writeDisplay();
ddrew73 4:5d27966f93e4 145 ledbar_left.writeDisplay();
ddrew73 7:7fbe8dc5e4fa 146 }
ddrew73 0:16d2619002d7 147 //Moving the selected row
ddrew73 0:16d2619002d7 148 if (upbutton.read() == 0) {
ddrew73 7:7fbe8dc5e4fa 149
ddrew73 0:16d2619002d7 150 rowselect = rowselect-1;
ddrew73 0:16d2619002d7 151 moved = 1;
ddrew73 0:16d2619002d7 152 wait(0.75);
ddrew73 0:16d2619002d7 153 }
ddrew73 0:16d2619002d7 154
ddrew73 0:16d2619002d7 155 if (downbutton.read() == 0) {
ddrew73 7:7fbe8dc5e4fa 156
ddrew73 0:16d2619002d7 157 rowselect = rowselect+1;
ddrew73 0:16d2619002d7 158 moved = 1;
ddrew73 0:16d2619002d7 159 wait(0.75);
ddrew73 0:16d2619002d7 160 }
ddrew73 5:03d75ad40d5e 161
ddrew73 4:5d27966f93e4 162 if (leftbutton.read() == 0) {
ddrew73 4:5d27966f93e4 163 colselect = 0;
ddrew73 5:03d75ad40d5e 164 ledbar_right.clear();
ddrew73 5:03d75ad40d5e 165 moved =1;
ddrew73 4:5d27966f93e4 166 wait(0.75);
ddrew73 7:7fbe8dc5e4fa 167
ddrew73 4:5d27966f93e4 168 }
ddrew73 5:03d75ad40d5e 169
ddrew73 4:5d27966f93e4 170 if (rightbutton.read() == 0) {
ddrew73 4:5d27966f93e4 171 colselect = 1;
ddrew73 5:03d75ad40d5e 172 ledbar_left.clear();
ddrew73 5:03d75ad40d5e 173 moved =1;
ddrew73 4:5d27966f93e4 174 wait(0.75);
ddrew73 7:7fbe8dc5e4fa 175
ddrew73 7:7fbe8dc5e4fa 176
ddrew73 5:03d75ad40d5e 177 }
ddrew73 0:16d2619002d7 178
ddrew73 0:16d2619002d7 179 //Boundary checking
ddrew73 0:16d2619002d7 180 if (rowselect > 23) {
ddrew73 0:16d2619002d7 181 rowselect = 23;
ddrew73 0:16d2619002d7 182 }
ddrew73 0:16d2619002d7 183 if (rowselect < 0) {
ddrew73 0:16d2619002d7 184 rowselect = 0;
ddrew73 0:16d2619002d7 185 }
ddrew73 0:16d2619002d7 186
ddrew73 0:16d2619002d7 187 //Implementing scanning
ddrew73 0:16d2619002d7 188
ddrew73 0:16d2619002d7 189 if (scanbutton.read() == 0) {
ddrew73 7:7fbe8dc5e4fa 190 A_in = 1;
ddrew73 7:7fbe8dc5e4fa 191 B_in = 1;
ddrew73 7:7fbe8dc5e4fa 192 C_in = 1;
ddrew73 7:7fbe8dc5e4fa 193 D_in = 1;
ddrew73 7:7fbe8dc5e4fa 194 E_in = 1;
ddrew73 7:7fbe8dc5e4fa 195 F_in = 1;
fil 6:d0a1eba7f943 196
ddrew73 7:7fbe8dc5e4fa 197 vddval = adc.read();
ddrew73 0:16d2619002d7 198
ddrew73 7:7fbe8dc5e4fa 199 //SET MULTIPLEXER TO READ SELECTED ROW
ddrew73 7:7fbe8dc5e4fa 200 // Sample the 'selected' node
fil 6:d0a1eba7f943 201
ddrew73 7:7fbe8dc5e4fa 202 int sn = (colselect + 1)*(rowselect + 1);
ddrew73 7:7fbe8dc5e4fa 203 A_in = (sn-1)&2;
ddrew73 7:7fbe8dc5e4fa 204 B_in = ((sn-1)/2)%2;
ddrew73 7:7fbe8dc5e4fa 205 C_in = ((sn-1)/4)%2;
ddrew73 7:7fbe8dc5e4fa 206 D_in = ((sn-1)/8)%2;
ddrew73 7:7fbe8dc5e4fa 207 E_in = ((sn-1)/16)%2;
ddrew73 7:7fbe8dc5e4fa 208 F_in = ((sn-1)/32)%2;
ddrew73 7:7fbe8dc5e4fa 209 rowval = adc.read();
ddrew73 1:0183a7d38878 210
ddrew73 7:7fbe8dc5e4fa 211 ledbar_left.clear();
ddrew73 7:7fbe8dc5e4fa 212 ledbar_right.clear();
ddrew73 1:0183a7d38878 213
ddrew73 7:7fbe8dc5e4fa 214 for (int x = 0; x < 2; x++) {
ddrew73 7:7fbe8dc5e4fa 215 for (int y = 0; y < 24; y++) {
ddrew73 7:7fbe8dc5e4fa 216 int sn = (colselect+1)*(rowselect+1);
ddrew73 7:7fbe8dc5e4fa 217 A_in = (sn-1)&2;
ddrew73 7:7fbe8dc5e4fa 218 B_in = ((sn-1)/2)%2;
ddrew73 7:7fbe8dc5e4fa 219 C_in = ((sn-1)/4)%2;
ddrew73 7:7fbe8dc5e4fa 220 D_in = ((sn-1)/8)%2;
ddrew73 7:7fbe8dc5e4fa 221 E_in = ((sn-1)/16)%2;
ddrew73 7:7fbe8dc5e4fa 222 F_in = ((sn-1)/32)%2;
ddrew73 0:16d2619002d7 223
ddrew73 7:7fbe8dc5e4fa 224 float in_val = adc.read();
ddrew73 7:7fbe8dc5e4fa 225 volt_mat[x][y] = in_val;
fil 6:d0a1eba7f943 226
ddrew73 7:7fbe8dc5e4fa 227 if (x == 1){
ddrew73 7:7fbe8dc5e4fa 228 int z = y+24;
ddrew73 7:7fbe8dc5e4fa 229 clientdata[z] = in_val;
fil 6:d0a1eba7f943 230 }
fil 6:d0a1eba7f943 231 else {
ddrew73 7:7fbe8dc5e4fa 232 clientdata[y] = in_val;
ddrew73 7:7fbe8dc5e4fa 233 }
ddrew73 7:7fbe8dc5e4fa 234
ddrew73 7:7fbe8dc5e4fa 235
ddrew73 7:7fbe8dc5e4fa 236 if ((in_val > vddval-0.01) && (in_val < vddval+0.01)) {
ddrew73 7:7fbe8dc5e4fa 237 con_mat[x][y] = 2;
ddrew73 7:7fbe8dc5e4fa 238 if (x == 0) {
ddrew73 7:7fbe8dc5e4fa 239 ledbar_left.setBar(y,LED_RED);
ddrew73 7:7fbe8dc5e4fa 240 } else {
ddrew73 7:7fbe8dc5e4fa 241 ledbar_right.setBar(y,LED_RED);
ddrew73 7:7fbe8dc5e4fa 242 }
ddrew73 7:7fbe8dc5e4fa 243 }
ddrew73 7:7fbe8dc5e4fa 244 else if (in_val == 0) {
ddrew73 7:7fbe8dc5e4fa 245 con_mat[x][y] = 3;
ddrew73 7:7fbe8dc5e4fa 246 if (x == 0) {
ddrew73 7:7fbe8dc5e4fa 247 ledbar_left.setBar(y,LED_YELLOW);
ddrew73 7:7fbe8dc5e4fa 248 } else {
ddrew73 7:7fbe8dc5e4fa 249 ledbar_right.setBar(y,LED_YELLOW);
ddrew73 7:7fbe8dc5e4fa 250 }
ddrew73 7:7fbe8dc5e4fa 251 }
ddrew73 7:7fbe8dc5e4fa 252 else if ((in_val > rowval-0.01) && (in_val < rowval+0.01)) {
ddrew73 7:7fbe8dc5e4fa 253 con_mat[x][y] = 1;
ddrew73 7:7fbe8dc5e4fa 254 if (x == 0) {
ddrew73 7:7fbe8dc5e4fa 255 ledbar_left.setBar(y,LED_GREEN);
ddrew73 7:7fbe8dc5e4fa 256 } else {
ddrew73 7:7fbe8dc5e4fa 257 ledbar_right.setBar(y,LED_GREEN);
ddrew73 7:7fbe8dc5e4fa 258 }
ddrew73 7:7fbe8dc5e4fa 259 }
ddrew73 7:7fbe8dc5e4fa 260 else {
ddrew73 7:7fbe8dc5e4fa 261 con_mat[x][y] = 0;
fil 6:d0a1eba7f943 262 }
ddrew73 7:7fbe8dc5e4fa 263
ddrew73 7:7fbe8dc5e4fa 264
ddrew73 7:7fbe8dc5e4fa 265 } } //END OF ROWSCAN FOR LOOP
ddrew73 7:7fbe8dc5e4fa 266
ddrew73 7:7fbe8dc5e4fa 267 //STUFF INTO JSON FORMAT
jn80842 12:c4b046975527 268 add_to_json("{\"vddval\":",json_str);
jn80842 12:c4b046975527 269 sprintf(rowvoltage,"%.f",vddval);
jn80842 12:c4b046975527 270 add_to_json(rowvoltage,json_str);
jn80842 12:c4b046975527 271 add_to_json(", \"selected\":",json_str);
jn80842 12:c4b046975527 272 selected = rowselect;
jn80842 12:c4b046975527 273 if (colselect == 1){
jn80842 12:c4b046975527 274 selected = selected+24;
jn80842 12:c4b046975527 275 }
jn80842 12:c4b046975527 276 sprintf(rowvoltage,"%d",selected);
jn80842 12:c4b046975527 277 add_to_json(", \"rows\": [",json_str);
jn80842 12:c4b046975527 278
ddrew73 7:7fbe8dc5e4fa 279 char str[1];
ddrew73 7:7fbe8dc5e4fa 280 for (int i= 0; i < 48; i++) {
jn80842 12:c4b046975527 281 if (i != 0) {
jn80842 12:c4b046975527 282 add_to_json(",",json_str);
ddrew73 7:7fbe8dc5e4fa 283 }
jn80842 12:c4b046975527 284 add_to_json("{\"",json_str);
jn80842 12:c4b046975527 285 sprintf(str, "%d", i);
jn80842 12:c4b046975527 286 add_to_json(str,json_str);
jn80842 12:c4b046975527 287 add_to_json("\":",json_str);
jn80842 12:c4b046975527 288 sprintf(rowvoltage,"%.f",clientdata[i]);
jn80842 12:c4b046975527 289 add_to_json(rowvoltage,json_str);
jn80842 12:c4b046975527 290 add_to_json("}",json_str);
jn80842 12:c4b046975527 291 }
ddrew73 7:7fbe8dc5e4fa 292
ddrew73 7:7fbe8dc5e4fa 293
ddrew73 7:7fbe8dc5e4fa 294 moved = 0;
ddrew73 7:7fbe8dc5e4fa 295
ddrew73 8:725d938b301b 296 //DEBUGGING TOOLS //////////////
ddrew73 8:725d938b301b 297 pc.printf("\n%1.3f %1.3f \n", vddval, rowval);
ddrew73 8:725d938b301b 298 for (int i = 0; i<48; i++){
ddrew73 8:725d938b301b 299 pc.printf(" %1.3f ", clientdata[i]);
ddrew73 8:725d938b301b 300 }
ddrew73 8:725d938b301b 301 pc.printf(" \n \n ");
ddrew73 8:725d938b301b 302 for (int x = 0; x < 2; x++) {
ddrew73 8:725d938b301b 303 for (int y = 0; y < 24; y++) {
ddrew73 8:725d938b301b 304 pc.printf("%1.3f \n", volt_mat[x][y]);
ddrew73 8:725d938b301b 305 }}
ddrew73 8:725d938b301b 306 ////////////////////////
ddrew73 8:725d938b301b 307
ddrew73 8:725d938b301b 308
ddrew73 7:7fbe8dc5e4fa 309 wait(2); //THIS NEEDS TO GO AWAY! :}
ddrew73 7:7fbe8dc5e4fa 310
ddrew73 7:7fbe8dc5e4fa 311 } // END OF SCANBUTTON IF STATEMENT
ddrew73 7:7fbe8dc5e4fa 312
ddrew73 7:7fbe8dc5e4fa 313 if (moved==0) {
ddrew73 7:7fbe8dc5e4fa 314 ledbar_left.writeDisplay();
ddrew73 7:7fbe8dc5e4fa 315 ledbar_right.writeDisplay();
ddrew73 7:7fbe8dc5e4fa 316 lcd.cls();
ddrew73 7:7fbe8dc5e4fa 317 lcd.locate(0,1);
ddrew73 7:7fbe8dc5e4fa 318 lcd.printf("Vdd: %1.1f V",vddval);
ddrew73 7:7fbe8dc5e4fa 319 lcd.locate(0,0);
ddrew73 7:7fbe8dc5e4fa 320 lcd.printf("Row %d: %1.1f V",selected,rowval);
ddrew73 7:7fbe8dc5e4fa 321 }
fil 6:d0a1eba7f943 322 else {
ddrew73 7:7fbe8dc5e4fa 323 lcd.cls();
ddrew73 7:7fbe8dc5e4fa 324 string programname = "The ToastBoard";
ddrew73 7:7fbe8dc5e4fa 325 string instructions = "Select a row and scan";
ddrew73 7:7fbe8dc5e4fa 326 lcd.locate(0,0);
ddrew73 7:7fbe8dc5e4fa 327 lcd.printf("%s",programname.c_str());
ddrew73 7:7fbe8dc5e4fa 328 lcd.locate(0,1);
ddrew73 7:7fbe8dc5e4fa 329 lcd.printf("%s",instructions.c_str());
ddrew73 7:7fbe8dc5e4fa 330 }
ddrew73 5:03d75ad40d5e 331
ddrew73 5:03d75ad40d5e 332
ddrew73 5:03d75ad40d5e 333
ddrew73 5:03d75ad40d5e 334
ddrew73 4:5d27966f93e4 335
ddrew73 7:7fbe8dc5e4fa 336
ddrew73 7:7fbe8dc5e4fa 337
ddrew73 7:7fbe8dc5e4fa 338
ddrew73 0:16d2619002d7 339
ddrew73 0:16d2619002d7 340
ddrew73 4:5d27966f93e4 341
ddrew73 4:5d27966f93e4 342
ddrew73 4:5d27966f93e4 343
ddrew73 7:7fbe8dc5e4fa 344 } // END OF WHILE(1)
ddrew73 7:7fbe8dc5e4fa 345
ddrew73 7:7fbe8dc5e4fa 346
ddrew73 7:7fbe8dc5e4fa 347
ddrew73 4:5d27966f93e4 348
ddrew73 7:7fbe8dc5e4fa 349 } // END OF INT MAIN
ddrew73 7:7fbe8dc5e4fa 350
ddrew73 7:7fbe8dc5e4fa 351
ddrew73 8:725d938b301b 352 /*
ddrew73 8:725d938b301b 353 FLOAT NODE CHECKER
ddrew73 8:725d938b301b 354 add another "for" around the two for the 48 row checker:
ddrew73 8:725d938b301b 355
ddrew73 8:725d938b301b 356 if (u == 0){
ddrew73 8:725d938b301b 357 old_volt_map[x,y] = in_val
ddrew73 8:725d938b301b 358 }
ddrew73 8:725d938b301b 359 else{
ddrew73 8:725d938b301b 360 volt_map[x,y] = in_val
ddrew73 8:725d938b301b 361 if (old_volt_map[x,y] != volt_map[x,y] ) {
ddrew73 8:725d938b301b 362 volt_map[x,y] = 100;
ddrew73 8:725d938b301b 363 }
ddrew73 8:725d938b301b 364
ddrew73 8:725d938b301b 365 PUT ALL ROW LIGHTING (CON_MAT) STUFF HERE
ddrew73 8:725d938b301b 366 }
ddrew73 8:725d938b301b 367
ddrew73 8:725d938b301b 368 */
ddrew73 8:725d938b301b 369
ddrew73 8:725d938b301b 370 /*
ddrew73 8:725d938b301b 371 OSCILLISCOPE
ddrew73 7:7fbe8dc5e4fa 372
ddrew73 7:7fbe8dc5e4fa 373
ddrew73 8:725d938b301b 374 while (scanbutton == 0){
ddrew73 8:725d938b301b 375 if (loopcount = 0){
ddrew73 8:725d938b301b 376 timer.reset();
ddrew73 8:725d938b301b 377 timer.start();
ddrew73 8:725d938b301b 378 begintime = timer.read_ms();
ddrew73 8:725d938b301b 379 pressed == 1;
ddrew73 8:725d938b301b 380 }
ddrew73 7:7fbe8dc5e4fa 381
ddrew73 8:725d938b301b 382 ADD VOLTAGE TO OSCI BUFFER
ddrew73 7:7fbe8dc5e4fa 383
ddrew73 8:725d938b301b 384 loopcount = loopcount +1;
ddrew73 8:725d938b301b 385 } // BREAK THE WHILE SCANBUTTON
ddrew73 8:725d938b301b 386
ddrew73 8:725d938b301b 387 if (pressed == 1){
ddrew73 8:725d938b301b 388 timer.stop();
ddrew73 8:725d938b301b 389 endtime = timer.read_ms();
ddrew73 8:725d938b301b 390
ddrew73 8:725d938b301b 391 DO ENTIRE SCAN STUFF
ddrew73 8:725d938b301b 392
ddrew73 8:725d938b301b 393 pressed = 0;
ddrew73 8:725d938b301b 394 }
ddrew73 8:725d938b301b 395
ddrew73 8:725d938b301b 396 */