:)
Dependencies: MbedJSONValue DebounceIn TextLCD USBDevice mbed WebSocketClient cc3000_hostdriver_mbedsocket Adafruit_LEDBackpack_2
main.cpp@6:d0a1eba7f943, 2014-11-25 (annotated)
- Committer:
- fil
- Date:
- Tue Nov 25 23:56:23 2014 +0000
- Revision:
- 6:d0a1eba7f943
- Parent:
- 5:03d75ad40d5e
- Child:
- 7:7fbe8dc5e4fa
Included 24x2 to multiplexer address decoding.
Who changed what in which revision?
User | Revision | Line number | New 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" |
ddrew73 | 0:16d2619002d7 | 7 | #include "USBKeyboard.h" |
jn80842 | 3:161fed8bd027 | 8 | #include "cc3000.h" |
jn80842 | 3:161fed8bd027 | 9 | #include "Websocket.h" |
jn80842 | 3:161fed8bd027 | 10 | #include "MbedJSONValue.h" |
ddrew73 | 0:16d2619002d7 | 11 | |
ddrew73 | 0:16d2619002d7 | 12 | //LED stuff |
ddrew73 | 0:16d2619002d7 | 13 | I2C i2c(D7,D6); |
ddrew73 | 4:5d27966f93e4 | 14 | Adafruit_24bargraph ledbar_left=Adafruit_24bargraph(&i2c); |
ddrew73 | 4:5d27966f93e4 | 15 | |
ddrew73 | 5:03d75ad40d5e | 16 | I2C i2c(D7,D6); |
ddrew73 | 5:03d75ad40d5e | 17 | Adafruit_24bargraph ledbar_right=Adafruit_24bargraph(&i2c); |
ddrew73 | 4:5d27966f93e4 | 18 | |
ddrew73 | 0:16d2619002d7 | 19 | DebounceIn upbutton(D9); |
ddrew73 | 0:16d2619002d7 | 20 | DebounceIn downbutton(D8); |
ddrew73 | 5:03d75ad40d5e | 21 | DebounceIn leftbutton( ); |
ddrew73 | 5:03d75ad40d5e | 22 | DebounceIn rightbutton( ); |
ddrew73 | 0:16d2619002d7 | 23 | |
ddrew73 | 0:16d2619002d7 | 24 | //Scanner stuff |
ddrew73 | 0:16d2619002d7 | 25 | |
ddrew73 | 0:16d2619002d7 | 26 | DebounceIn scanbutton(D10); |
ddrew73 | 0:16d2619002d7 | 27 | |
ddrew73 | 0:16d2619002d7 | 28 | DigitalOut A_in(D0); |
ddrew73 | 0:16d2619002d7 | 29 | DigitalOut B_in(D1); |
ddrew73 | 0:16d2619002d7 | 30 | DigitalOut C_in(D2); |
fil | 6:d0a1eba7f943 | 31 | DigitalOut D_in(D3); |
fil | 6:d0a1eba7f943 | 32 | DigitalOut E_in(D4); |
fil | 6:d0a1eba7f943 | 33 | DigitalOut F_in(D5); |
ddrew73 | 0:16d2619002d7 | 34 | |
ddrew73 | 0:16d2619002d7 | 35 | DigitalOut A_out(PTC7); |
ddrew73 | 0:16d2619002d7 | 36 | DigitalOut B_out(PTC0); |
ddrew73 | 0:16d2619002d7 | 37 | DigitalOut C_out(PTC3); |
ddrew73 | 0:16d2619002d7 | 38 | |
ddrew73 | 0:16d2619002d7 | 39 | AnalogOut dac(PTE30); |
ddrew73 | 0:16d2619002d7 | 40 | AnalogIn adc(PTB0); |
ddrew73 | 0:16d2619002d7 | 41 | |
ddrew73 | 0:16d2619002d7 | 42 | //USBKeyboard keyboard; |
ddrew73 | 0:16d2619002d7 | 43 | |
ddrew73 | 0:16d2619002d7 | 44 | |
ddrew73 | 0:16d2619002d7 | 45 | //LCD stuff |
ddrew73 | 1:0183a7d38878 | 46 | TextLCD lcd(D13,D12,PTA17,PTA16,PTC17,PTC16,TextLCD::LCD20x4); |
ddrew73 | 0:16d2619002d7 | 47 | |
jn80842 | 3:161fed8bd027 | 48 | // cc3000 KL25Z wifi connection |
jn80842 | 3:161fed8bd027 | 49 | // we need to define connection pins for: |
jn80842 | 3:161fed8bd027 | 50 | // - IRQ => (pin D3) |
jn80842 | 3:161fed8bd027 | 51 | // - Enable => (pin D5) |
jn80842 | 3:161fed8bd027 | 52 | // - SPI CS => (pin D10) |
jn80842 | 3:161fed8bd027 | 53 | // - SPI MOSI => (pin D11) |
jn80842 | 3:161fed8bd027 | 54 | // - SPI MISO => (pin D12) |
jn80842 | 3:161fed8bd027 | 55 | // - SPI CLK => (pin D13) |
jn80842 | 3:161fed8bd027 | 56 | // plus wifi network SSID, password, security level and smart-configuration flag. |
jn80842 | 3:161fed8bd027 | 57 | |
jn80842 | 3:161fed8bd027 | 58 | mbed_cc3000::cc3000 wifi(D3, D5, D10, SPI(D11, D12, D13), |
jn80842 | 3:161fed8bd027 | 59 | "SSID", "PASSWORD", WPA2, false); |
jn80842 | 3:161fed8bd027 | 60 | Websocket ws("ws://sockets.mbed.org/ws/toastboard/rw"); |
jn80842 | 3:161fed8bd027 | 61 | |
ddrew73 | 0:16d2619002d7 | 62 | int main() |
ddrew73 | 0:16d2619002d7 | 63 | { |
ddrew73 | 0:16d2619002d7 | 64 | |
ddrew73 | 0:16d2619002d7 | 65 | //Scan init |
ddrew73 | 0:16d2619002d7 | 66 | |
ddrew73 | 0:16d2619002d7 | 67 | float test_val = .001; |
ddrew73 | 1:0183a7d38878 | 68 | float row_volt = 0; |
ddrew73 | 4:5d27966f93e4 | 69 | int con_mat[24][2] = {}; |
ddrew73 | 0:16d2619002d7 | 70 | int a1,b1,c1,a2,b2,c2; |
ddrew73 | 4:5d27966f93e4 | 71 | float volt_mat[24][2] = {}; |
ddrew73 | 0:16d2619002d7 | 72 | //dac = test_val; |
ddrew73 | 0:16d2619002d7 | 73 | |
ddrew73 | 0:16d2619002d7 | 74 | |
ddrew73 | 0:16d2619002d7 | 75 | //LED init |
ddrew73 | 4:5d27966f93e4 | 76 | int redcount = 0, greencount = 0, rowselect = 0, rowselect_old = 0, moved = 1, colselect = 0; |
ddrew73 | 4:5d27966f93e4 | 77 | ledbar_left.begin(0x70); |
ddrew73 | 4:5d27966f93e4 | 78 | ledbar_left.clear(); |
ddrew73 | 4:5d27966f93e4 | 79 | ledbar_left.writeDisplay(); |
ddrew73 | 5:03d75ad40d5e | 80 | |
ddrew73 | 4:5d27966f93e4 | 81 | ledbar_right.begin(0x70); |
ddrew73 | 4:5d27966f93e4 | 82 | ledbar_right.clear(); |
ddrew73 | 4:5d27966f93e4 | 83 | ledbar_right.writeDisplay(); |
ddrew73 | 0:16d2619002d7 | 84 | |
ddrew73 | 0:16d2619002d7 | 85 | //LCD init |
ddrew73 | 0:16d2619002d7 | 86 | lcd.cls(); |
ddrew73 | 1:0183a7d38878 | 87 | string programname = "Dan's UI Test"; |
ddrew73 | 0:16d2619002d7 | 88 | |
ddrew73 | 1:0183a7d38878 | 89 | lcd.printf("%s",programname.c_str()); |
ddrew73 | 0:16d2619002d7 | 90 | |
ddrew73 | 0:16d2619002d7 | 91 | while(1) { |
ddrew73 | 5:03d75ad40d5e | 92 | |
ddrew73 | 0:16d2619002d7 | 93 | //Display |
ddrew73 | 0:16d2619002d7 | 94 | |
ddrew73 | 4:5d27966f93e4 | 95 | if (colselect == 0) { |
ddrew73 | 5:03d75ad40d5e | 96 | ledbar_left.clear(); |
ddrew73 | 5:03d75ad40d5e | 97 | ledbar_right.clear(); |
ddrew73 | 5:03d75ad40d5e | 98 | ledbar_left.setBar(rowselect,LED_GREEN); |
ddrew73 | 5:03d75ad40d5e | 99 | ledbar_left.writeDisplay(); |
ddrew73 | 5:03d75ad40d5e | 100 | ledbar_right.writeDisplay(); |
ddrew73 | 5:03d75ad40d5e | 101 | } else |
ddrew73 | 5:03d75ad40d5e | 102 | ledbar_left.clear(); |
ddrew73 | 5:03d75ad40d5e | 103 | ledbar_right.clear(); |
ddrew73 | 4:5d27966f93e4 | 104 | ledbar_right.setBar(rowselect,LED_GREEN); |
ddrew73 | 4:5d27966f93e4 | 105 | ledbar_right.writeDisplay(); |
ddrew73 | 4:5d27966f93e4 | 106 | ledbar_left.writeDisplay(); |
ddrew73 | 0:16d2619002d7 | 107 | |
ddrew73 | 0:16d2619002d7 | 108 | //Moving the selected row |
ddrew73 | 0:16d2619002d7 | 109 | if (upbutton.read() == 0) { |
ddrew73 | 0:16d2619002d7 | 110 | rowselect_old = rowselect; |
ddrew73 | 0:16d2619002d7 | 111 | rowselect = rowselect-1; |
ddrew73 | 0:16d2619002d7 | 112 | moved = 1; |
ddrew73 | 0:16d2619002d7 | 113 | wait(0.75); |
ddrew73 | 0:16d2619002d7 | 114 | } |
ddrew73 | 0:16d2619002d7 | 115 | |
ddrew73 | 0:16d2619002d7 | 116 | if (downbutton.read() == 0) { |
ddrew73 | 0:16d2619002d7 | 117 | rowselect_old = rowselect; |
ddrew73 | 0:16d2619002d7 | 118 | rowselect = rowselect+1; |
ddrew73 | 0:16d2619002d7 | 119 | moved = 1; |
ddrew73 | 0:16d2619002d7 | 120 | wait(0.75); |
ddrew73 | 0:16d2619002d7 | 121 | } |
ddrew73 | 5:03d75ad40d5e | 122 | |
ddrew73 | 4:5d27966f93e4 | 123 | if (leftbutton.read() == 0) { |
ddrew73 | 4:5d27966f93e4 | 124 | colselect = 0; |
ddrew73 | 5:03d75ad40d5e | 125 | ledbar_right.clear(); |
ddrew73 | 5:03d75ad40d5e | 126 | moved =1; |
ddrew73 | 4:5d27966f93e4 | 127 | wait(0.75); |
ddrew73 | 5:03d75ad40d5e | 128 | |
ddrew73 | 4:5d27966f93e4 | 129 | } |
ddrew73 | 5:03d75ad40d5e | 130 | |
ddrew73 | 4:5d27966f93e4 | 131 | if (rightbutton.read() == 0) { |
ddrew73 | 4:5d27966f93e4 | 132 | colselect = 1; |
ddrew73 | 5:03d75ad40d5e | 133 | ledbar_left.clear(); |
ddrew73 | 5:03d75ad40d5e | 134 | moved =1; |
ddrew73 | 4:5d27966f93e4 | 135 | wait(0.75); |
ddrew73 | 5:03d75ad40d5e | 136 | |
ddrew73 | 5:03d75ad40d5e | 137 | |
ddrew73 | 5:03d75ad40d5e | 138 | } |
ddrew73 | 0:16d2619002d7 | 139 | |
ddrew73 | 0:16d2619002d7 | 140 | //Boundary checking |
ddrew73 | 0:16d2619002d7 | 141 | if (rowselect > 23) { |
ddrew73 | 0:16d2619002d7 | 142 | rowselect = 23; |
ddrew73 | 0:16d2619002d7 | 143 | } |
ddrew73 | 0:16d2619002d7 | 144 | if (rowselect < 0) { |
ddrew73 | 0:16d2619002d7 | 145 | rowselect = 0; |
ddrew73 | 0:16d2619002d7 | 146 | } |
ddrew73 | 0:16d2619002d7 | 147 | |
ddrew73 | 0:16d2619002d7 | 148 | //Implementing scanning |
ddrew73 | 0:16d2619002d7 | 149 | |
ddrew73 | 0:16d2619002d7 | 150 | if (scanbutton.read() == 0) { |
fil | 6:d0a1eba7f943 | 151 | |
fil | 6:d0a1eba7f943 | 152 | // Old mega-scan code. More refined version below |
fil | 6:d0a1eba7f943 | 153 | /* |
ddrew73 | 0:16d2619002d7 | 154 | for (int x = 0; x < 8; x++) { |
ddrew73 | 0:16d2619002d7 | 155 | for (int y = 0; y < 8; y++) { |
ddrew73 | 0:16d2619002d7 | 156 | // Stupid logic to convert count value to binary... |
ddrew73 | 0:16d2619002d7 | 157 | A_in = x%2; |
ddrew73 | 0:16d2619002d7 | 158 | a1 = x%2; |
ddrew73 | 0:16d2619002d7 | 159 | B_in = (x/2)%2; |
ddrew73 | 0:16d2619002d7 | 160 | b1 = (x/2)%2; |
ddrew73 | 0:16d2619002d7 | 161 | C_in = (x/4)%2; |
ddrew73 | 0:16d2619002d7 | 162 | c1 = (x/4)%2; |
ddrew73 | 0:16d2619002d7 | 163 | |
ddrew73 | 0:16d2619002d7 | 164 | A_out = y%2; |
ddrew73 | 0:16d2619002d7 | 165 | int a2 = y%2; |
ddrew73 | 0:16d2619002d7 | 166 | B_out = (y/2)%2; |
ddrew73 | 0:16d2619002d7 | 167 | b2 = (y/2)%2; |
ddrew73 | 0:16d2619002d7 | 168 | C_out = (y/4)%2; |
ddrew73 | 0:16d2619002d7 | 169 | c2 = (y/4)%2; |
ddrew73 | 0:16d2619002d7 | 170 | |
ddrew73 | 0:16d2619002d7 | 171 | // Now we do the scan test, results are stored in con_mat |
ddrew73 | 0:16d2619002d7 | 172 | //wait(0.01); |
ddrew73 | 0:16d2619002d7 | 173 | dac = test_val; |
ddrew73 | 0:16d2619002d7 | 174 | float in_val = adc.read(); |
ddrew73 | 0:16d2619002d7 | 175 | |
ddrew73 | 0:16d2619002d7 | 176 | if ((in_val > .0010) && (in_val < .0025)) |
ddrew73 | 0:16d2619002d7 | 177 | con_mat[x][y] = 1; |
ddrew73 | 0:16d2619002d7 | 178 | else |
ddrew73 | 0:16d2619002d7 | 179 | con_mat[x][y] = 0; |
ddrew73 | 0:16d2619002d7 | 180 | |
ddrew73 | 0:16d2619002d7 | 181 | //keyboard.printf("%f %f \n",dac.read(),in_val); |
ddrew73 | 0:16d2619002d7 | 182 | //keyboard.printf("%d %d %d\n",a2,b2,c2); |
ddrew73 | 0:16d2619002d7 | 183 | } |
ddrew73 | 0:16d2619002d7 | 184 | } |
fil | 6:d0a1eba7f943 | 185 | |
ddrew73 | 1:0183a7d38878 | 186 | for (int x=0;x<8;x++) { |
ddrew73 | 1:0183a7d38878 | 187 | for (int y=0;y<8;y++) { |
ddrew73 | 1:0183a7d38878 | 188 | keyboard.printf("%d ",con_mat[x][y]); |
ddrew73 | 1:0183a7d38878 | 189 | }} |
ddrew73 | 1:0183a7d38878 | 190 | */ |
ddrew73 | 0:16d2619002d7 | 191 | //Displaying all connected rows as red light! |
ddrew73 | 0:16d2619002d7 | 192 | ledbar.clear(); |
ddrew73 | 0:16d2619002d7 | 193 | for (int i=0; i<8; i++) { |
ddrew73 | 0:16d2619002d7 | 194 | if (con_mat[rowselect][i] == 1) { |
ddrew73 | 0:16d2619002d7 | 195 | ledbar.setBar(i,LED_RED); |
ddrew73 | 0:16d2619002d7 | 196 | } |
ddrew73 | 0:16d2619002d7 | 197 | } |
ddrew73 | 0:16d2619002d7 | 198 | ledbar.writeDisplay(); |
ddrew73 | 1:0183a7d38878 | 199 | |
ddrew73 | 1:0183a7d38878 | 200 | float vddmeasure = 3.14259; |
ddrew73 | 1:0183a7d38878 | 201 | float vrowmeasure = 1.1234; |
ddrew73 | 1:0183a7d38878 | 202 | lcd.cls(); |
ddrew73 | 1:0183a7d38878 | 203 | lcd.locate(0,1); |
ddrew73 | 1:0183a7d38878 | 204 | lcd.printf("Vdd: %1.1f V",vddmeasure); |
ddrew73 | 1:0183a7d38878 | 205 | lcd.locate(0,0); |
ddrew73 | 1:0183a7d38878 | 206 | lcd.printf("Row: %1.1f V",vrowmeasure); |
ddrew73 | 1:0183a7d38878 | 207 | |
ddrew73 | 0:16d2619002d7 | 208 | wait(2.5); |
ddrew73 | 0:16d2619002d7 | 209 | ledbar.clear(); |
ddrew73 | 0:16d2619002d7 | 210 | ledbar.writeDisplay(); |
ddrew73 | 1:0183a7d38878 | 211 | lcd.cls(); |
ddrew73 | 1:0183a7d38878 | 212 | string programname = "Dan's UI Test"; |
ddrew73 | 1:0183a7d38878 | 213 | lcd.printf("%s",programname.c_str()); |
ddrew73 | 0:16d2619002d7 | 214 | |
ddrew73 | 0:16d2619002d7 | 215 | } |
ddrew73 | 0:16d2619002d7 | 216 | } |
ddrew73 | 0:16d2619002d7 | 217 | |
ddrew73 | 0:16d2619002d7 | 218 | |
ddrew73 | 0:16d2619002d7 | 219 | |
ddrew73 | 0:16d2619002d7 | 220 | |
ddrew73 | 0:16d2619002d7 | 221 | } |
ddrew73 | 0:16d2619002d7 | 222 | |
ddrew73 | 0:16d2619002d7 | 223 | |
ddrew73 | 4:5d27966f93e4 | 224 | /* |
ddrew73 | 4:5d27966f93e4 | 225 | |
ddrew73 | 5:03d75ad40d5e | 226 | ///// PUT ALL BELOW IN SCAN BUTTON IF //////// |
ddrew73 | 4:5d27966f93e4 | 227 | //Scans rows connected to vdd and ground. Vdd = 2 in con mat, Ground = 3. Rows connected to selected row = 1. |
ddrew73 | 4:5d27966f93e4 | 228 | |
ddrew73 | 4:5d27966f93e4 | 229 | //SET MULTIPLEXER TO READ VDD |
fil | 6:d0a1eba7f943 | 230 | for (int i=0; i++; i<2) { |
fil | 6:d0a1eba7f943 | 231 | for (int j=0; j++; i<24) { |
fil | 6:d0a1eba7f943 | 232 | |
fil | 6:d0a1eba7f943 | 233 | float test_val = adc.read(); |
fil | 6:d0a1eba7f943 | 234 | if (test_val == 0.0) { |
fil | 6:d0a1eba7f943 | 235 | // this node is ground... |
fil | 6:d0a1eba7f943 | 236 | } |
fil | 6:d0a1eba7f943 | 237 | else if ((test_val > vdd_samp-0.01) && (test_val < vdd_samp+0.01)) { |
fil | 6:d0a1eba7f943 | 238 | // this node is VDD |
fil | 6:d0a1eba7f943 | 239 | } |
fil | 6:d0a1eba7f943 | 240 | else if ((test_val > select_val-0.01) && (test_val < select_val+0.01)) { |
fil | 6:d0a1eba7f943 | 241 | // this node is connected to the selected node |
fil | 6:d0a1eba7f943 | 242 | } |
fil | 6:d0a1eba7f943 | 243 | else { |
fil | 6:d0a1eba7f943 | 244 | // this node is floating? |
fil | 6:d0a1eba7f943 | 245 | } |
fil | 6:d0a1eba7f943 | 246 | } |
fil | 6:d0a1eba7f943 | 247 | } |
fil | 6:d0a1eba7f943 | 248 | |
fil | 6:d0a1eba7f943 | 249 | A_in,B_in,C_in,D_in,E_in,F_in = 1; |
fil | 6:d0a1eba7f943 | 250 | float vddval = adc.read(); |
ddrew73 | 4:5d27966f93e4 | 251 | |
ddrew73 | 4:5d27966f93e4 | 252 | //SET MULTIPLEXER TO READ SELECTED ROW |
fil | 6:d0a1eba7f943 | 253 | // Sample the 'selected' node |
fil | 6:d0a1eba7f943 | 254 | int sn = 0; |
fil | 6:d0a1eba7f943 | 255 | int sn = (colselect + 1)*(rowselect + 1); |
fil | 6:d0a1eba7f943 | 256 | A_in = (sn-1)&2; B_in = ((sn-1)/2)%2; C_in = ((sn-1)/4)%2; D_in = ((sn-1)/8)%2; E_in = ((sn-1)/16)%2; F_in = ((sn-1)/32)%2; |
fil | 6:d0a1eba7f943 | 257 | float rowval = adc.read(); |
ddrew73 | 4:5d27966f93e4 | 258 | |
ddrew73 | 5:03d75ad40d5e | 259 | ledbar_left.clear(); |
ddrew73 | 5:03d75ad40d5e | 260 | ledbar_right.clear(); |
ddrew73 | 5:03d75ad40d5e | 261 | |
ddrew73 | 4:5d27966f93e4 | 262 | for (int x = 0; x < 2; x++) { |
ddrew73 | 4:5d27966f93e4 | 263 | for (int y = 0; y < 24; y++) { |
fil | 6:d0a1eba7f943 | 264 | int sn = (colselect+1)*(rowselect+1); |
fil | 6:d0a1eba7f943 | 265 | A_in = (sn-1)&2; B_in = ((sn-1)/2)%2; C_in = ((sn-1)/4)%2; D_in = ((sn-1)/8)%2; E_in = ((sn-1)/16)%2; F_in = ((sn-1)/32)%2; |
fil | 6:d0a1eba7f943 | 266 | |
fil | 6:d0a1eba7f943 | 267 | float in_val = adc.read(); |
fil | 6:d0a1eba7f943 | 268 | volt_mat[x][y] = in_val; |
ddrew73 | 4:5d27966f93e4 | 269 | |
fil | 6:d0a1eba7f943 | 270 | if (in_val == vddval){ |
fil | 6:d0a1eba7f943 | 271 | con_mat[x][y] = 2; |
fil | 6:d0a1eba7f943 | 272 | if (x == 0){ |
fil | 6:d0a1eba7f943 | 273 | ledbar_left.setBar(y,LED_RED); |
fil | 6:d0a1eba7f943 | 274 | } |
fil | 6:d0a1eba7f943 | 275 | else { |
fil | 6:d0a1eba7f943 | 276 | ledbar_right.setBar(y,LED_RED); |
fil | 6:d0a1eba7f943 | 277 | } |
fil | 6:d0a1eba7f943 | 278 | } |
fil | 6:d0a1eba7f943 | 279 | if (in_val == 0){ |
fil | 6:d0a1eba7f943 | 280 | con_mat[x][y] = 3; |
fil | 6:d0a1eba7f943 | 281 | if (x == 0){ |
fil | 6:d0a1eba7f943 | 282 | ledbar_left.setBar(y,LED_YELLOW); |
fil | 6:d0a1eba7f943 | 283 | } |
fil | 6:d0a1eba7f943 | 284 | else { |
fil | 6:d0a1eba7f943 | 285 | ledbar_right.setBar(y,LED_YELLOW); |
fil | 6:d0a1eba7f943 | 286 | } |
fil | 6:d0a1eba7f943 | 287 | } |
fil | 6:d0a1eba7f943 | 288 | if (in_val == rowval){ |
fil | 6:d0a1eba7f943 | 289 | con_mat[x][y] = 1; |
fil | 6:d0a1eba7f943 | 290 | if (x == 0){ |
fil | 6:d0a1eba7f943 | 291 | ledbar_left.setBar(y,LED_GREEN); |
fil | 6:d0a1eba7f943 | 292 | } |
fil | 6:d0a1eba7f943 | 293 | else { |
fil | 6:d0a1eba7f943 | 294 | ledbar_right.setBar(y,LED_GREEN); |
fil | 6:d0a1eba7f943 | 295 | } |
ddrew73 | 5:03d75ad40d5e | 296 | } |
ddrew73 | 5:03d75ad40d5e | 297 | else { |
fil | 6:d0a1eba7f943 | 298 | con_mat[x][y] = 0; |
ddrew73 | 4:5d27966f93e4 | 299 | } |
ddrew73 | 4:5d27966f93e4 | 300 | } |
fil | 6:d0a1eba7f943 | 301 | |
ddrew73 | 5:03d75ad40d5e | 302 | moved = 0; |
ddrew73 | 5:03d75ad40d5e | 303 | |
ddrew73 | 5:03d75ad40d5e | 304 | //// PUT ALL ABOVE IN SCAN BUTTON IF ///// |
ddrew73 | 5:03d75ad40d5e | 305 | |
ddrew73 | 5:03d75ad40d5e | 306 | |
ddrew73 | 5:03d75ad40d5e | 307 | |
ddrew73 | 5:03d75ad40d5e | 308 | if (moved==0) { |
ddrew73 | 5:03d75ad40d5e | 309 | ledbar_left.writeDisplay(); |
ddrew73 | 5:03d75ad40d5e | 310 | ledbar_right.writeDisplay(); |
ddrew73 | 5:03d75ad40d5e | 311 | lcd.cls(); |
ddrew73 | 5:03d75ad40d5e | 312 | lcd.locate(0,1); |
ddrew73 | 5:03d75ad40d5e | 313 | lcd.printf("Vdd: %1.1f V",vddval); |
ddrew73 | 5:03d75ad40d5e | 314 | lcd.locate(0,0); |
ddrew73 | 5:03d75ad40d5e | 315 | lcd.printf("Row: %1.1f V",rowval); |
ddrew73 | 5:03d75ad40d5e | 316 | } |
ddrew73 | 5:03d75ad40d5e | 317 | else { |
ddrew73 | 5:03d75ad40d5e | 318 | lcd.cls(); |
ddrew73 | 5:03d75ad40d5e | 319 | string programname = "Dan's UI Test"; |
ddrew73 | 5:03d75ad40d5e | 320 | string instructions = "Select a row and scan it"; |
ddrew73 | 5:03d75ad40d5e | 321 | lcd.locate(0,0); |
ddrew73 | 5:03d75ad40d5e | 322 | lcd.printf("%s",programname.c_str()); |
ddrew73 | 5:03d75ad40d5e | 323 | lcd.locate(0,1); |
ddrew73 | 5:03d75ad40d5e | 324 | lcd.printf("%s",instructions.c_str()); |
ddrew73 | 5:03d75ad40d5e | 325 | } |
ddrew73 | 5:03d75ad40d5e | 326 | |
ddrew73 | 5:03d75ad40d5e | 327 | |
ddrew73 | 5:03d75ad40d5e | 328 | |
ddrew73 | 5:03d75ad40d5e | 329 | |
ddrew73 | 4:5d27966f93e4 | 330 | |
ddrew73 | 4:5d27966f93e4 | 331 | //Q: Do we need to do the same test for ground or can 0.00 be assumed? |
ddrew73 | 5:03d75ad40d5e | 332 | //Q: What is the most efficient way to compare all the "volt_mat" elements? |
ddrew73 | 4:5d27966f93e4 | 333 | //Q: Do we need to add a "confidence interval" around the rowval and vdd tests? |
ddrew73 | 0:16d2619002d7 | 334 | |
ddrew73 | 0:16d2619002d7 | 335 | |
ddrew73 | 4:5d27966f93e4 | 336 | |
ddrew73 | 4:5d27966f93e4 | 337 | |
ddrew73 | 4:5d27966f93e4 | 338 | |
ddrew73 | 4:5d27966f93e4 | 339 | */ |
ddrew73 | 4:5d27966f93e4 | 340 |