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