:)

Dependencies:   MbedJSONValue DebounceIn TextLCD USBDevice mbed WebSocketClient cc3000_hostdriver_mbedsocket Adafruit_LEDBackpack_2

Committer:
ddrew73
Date:
Tue Dec 02 23:25:02 2014 +0000
Revision:
11:b520586dc0a1
Parent:
10:cfd60b63ed11
Child:
13:209da1dcb6e1
Float checker implemented (not checked);

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