:)

Dependencies:   MbedJSONValue DebounceIn TextLCD USBDevice mbed WebSocketClient cc3000_hostdriver_mbedsocket Adafruit_LEDBackpack_2

Committer:
ddrew73
Date:
Tue Dec 09 18:21:26 2014 +0000
Revision:
15:236d90e38951
Parent:
14:2d47b97c2028
Child:
16:028a8548ab22
UI + scan working, wifi down;

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 9:5fa90677ff3e 17 I2C i2c_left(PTC11,PTC10);
ddrew73 7:7fbe8dc5e4fa 18 Adafruit_24bargraph ledbar_left=Adafruit_24bargraph(&i2c_left);
ddrew73 4:5d27966f93e4 19
ddrew73 9:5fa90677ff3e 20 I2C i2c_right(D7,D6);
ddrew73 7:7fbe8dc5e4fa 21 Adafruit_24bargraph ledbar_right=Adafruit_24bargraph(&i2c_right);
ddrew73 4:5d27966f93e4 22
jn80842 14:2d47b97c2028 23 void set_led(int index, int color) { // index range from 0-47
jn80842 14:2d47b97c2028 24 if (index<24) {
jn80842 14:2d47b97c2028 25 ledbar_left.setBar(index,color);
jn80842 14:2d47b97c2028 26 } else {
jn80842 14:2d47b97c2028 27 ledbar_right.setBar(index-24,color);
jn80842 14:2d47b97c2028 28 }
jn80842 14:2d47b97c2028 29 }
jn80842 14:2d47b97c2028 30
ddrew73 9:5fa90677ff3e 31 DebounceIn upbutton(PTA16);
ddrew73 10:cfd60b63ed11 32 DebounceIn downbutton(PTC12);
ddrew73 10:cfd60b63ed11 33 DebounceIn leftbutton(PTC17);
ddrew73 10:cfd60b63ed11 34 DebounceIn rightbutton(PTC16);
ddrew73 0:16d2619002d7 35
ddrew73 0:16d2619002d7 36 //Scanner stuff
ddrew73 0:16d2619002d7 37
ddrew73 10:cfd60b63ed11 38 DebounceIn scanbutton(PTC13);
ddrew73 0:16d2619002d7 39
ddrew73 9:5fa90677ff3e 40 DigitalOut A_in(PTB10);
ddrew73 9:5fa90677ff3e 41 DigitalOut B_in(PTB11);
ddrew73 9:5fa90677ff3e 42 DigitalOut C_in(PTE2);
ddrew73 9:5fa90677ff3e 43 DigitalOut D_in(PTE3);
ddrew73 9:5fa90677ff3e 44 DigitalOut E_in(PTE4);
ddrew73 9:5fa90677ff3e 45 DigitalOut F_in(PTE5);
ddrew73 0:16d2619002d7 46
ddrew73 0:16d2619002d7 47 AnalogIn adc(PTB0);
ddrew73 0:16d2619002d7 48
ddrew73 8:725d938b301b 49
ddrew73 0:16d2619002d7 50
ddrew73 0:16d2619002d7 51
ddrew73 0:16d2619002d7 52 //LCD stuff
jn80842 14:2d47b97c2028 53 //TextLCD(PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, LCDType type = LCD16x2);
ddrew73 9:5fa90677ff3e 54 TextLCD lcd(PTC6,PTC5,D5,D4,D3,D2,TextLCD::LCD20x4);
ddrew73 0:16d2619002d7 55
jn80842 14:2d47b97c2028 56 void lcd_write_selected_info(int selected) {
jn80842 14:2d47b97c2028 57 lcd.cls();
jn80842 14:2d47b97c2028 58 lcd.locate(0,0);
jn80842 14:2d47b97c2028 59 lcd.printf("The ToastBoard");
jn80842 14:2d47b97c2028 60 lcd.locate(0,1);
jn80842 14:2d47b97c2028 61 lcd.printf("Selected row: %d",selected);
jn80842 14:2d47b97c2028 62 }
jn80842 14:2d47b97c2028 63
jn80842 14:2d47b97c2028 64 void lcd_write_voltage_info(float vddval,int selected,float rowval) {
jn80842 14:2d47b97c2028 65 lcd.cls();
jn80842 14:2d47b97c2028 66 lcd.locate(0,1);
jn80842 14:2d47b97c2028 67 lcd.printf("Vdd: %1.1f V",vddval);
jn80842 14:2d47b97c2028 68 lcd.locate(0,0);
ddrew73 15:236d90e38951 69 lcd.printf("Row %d: %1.1f V",selected,rowval);
jn80842 14:2d47b97c2028 70 }
jn80842 14:2d47b97c2028 71
ddrew73 10:cfd60b63ed11 72
ddrew73 10:cfd60b63ed11 73 //WIFI STUFF
jn80842 13:209da1dcb6e1 74
ddrew73 0:16d2619002d7 75
jn80842 3:161fed8bd027 76 // cc3000 KL25Z wifi connection
jn80842 3:161fed8bd027 77 // we need to define connection pins for:
jn80842 3:161fed8bd027 78 // - IRQ => (pin D3)
jn80842 3:161fed8bd027 79 // - Enable => (pin D5)
jn80842 3:161fed8bd027 80 // - SPI CS => (pin D10)
jn80842 3:161fed8bd027 81 // - SPI MOSI => (pin D11)
jn80842 3:161fed8bd027 82 // - SPI MISO => (pin D12)
jn80842 3:161fed8bd027 83 // - SPI CLK => (pin D13)
jn80842 3:161fed8bd027 84 // plus wifi network SSID, password, security level and smart-configuration flag.
jn80842 3:161fed8bd027 85
ddrew73 15:236d90e38951 86 /*
ddrew73 15:236d90e38951 87
ddrew73 9:5fa90677ff3e 88 mbed_cc3000::cc3000 wifi(D8, D9, D10, SPI(D11, D12, D13),
jn80842 14:2d47b97c2028 89 "SSID", "PASSWORD", WPA2, false);
jn80842 3:161fed8bd027 90 Websocket ws("ws://sockets.mbed.org/ws/toastboard/rw");
jn80842 3:161fed8bd027 91
ddrew73 15:236d90e38951 92
jn80842 12:c4b046975527 93 void add_to_json(const std::string& s, std::back_insert_iterator<std::string> oi) {
jn80842 14:2d47b97c2028 94 // this chunk of code lifted from the MbedJSONValue
jn80842 14:2d47b97c2028 95 char buf[7];
jn80842 12:c4b046975527 96 for (std::string::const_iterator i = s.begin(); i != s.end(); ++i) {
jn80842 14:2d47b97c2028 97 if ((unsigned char)*i < 0x20 || *i == 0x7f) {
jn80842 14:2d47b97c2028 98 sprintf(buf, "\\u%04x", *i & 0xff);
jn80842 14:2d47b97c2028 99 copy(buf, buf + 6, oi);
jn80842 14:2d47b97c2028 100 } else {
jn80842 14:2d47b97c2028 101 *oi++ = *i;
jn80842 14:2d47b97c2028 102 }
jn80842 14:2d47b97c2028 103 }
jn80842 14:2d47b97c2028 104 }
jn80842 14:2d47b97c2028 105
jn80842 14:2d47b97c2028 106 std::string build_json(float vddval,int selected,float clientdata[48]) {
jn80842 14:2d47b97c2028 107 std::string s;
jn80842 14:2d47b97c2028 108 std::back_insert_iterator<std::string> json_str = std::back_inserter(s);
jn80842 14:2d47b97c2028 109 char row[1] = ""; // holder for row tokens
jn80842 14:2d47b97c2028 110 char rowvoltage[4] = ""; // holder for voltage values
jn80842 14:2d47b97c2028 111 add_to_json("{\"vddval\":",json_str);
jn80842 14:2d47b97c2028 112 sprintf(rowvoltage,"%.1f",vddval);
jn80842 14:2d47b97c2028 113 add_to_json(rowvoltage,json_str);
jn80842 14:2d47b97c2028 114 add_to_json(", \"selected\":",json_str);
jn80842 14:2d47b97c2028 115 sprintf(rowvoltage,"%d",selected);
jn80842 14:2d47b97c2028 116 add_to_json(", \"rows\": [",json_str);
jn80842 14:2d47b97c2028 117 int append_comma = 0;
jn80842 14:2d47b97c2028 118 for (int i= 0; i < 48; i++) {
jn80842 14:2d47b97c2028 119 if (clientdata[i] != 100.0) { // don't pass on floating row vals
jn80842 14:2d47b97c2028 120 if (append_comma == 1) {
jn80842 14:2d47b97c2028 121 add_to_json(",",json_str);
jn80842 14:2d47b97c2028 122 } else {
jn80842 14:2d47b97c2028 123 append_comma = 1;
jn80842 14:2d47b97c2028 124 }
jn80842 14:2d47b97c2028 125 add_to_json("{\"",json_str);
jn80842 14:2d47b97c2028 126 sprintf(row, "%d", i);
jn80842 14:2d47b97c2028 127 add_to_json(row,json_str);
jn80842 14:2d47b97c2028 128 add_to_json("\":",json_str);
jn80842 14:2d47b97c2028 129 sprintf(rowvoltage,"%.1f",clientdata[i]);
jn80842 14:2d47b97c2028 130 add_to_json(rowvoltage,json_str);
jn80842 14:2d47b97c2028 131 add_to_json("}",json_str);
jn80842 14:2d47b97c2028 132 }
jn80842 14:2d47b97c2028 133 }
jn80842 14:2d47b97c2028 134 add_to_json("]}",json_str);
jn80842 14:2d47b97c2028 135 return s;
jn80842 14:2d47b97c2028 136 }
ddrew73 15:236d90e38951 137 */
jn80842 14:2d47b97c2028 138
jn80842 14:2d47b97c2028 139 bool voltages_equal(float voltage1,float voltage2) {
jn80842 14:2d47b97c2028 140 return (voltage1 > voltage2-0.01) && (voltage1 < voltage2+0.01);
jn80842 14:2d47b97c2028 141 }
jn80842 14:2d47b97c2028 142
jn80842 14:2d47b97c2028 143 void read_voltages(float voltages[48]) {
jn80842 14:2d47b97c2028 144 int sn = 0;
ddrew73 15:236d90e38951 145 for (int i=0;i<48;i++) { // iterate over two columns of breadboard
ddrew73 15:236d90e38951 146 // iterate over 24 rows of each column
ddrew73 15:236d90e38951 147 sn = i; // maybe?????
ddrew73 15:236d90e38951 148 D_in = (sn)%2;
ddrew73 15:236d90e38951 149 E_in = ((sn)/2)%2;
ddrew73 15:236d90e38951 150 F_in = ((sn)/4)%2;
ddrew73 15:236d90e38951 151 A_in = ((sn)/8)%2;
ddrew73 15:236d90e38951 152 B_in = ((sn)/16)%2;
ddrew73 15:236d90e38951 153 C_in = ((sn)/32)%2;
jn80842 14:2d47b97c2028 154
ddrew73 15:236d90e38951 155 voltages[sn] = adc.read();
ddrew73 15:236d90e38951 156
jn80842 14:2d47b97c2028 157 }
jn80842 14:2d47b97c2028 158 }
jn80842 14:2d47b97c2028 159
jn80842 14:2d47b97c2028 160 void compare_voltages(float voltages[48], float clientdata[48], int colselect, int rowselect, float vddval) {
jn80842 14:2d47b97c2028 161 // get selected row voltage
ddrew73 15:236d90e38951 162 float rowval = voltages[(colselect*24)+ rowselect];
jn80842 14:2d47b97c2028 163 for (int i=0;i<48;i++) {
jn80842 14:2d47b97c2028 164 int client_index = (colselect*24)+rowselect;
ddrew73 15:236d90e38951 165 int sn = i;//(colselect+1)*(rowselect+1);
ddrew73 15:236d90e38951 166 D_in = (sn)%2;
ddrew73 15:236d90e38951 167 E_in = ((sn)/2)%2;
ddrew73 15:236d90e38951 168 F_in = ((sn)/4)%2;
ddrew73 15:236d90e38951 169 A_in = ((sn)/8)%2;
ddrew73 15:236d90e38951 170 B_in = ((sn)/16)%2;
ddrew73 15:236d90e38951 171 C_in = ((sn)/32)%2;
jn80842 14:2d47b97c2028 172
jn80842 14:2d47b97c2028 173 float in_val = adc.read();
ddrew73 15:236d90e38951 174
ddrew73 15:236d90e38951 175
jn80842 14:2d47b97c2028 176 if (!voltages_equal(voltages[i],in_val)) {
jn80842 14:2d47b97c2028 177 // this row is floating
ddrew73 15:236d90e38951 178 set_led(i,LED_OFF);
jn80842 14:2d47b97c2028 179 clientdata[client_index] = 100.0;
jn80842 14:2d47b97c2028 180 } else if (voltages_equal(voltages[i],vddval)) {
jn80842 14:2d47b97c2028 181 // this row matches vdd
jn80842 14:2d47b97c2028 182 set_led(i,LED_RED);
jn80842 14:2d47b97c2028 183 clientdata[client_index] = vddval;
jn80842 14:2d47b97c2028 184 } else if (voltages_equal(voltages[i],0.0)) {
jn80842 14:2d47b97c2028 185 // this row matches ground
jn80842 14:2d47b97c2028 186 set_led(i,LED_YELLOW);
jn80842 14:2d47b97c2028 187 clientdata[client_index] = 0.0;
jn80842 14:2d47b97c2028 188 } else if (voltages_equal(voltages[i],rowval)) {
jn80842 14:2d47b97c2028 189 // this row matches selected row
jn80842 14:2d47b97c2028 190 set_led(i,LED_GREEN);
jn80842 14:2d47b97c2028 191 clientdata[client_index] = rowval;
jn80842 14:2d47b97c2028 192 } else {
ddrew73 15:236d90e38951 193 set_led(i,LED_OFF);
jn80842 14:2d47b97c2028 194 clientdata[client_index] = voltages[i];
jn80842 12:c4b046975527 195 }
jn80842 12:c4b046975527 196 }
jn80842 12:c4b046975527 197 }
jn80842 12:c4b046975527 198
ddrew73 7:7fbe8dc5e4fa 199
ddrew73 0:16d2619002d7 200 int main()
ddrew73 0:16d2619002d7 201 {
ddrew73 0:16d2619002d7 202
ddrew73 0:16d2619002d7 203 //Scan init
jn80842 14:2d47b97c2028 204 float originalvoltages[48] = {};
ddrew73 15:236d90e38951 205 float newvoltages[48] = {};
ddrew73 7:7fbe8dc5e4fa 206 float clientdata[48] = {};
jn80842 14:2d47b97c2028 207 float vddval = 0.0;
ddrew73 15:236d90e38951 208 float rowval = 0.0;
ddrew73 0:16d2619002d7 209
ddrew73 0:16d2619002d7 210 //LED init
ddrew73 15:236d90e38951 211 int rowselect = 0, moved = 1, colselect = 0, selected = 0, oldselected = 49;
ddrew73 4:5d27966f93e4 212 ledbar_left.begin(0x70);
ddrew73 4:5d27966f93e4 213 ledbar_left.clear();
ddrew73 4:5d27966f93e4 214 ledbar_left.writeDisplay();
ddrew73 5:03d75ad40d5e 215
ddrew73 4:5d27966f93e4 216 ledbar_right.begin(0x70);
ddrew73 4:5d27966f93e4 217 ledbar_right.clear();
ddrew73 4:5d27966f93e4 218 ledbar_right.writeDisplay();
ddrew73 0:16d2619002d7 219
ddrew73 0:16d2619002d7 220 //LCD init
ddrew73 0:16d2619002d7 221 lcd.cls();
jn80842 14:2d47b97c2028 222 int written = 0;
jn80842 14:2d47b97c2028 223
ddrew73 15:236d90e38951 224 //wifi.init();
ddrew73 11:b520586dc0a1 225
ddrew73 9:5fa90677ff3e 226 //Osci
ddrew73 9:5fa90677ff3e 227 int loopcount = 0, pressed = 0;
ddrew73 9:5fa90677ff3e 228 float begintime = 0, endtime = 0, elapsed = 0;
ddrew73 0:16d2619002d7 229
ddrew73 0:16d2619002d7 230
ddrew73 0:16d2619002d7 231 while(1) {
ddrew73 15:236d90e38951 232 /*
jn80842 14:2d47b97c2028 233 if (wifi.is_connected() == false) {
jn80842 14:2d47b97c2028 234 pc.printf("trying to connect to wifi\r\n");
jn80842 14:2d47b97c2028 235 if (wifi.connect() == -1) {
jn80842 14:2d47b97c2028 236 pc.printf("Failed to connect\r\n");
jn80842 14:2d47b97c2028 237 } else {
jn80842 14:2d47b97c2028 238 pc.printf("IP address: %s \r\n", wifi.getIPAddress());
jn80842 14:2d47b97c2028 239 }
jn80842 14:2d47b97c2028 240 } else {
jn80842 14:2d47b97c2028 241 Websocket ws("ws://sockets.mbed.org/ws/toastboard/rw");
jn80842 14:2d47b97c2028 242 ws.connect();
jn80842 14:2d47b97c2028 243 }
ddrew73 5:03d75ad40d5e 244
ddrew73 15:236d90e38951 245 */
ddrew73 15:236d90e38951 246
ddrew73 15:236d90e38951 247
ddrew73 0:16d2619002d7 248 //Display
jn80842 14:2d47b97c2028 249 if (moved ==1) {
ddrew73 5:03d75ad40d5e 250 ledbar_left.clear();
ddrew73 5:03d75ad40d5e 251 ledbar_right.clear();
jn80842 14:2d47b97c2028 252 set_led((colselect*24+rowselect),LED_GREEN);
ddrew73 5:03d75ad40d5e 253 ledbar_left.writeDisplay();
ddrew73 5:03d75ad40d5e 254 ledbar_right.writeDisplay();
ddrew73 7:7fbe8dc5e4fa 255 }
ddrew73 0:16d2619002d7 256 //Moving the selected row
ddrew73 0:16d2619002d7 257 if (upbutton.read() == 0) {
ddrew73 0:16d2619002d7 258 rowselect = rowselect-1;
ddrew73 0:16d2619002d7 259 moved = 1;
jn80842 14:2d47b97c2028 260 written = 0;
ddrew73 15:236d90e38951 261 wait(0.3);
ddrew73 0:16d2619002d7 262 }
ddrew73 0:16d2619002d7 263
ddrew73 0:16d2619002d7 264 if (downbutton.read() == 0) {
ddrew73 0:16d2619002d7 265 rowselect = rowselect+1;
ddrew73 0:16d2619002d7 266 moved = 1;
jn80842 14:2d47b97c2028 267 written = 0;
ddrew73 15:236d90e38951 268 wait(0.3);
ddrew73 0:16d2619002d7 269 }
ddrew73 5:03d75ad40d5e 270
ddrew73 4:5d27966f93e4 271 if (leftbutton.read() == 0) {
ddrew73 4:5d27966f93e4 272 colselect = 0;
ddrew73 5:03d75ad40d5e 273 ledbar_right.clear();
ddrew73 5:03d75ad40d5e 274 moved =1;
jn80842 14:2d47b97c2028 275 written = 0;
ddrew73 15:236d90e38951 276 wait(0.3);
ddrew73 4:5d27966f93e4 277 }
ddrew73 5:03d75ad40d5e 278
ddrew73 4:5d27966f93e4 279 if (rightbutton.read() == 0) {
ddrew73 4:5d27966f93e4 280 colselect = 1;
ddrew73 5:03d75ad40d5e 281 ledbar_left.clear();
ddrew73 5:03d75ad40d5e 282 moved =1;
jn80842 14:2d47b97c2028 283 written = 0;
ddrew73 15:236d90e38951 284 wait(0.3);
ddrew73 5:03d75ad40d5e 285 }
ddrew73 0:16d2619002d7 286
ddrew73 0:16d2619002d7 287 //Boundary checking
ddrew73 0:16d2619002d7 288 if (rowselect > 23) {
ddrew73 0:16d2619002d7 289 rowselect = 23;
ddrew73 0:16d2619002d7 290 }
ddrew73 0:16d2619002d7 291 if (rowselect < 0) {
ddrew73 0:16d2619002d7 292 rowselect = 0;
ddrew73 0:16d2619002d7 293 }
ddrew73 0:16d2619002d7 294
ddrew73 15:236d90e38951 295 selected = (colselect * 24) + (rowselect+1);
ddrew73 15:236d90e38951 296
ddrew73 0:16d2619002d7 297 //Implementing scanning
ddrew73 0:16d2619002d7 298
ddrew73 0:16d2619002d7 299 if (scanbutton.read() == 0) {
ddrew73 15:236d90e38951 300 A_in = 0;
ddrew73 7:7fbe8dc5e4fa 301 B_in = 1;
ddrew73 7:7fbe8dc5e4fa 302 C_in = 1;
ddrew73 7:7fbe8dc5e4fa 303 D_in = 1;
ddrew73 15:236d90e38951 304 E_in = 0;
ddrew73 15:236d90e38951 305 F_in = 0;
ddrew73 11:b520586dc0a1 306
ddrew73 7:7fbe8dc5e4fa 307 vddval = adc.read();
ddrew73 0:16d2619002d7 308
ddrew73 7:7fbe8dc5e4fa 309 ledbar_left.clear();
ddrew73 7:7fbe8dc5e4fa 310 ledbar_right.clear();
ddrew73 1:0183a7d38878 311
jn80842 14:2d47b97c2028 312 // first set of voltages read into old_volt_mat
jn80842 14:2d47b97c2028 313 read_voltages(originalvoltages);
ddrew73 15:236d90e38951 314 wait(0.2);
ddrew73 15:236d90e38951 315 read_voltages(newvoltages);
jn80842 14:2d47b97c2028 316 // second set for comparison, read into clientdata
ddrew73 15:236d90e38951 317 wait(0.2);
jn80842 14:2d47b97c2028 318 compare_voltages(originalvoltages,clientdata,colselect,rowselect,vddval);
ddrew73 0:16d2619002d7 319
ddrew73 15:236d90e38951 320 selected = (colselect * 24) + (rowselect+1);
ddrew73 15:236d90e38951 321 rowval = newvoltages[selected-1];
ddrew73 11:b520586dc0a1 322
jn80842 14:2d47b97c2028 323 written = 0;
jn80842 14:2d47b97c2028 324 moved = 0;
ddrew73 11:b520586dc0a1 325
ddrew73 8:725d938b301b 326 //DEBUGGING TOOLS //////////////
ddrew73 11:b520586dc0a1 327
ddrew73 15:236d90e38951 328 pc.printf("\r\n%1.3f %1.3f \r\n", vddval, rowval);
jn80842 14:2d47b97c2028 329 for (int i = 0; i<48; i++) {
jn80842 14:2d47b97c2028 330 pc.printf(" %1.3f ", clientdata[i]);
jn80842 14:2d47b97c2028 331 }
jn80842 14:2d47b97c2028 332 pc.printf(" \r\n \r\n ");
jn80842 14:2d47b97c2028 333 for (int x = 0; x < 48; x++) {
ddrew73 15:236d90e38951 334 pc.printf("%1.3f %1.3f \r\n", originalvoltages[x], newvoltages[x]);
jn80842 14:2d47b97c2028 335 }
jn80842 14:2d47b97c2028 336 ////////////////////////
ddrew73 11:b520586dc0a1 337
ddrew73 11:b520586dc0a1 338
ddrew73 15:236d90e38951 339 wait(0.3); //THIS NEEDS TO GO AWAY!
ddrew73 11:b520586dc0a1 340
ddrew73 11:b520586dc0a1 341 } // END OF SCANBUTTON IF STATEMENT
ddrew73 11:b520586dc0a1 342
jn80842 14:2d47b97c2028 343 if (moved==0 && written == 0) {
ddrew73 7:7fbe8dc5e4fa 344 ledbar_left.writeDisplay();
ddrew73 7:7fbe8dc5e4fa 345 ledbar_right.writeDisplay();
ddrew73 15:236d90e38951 346 lcd_write_voltage_info(vddval*3.3,selected,rowval*3.3);
ddrew73 15:236d90e38951 347
ddrew73 15:236d90e38951 348 /*
jn80842 13:209da1dcb6e1 349 // send data to websocket
jn80842 14:2d47b97c2028 350 if (wifi.is_connected()) {
jn80842 14:2d47b97c2028 351 std::string json = build_json(vddval,selected,clientdata);
jn80842 14:2d47b97c2028 352 char * writable = new char[json.size() + 1];
jn80842 14:2d47b97c2028 353 std::copy(json.begin(), json.end(), writable);
jn80842 14:2d47b97c2028 354 writable[json.size()] = '\0';
jn80842 14:2d47b97c2028 355 ws.send(writable);
jn80842 14:2d47b97c2028 356 delete[] writable;
jn80842 14:2d47b97c2028 357 delete[] &json;
jn80842 14:2d47b97c2028 358 }
ddrew73 15:236d90e38951 359 */
ddrew73 15:236d90e38951 360
jn80842 14:2d47b97c2028 361 written = 1;
ddrew73 15:236d90e38951 362 } else if (oldselected != selected) {
jn80842 14:2d47b97c2028 363 lcd_write_selected_info(selected);
ddrew73 15:236d90e38951 364
ddrew73 11:b520586dc0a1 365 }
ddrew73 15:236d90e38951 366 oldselected = selected;
ddrew73 5:03d75ad40d5e 367
ddrew73 5:03d75ad40d5e 368
ddrew73 5:03d75ad40d5e 369
ddrew73 5:03d75ad40d5e 370
ddrew73 4:5d27966f93e4 371
ddrew73 11:b520586dc0a1 372
ddrew73 7:7fbe8dc5e4fa 373
ddrew73 7:7fbe8dc5e4fa 374
ddrew73 0:16d2619002d7 375
ddrew73 0:16d2619002d7 376
ddrew73 4:5d27966f93e4 377
ddrew73 4:5d27966f93e4 378
ddrew73 4:5d27966f93e4 379
ddrew73 7:7fbe8dc5e4fa 380 } // END OF WHILE(1)
ddrew73 7:7fbe8dc5e4fa 381
ddrew73 7:7fbe8dc5e4fa 382
ddrew73 7:7fbe8dc5e4fa 383
ddrew73 4:5d27966f93e4 384
ddrew73 7:7fbe8dc5e4fa 385 } // END OF INT MAIN
ddrew73 7:7fbe8dc5e4fa 386
ddrew73 7:7fbe8dc5e4fa 387
ddrew73 11:b520586dc0a1 388 /*
ddrew73 11:b520586dc0a1 389 OSCILLISCOPE
ddrew73 7:7fbe8dc5e4fa 390
ddrew73 7:7fbe8dc5e4fa 391
ddrew73 11:b520586dc0a1 392 while (scanbutton == 0){
ddrew73 11:b520586dc0a1 393 if (loopcount = 0){
ddrew73 11:b520586dc0a1 394 timer.reset();
ddrew73 11:b520586dc0a1 395 timer.start();
ddrew73 11:b520586dc0a1 396 begintime = timer.read_ms();
ddrew73 11:b520586dc0a1 397 pressed == 1;
ddrew73 11:b520586dc0a1 398 }
ddrew73 7:7fbe8dc5e4fa 399
ddrew73 11:b520586dc0a1 400 int sn = (colselect + 1)*(rowselect + 1);
ddrew73 11:b520586dc0a1 401 A_in = (sn-1)&2;
ddrew73 11:b520586dc0a1 402 B_in = ((sn-1)/2)%2;
ddrew73 11:b520586dc0a1 403 C_in = ((sn-1)/4)%2;
ddrew73 11:b520586dc0a1 404 D_in = ((sn-1)/8)%2;
ddrew73 11:b520586dc0a1 405 E_in = ((sn-1)/16)%2;
ddrew73 11:b520586dc0a1 406 F_in = ((sn-1)/32)%2;
ddrew73 11:b520586dc0a1 407 volt_buffer[loopcount] = adc.read();
ddrew73 8:725d938b301b 408
ddrew73 8:725d938b301b 409
ddrew73 11:b520586dc0a1 410 loopcount = loopcount +1;
ddrew73 11:b520586dc0a1 411 } // BREAK THE WHILE SCANBUTTON
ddrew73 8:725d938b301b 412
ddrew73 11:b520586dc0a1 413 if (pressed == 1){
ddrew73 11:b520586dc0a1 414 timer.stop();
ddrew73 11:b520586dc0a1 415 endtime = timer.read_ms();
ddrew73 11:b520586dc0a1 416 elapsed = endtime - begintime;
ddrew73 8:725d938b301b 417
ddrew73 11:b520586dc0a1 418 DO ENTIRE SCAN STUFF
ddrew73 8:725d938b301b 419
ddrew73 11:b520586dc0a1 420 pressed = 0;
ddrew73 11:b520586dc0a1 421 }
ddrew73 8:725d938b301b 422
ddrew73 11:b520586dc0a1 423 */