![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
amazon distribution center
Dependencies: ISL29125 Motor mbed
main.cpp@0:3bde34c58439, 2017-05-02 (annotated)
- Committer:
- elirobelo
- Date:
- Tue May 02 02:17:02 2017 +0000
- Revision:
- 0:3bde34c58439
distribution;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elirobelo | 0:3bde34c58439 | 1 | // ESP8266 Static page WEB server to control Mbed |
elirobelo | 0:3bde34c58439 | 2 | |
elirobelo | 0:3bde34c58439 | 3 | #include "mbed.h" |
elirobelo | 0:3bde34c58439 | 4 | #include "ISL29125.h" |
elirobelo | 0:3bde34c58439 | 5 | #include "Motor.h" |
elirobelo | 0:3bde34c58439 | 6 | |
elirobelo | 0:3bde34c58439 | 7 | |
elirobelo | 0:3bde34c58439 | 8 | Serial pc(USBTX, USBRX); |
elirobelo | 0:3bde34c58439 | 9 | Serial esp(p9, p10); // tx, rx |
elirobelo | 0:3bde34c58439 | 10 | |
elirobelo | 0:3bde34c58439 | 11 | ISL29125 RGBsensor(p28, p27); |
elirobelo | 0:3bde34c58439 | 12 | //PwmOut m(p23); |
elirobelo | 0:3bde34c58439 | 13 | Motor m(p23, p5, p6); |
elirobelo | 0:3bde34c58439 | 14 | |
elirobelo | 0:3bde34c58439 | 15 | // Standard Mbed LED definitions |
elirobelo | 0:3bde34c58439 | 16 | DigitalOut led1(LED1); |
elirobelo | 0:3bde34c58439 | 17 | DigitalOut led2(LED2); |
elirobelo | 0:3bde34c58439 | 18 | DigitalOut led3(LED3); |
elirobelo | 0:3bde34c58439 | 19 | DigitalOut led4(LED4); |
elirobelo | 0:3bde34c58439 | 20 | |
elirobelo | 0:3bde34c58439 | 21 | //Solenoids |
elirobelo | 0:3bde34c58439 | 22 | DigitalOut sol1(p11); |
elirobelo | 0:3bde34c58439 | 23 | DigitalOut sol2(p12); |
elirobelo | 0:3bde34c58439 | 24 | DigitalOut sol3(p13); |
elirobelo | 0:3bde34c58439 | 25 | DigitalOut sol4(p14); |
elirobelo | 0:3bde34c58439 | 26 | |
elirobelo | 0:3bde34c58439 | 27 | //Sensors |
elirobelo | 0:3bde34c58439 | 28 | AnalogIn sen1(p17); |
elirobelo | 0:3bde34c58439 | 29 | AnalogIn sen2(p18); |
elirobelo | 0:3bde34c58439 | 30 | AnalogIn sen3(p19); |
elirobelo | 0:3bde34c58439 | 31 | AnalogIn sen4(p20); |
elirobelo | 0:3bde34c58439 | 32 | |
elirobelo | 0:3bde34c58439 | 33 | |
elirobelo | 0:3bde34c58439 | 34 | |
elirobelo | 0:3bde34c58439 | 35 | |
elirobelo | 0:3bde34c58439 | 36 | char ssid[32] = "WifiRouter"; // enter WiFi router ssid inside the quotes |
elirobelo | 0:3bde34c58439 | 37 | char pwd [32] = "password"; // enter WiFi router password inside the quotes |
elirobelo | 0:3bde34c58439 | 38 | |
elirobelo | 0:3bde34c58439 | 39 | |
elirobelo | 0:3bde34c58439 | 40 | |
elirobelo | 0:3bde34c58439 | 41 | bool correct = false; |
elirobelo | 0:3bde34c58439 | 42 | int color; |
elirobelo | 0:3bde34c58439 | 43 | int sensorValue; |
elirobelo | 0:3bde34c58439 | 44 | int direction; |
elirobelo | 0:3bde34c58439 | 45 | Ticker als; |
elirobelo | 0:3bde34c58439 | 46 | uint16_t GRBdata[3]; |
elirobelo | 0:3bde34c58439 | 47 | bool data_present; |
elirobelo | 0:3bde34c58439 | 48 | |
elirobelo | 0:3bde34c58439 | 49 | float temperature, AdcIn, Ht; |
elirobelo | 0:3bde34c58439 | 50 | float R1=100000, R2=10000; // resistor values to give a 10:1 reduction of measured AnalogIn voltage |
elirobelo | 0:3bde34c58439 | 51 | char Vcc[10]; |
elirobelo | 0:3bde34c58439 | 52 | char Temp[10]; |
elirobelo | 0:3bde34c58439 | 53 | |
elirobelo | 0:3bde34c58439 | 54 | // things for sending/receiving data over serial |
elirobelo | 0:3bde34c58439 | 55 | volatile int tx_in=0; |
elirobelo | 0:3bde34c58439 | 56 | volatile int tx_out=0; |
elirobelo | 0:3bde34c58439 | 57 | volatile int rx_in=0; |
elirobelo | 0:3bde34c58439 | 58 | volatile int rx_out=0; |
elirobelo | 0:3bde34c58439 | 59 | const int buffer_size = 4095; |
elirobelo | 0:3bde34c58439 | 60 | char tx_buffer[buffer_size+1]; |
elirobelo | 0:3bde34c58439 | 61 | char rx_buffer[buffer_size+1]; |
elirobelo | 0:3bde34c58439 | 62 | void Tx_interrupt(); |
elirobelo | 0:3bde34c58439 | 63 | void Rx_interrupt(); |
elirobelo | 0:3bde34c58439 | 64 | void send_line(); |
elirobelo | 0:3bde34c58439 | 65 | void read_line(); |
elirobelo | 0:3bde34c58439 | 66 | |
elirobelo | 0:3bde34c58439 | 67 | int DataRX; |
elirobelo | 0:3bde34c58439 | 68 | int update; |
elirobelo | 0:3bde34c58439 | 69 | int count; |
elirobelo | 0:3bde34c58439 | 70 | char cmdbuff[1024]; |
elirobelo | 0:3bde34c58439 | 71 | char replybuff[4096]; |
elirobelo | 0:3bde34c58439 | 72 | char webdata[4096]; // This may need to be bigger depending on WEB browser used |
elirobelo | 0:3bde34c58439 | 73 | char webbuff[4096]; // Currently using 1986 characters, Increase this if more web page data added |
elirobelo | 0:3bde34c58439 | 74 | char timebuf[30]; |
elirobelo | 0:3bde34c58439 | 75 | void SendCMD(),getreply(),ReadWebData(),startserver(); |
elirobelo | 0:3bde34c58439 | 76 | void gettime(),setRTC(); //,gettemp(),getbattery(); |
elirobelo | 0:3bde34c58439 | 77 | char rx_line[1024]; |
elirobelo | 0:3bde34c58439 | 78 | int port =80; // set server port |
elirobelo | 0:3bde34c58439 | 79 | int SERVtimeout =5; // set server timeout in seconds in case link breaks. |
elirobelo | 0:3bde34c58439 | 80 | struct tm t; |
elirobelo | 0:3bde34c58439 | 81 | // manual set RTC values |
elirobelo | 0:3bde34c58439 | 82 | int minute =00; // 0-59 |
elirobelo | 0:3bde34c58439 | 83 | int hour =12; // 2-23 |
elirobelo | 0:3bde34c58439 | 84 | int dayofmonth =26; // 1-31 |
elirobelo | 0:3bde34c58439 | 85 | int month =8; // 1-12 |
elirobelo | 0:3bde34c58439 | 86 | int year =15; // last 2 digits |
elirobelo | 0:3bde34c58439 | 87 | |
elirobelo | 0:3bde34c58439 | 88 | |
elirobelo | 0:3bde34c58439 | 89 | int checkColorSensor() { |
elirobelo | 0:3bde34c58439 | 90 | while (1) { |
elirobelo | 0:3bde34c58439 | 91 | data_present = RGBsensor.Read(ISL29125_RGB, GRBdata); |
elirobelo | 0:3bde34c58439 | 92 | if(data_present) printf("RGB : %04X-%04X-%04X\r\n", GRBdata[1], GRBdata[0], GRBdata[2]); |
elirobelo | 0:3bde34c58439 | 93 | // if (GRBdata[1] < 0x02F0 && GRBdata[1] > 0x0210 && GRBdata[0] > 0x0120 && GRBdata[0] < 0x01F0 && GRBdata[2] < 0x0180 && GRBdata[2] > 0x00D0) { |
elirobelo | 0:3bde34c58439 | 94 | // return 1; //red |
elirobelo | 0:3bde34c58439 | 95 | // } |
elirobelo | 0:3bde34c58439 | 96 | // if (GRBdata[1] < 0x0210 && GRBdata[1] > 0x0100 && GRBdata[0] > 0x0100 && GRBdata[0] < 0x0200 && GRBdata[2] < 0x0190 && GRBdata[2] > 0x00CF) { |
elirobelo | 0:3bde34c58439 | 97 | // return 3; //blue |
elirobelo | 0:3bde34c58439 | 98 | // } |
elirobelo | 0:3bde34c58439 | 99 | if (GRBdata[1] < 0x00E0 && GRBdata[1] > 0x0060 && GRBdata[0] < 0x00F0 && GRBdata[0] > 0x0020 && GRBdata[2] < 0x00B0 && GRBdata[0] > 0x0040) { |
elirobelo | 0:3bde34c58439 | 100 | return 3; //blue |
elirobelo | 0:3bde34c58439 | 101 | } |
elirobelo | 0:3bde34c58439 | 102 | if (GRBdata[1] < 0x0170 && GRBdata[1] > 0x00D0 && GRBdata[0] < 0x0120 && GRBdata[0] > 0x0040 && GRBdata[2] > 0x0030 && GRBdata[2] < 0x00A0) { |
elirobelo | 0:3bde34c58439 | 103 | return 1; //red |
elirobelo | 0:3bde34c58439 | 104 | } |
elirobelo | 0:3bde34c58439 | 105 | } |
elirobelo | 0:3bde34c58439 | 106 | } |
elirobelo | 0:3bde34c58439 | 107 | |
elirobelo | 0:3bde34c58439 | 108 | |
elirobelo | 0:3bde34c58439 | 109 | int main() |
elirobelo | 0:3bde34c58439 | 110 | { |
elirobelo | 0:3bde34c58439 | 111 | pc.baud(9600); |
elirobelo | 0:3bde34c58439 | 112 | esp.baud(9600); |
elirobelo | 0:3bde34c58439 | 113 | led1=1,led2=0,led3=0, led4=0; |
elirobelo | 0:3bde34c58439 | 114 | m.speed(.7); |
elirobelo | 0:3bde34c58439 | 115 | //m = .5; |
elirobelo | 0:3bde34c58439 | 116 | // Setup a serial interrupt function to receive data |
elirobelo | 0:3bde34c58439 | 117 | esp.attach(&Rx_interrupt, Serial::RxIrq); |
elirobelo | 0:3bde34c58439 | 118 | // Setup a serial interrupt function to transmit data |
elirobelo | 0:3bde34c58439 | 119 | esp.attach(&Tx_interrupt, Serial::TxIrq); |
elirobelo | 0:3bde34c58439 | 120 | if (time(NULL) < 1420070400) { |
elirobelo | 0:3bde34c58439 | 121 | setRTC(); |
elirobelo | 0:3bde34c58439 | 122 | } |
elirobelo | 0:3bde34c58439 | 123 | startserver(); |
elirobelo | 0:3bde34c58439 | 124 | DataRX=0; |
elirobelo | 0:3bde34c58439 | 125 | count=0; |
elirobelo | 0:3bde34c58439 | 126 | while(1) { |
elirobelo | 0:3bde34c58439 | 127 | if(DataRX==1) { |
elirobelo | 0:3bde34c58439 | 128 | ReadWebData(); |
elirobelo | 0:3bde34c58439 | 129 | esp.attach(&Rx_interrupt, Serial::RxIrq); |
elirobelo | 0:3bde34c58439 | 130 | } |
elirobelo | 0:3bde34c58439 | 131 | if(update==1) // update time, hit count, and analog levels in the HUZZAH chip |
elirobelo | 0:3bde34c58439 | 132 | { |
elirobelo | 0:3bde34c58439 | 133 | // get new values |
elirobelo | 0:3bde34c58439 | 134 | gettime(); |
elirobelo | 0:3bde34c58439 | 135 | count++; |
elirobelo | 0:3bde34c58439 | 136 | // send new values |
elirobelo | 0:3bde34c58439 | 137 | sprintf(cmdbuff, "count,time,analog1,analog2=%d,\"%s\",\"%s\",\"%s\"\r\n",count,timebuf,Temp,Vcc); |
elirobelo | 0:3bde34c58439 | 138 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 139 | getreply(); |
elirobelo | 0:3bde34c58439 | 140 | update=0; |
elirobelo | 0:3bde34c58439 | 141 | } |
elirobelo | 0:3bde34c58439 | 142 | if (color != 0 && direction != 0) { |
elirobelo | 0:3bde34c58439 | 143 | while(!correct){ |
elirobelo | 0:3bde34c58439 | 144 | sensorValue = checkColorSensor(); |
elirobelo | 0:3bde34c58439 | 145 | if (sensorValue == color) { |
elirobelo | 0:3bde34c58439 | 146 | correct = true; |
elirobelo | 0:3bde34c58439 | 147 | color = 0; |
elirobelo | 0:3bde34c58439 | 148 | } |
elirobelo | 0:3bde34c58439 | 149 | } |
elirobelo | 0:3bde34c58439 | 150 | while(correct) { |
elirobelo | 0:3bde34c58439 | 151 | printf("percentage Sensor1: %3.3f%%\r\n", sen1.read()); |
elirobelo | 0:3bde34c58439 | 152 | printf("percentage Sensor2: %3.3f%%\r\n", sen2.read()); |
elirobelo | 0:3bde34c58439 | 153 | printf("percentage Sensor3: %3.3f%%\r\n", sen3.read()); |
elirobelo | 0:3bde34c58439 | 154 | printf("percentage Sensor4: %3.3f%%\r\n", sen4.read()); |
elirobelo | 0:3bde34c58439 | 155 | printf("direction: %d\r\n", direction); |
elirobelo | 0:3bde34c58439 | 156 | if (direction == 1 && sen1.read() < .82) { |
elirobelo | 0:3bde34c58439 | 157 | sol4 = 1; |
elirobelo | 0:3bde34c58439 | 158 | wait(1); |
elirobelo | 0:3bde34c58439 | 159 | correct = false; |
elirobelo | 0:3bde34c58439 | 160 | } |
elirobelo | 0:3bde34c58439 | 161 | if (direction == 2 && sen2.read() < .83) { |
elirobelo | 0:3bde34c58439 | 162 | sol3 = 1; |
elirobelo | 0:3bde34c58439 | 163 | wait(1); |
elirobelo | 0:3bde34c58439 | 164 | correct = false; |
elirobelo | 0:3bde34c58439 | 165 | } |
elirobelo | 0:3bde34c58439 | 166 | if (direction == 3 && sen3.read() < .815) { |
elirobelo | 0:3bde34c58439 | 167 | sol2 = 1; |
elirobelo | 0:3bde34c58439 | 168 | wait(1); |
elirobelo | 0:3bde34c58439 | 169 | correct = false; |
elirobelo | 0:3bde34c58439 | 170 | } |
elirobelo | 0:3bde34c58439 | 171 | if (direction == 4 && sen4.read() < .81) { |
elirobelo | 0:3bde34c58439 | 172 | sol1 = 1; |
elirobelo | 0:3bde34c58439 | 173 | wait(1); |
elirobelo | 0:3bde34c58439 | 174 | correct = false; |
elirobelo | 0:3bde34c58439 | 175 | } |
elirobelo | 0:3bde34c58439 | 176 | } |
elirobelo | 0:3bde34c58439 | 177 | } |
elirobelo | 0:3bde34c58439 | 178 | sol1 = 0; |
elirobelo | 0:3bde34c58439 | 179 | sol2 = 0; |
elirobelo | 0:3bde34c58439 | 180 | sol3 = 0; |
elirobelo | 0:3bde34c58439 | 181 | sol4 = 0; |
elirobelo | 0:3bde34c58439 | 182 | direction = 0; |
elirobelo | 0:3bde34c58439 | 183 | } |
elirobelo | 0:3bde34c58439 | 184 | } |
elirobelo | 0:3bde34c58439 | 185 | |
elirobelo | 0:3bde34c58439 | 186 | // Reads and processes GET and POST web data |
elirobelo | 0:3bde34c58439 | 187 | void ReadWebData() |
elirobelo | 0:3bde34c58439 | 188 | { |
elirobelo | 0:3bde34c58439 | 189 | wait_ms(200); |
elirobelo | 0:3bde34c58439 | 190 | esp.attach(NULL,Serial::RxIrq); |
elirobelo | 0:3bde34c58439 | 191 | DataRX=0; |
elirobelo | 0:3bde34c58439 | 192 | memset(webdata, '\0', sizeof(webdata)); |
elirobelo | 0:3bde34c58439 | 193 | strcpy(webdata, rx_buffer); |
elirobelo | 0:3bde34c58439 | 194 | memset(rx_buffer, '\0', sizeof(rx_buffer)); |
elirobelo | 0:3bde34c58439 | 195 | rx_in = 0; |
elirobelo | 0:3bde34c58439 | 196 | rx_out = 0; |
elirobelo | 0:3bde34c58439 | 197 | // check web data for form information |
elirobelo | 0:3bde34c58439 | 198 | if( strstr(webdata, "box=r") != NULL ) { |
elirobelo | 0:3bde34c58439 | 199 | //check for red |
elirobelo | 0:3bde34c58439 | 200 | color = 1; |
elirobelo | 0:3bde34c58439 | 201 | // while(!correct) { |
elirobelo | 0:3bde34c58439 | 202 | // color = checkColorSensor(); |
elirobelo | 0:3bde34c58439 | 203 | // if (color == 1) correct = true; |
elirobelo | 0:3bde34c58439 | 204 | // } |
elirobelo | 0:3bde34c58439 | 205 | //correct = true; |
elirobelo | 0:3bde34c58439 | 206 | led1=!led1; |
elirobelo | 0:3bde34c58439 | 207 | } |
elirobelo | 0:3bde34c58439 | 208 | // if( strstr(webdata, "box=g") != NULL ) { |
elirobelo | 0:3bde34c58439 | 209 | // color = 2; |
elirobelo | 0:3bde34c58439 | 210 | //// while(!correct) { |
elirobelo | 0:3bde34c58439 | 211 | //// color = checkColorSensor(); |
elirobelo | 0:3bde34c58439 | 212 | //// if (color == 2) correct = true; |
elirobelo | 0:3bde34c58439 | 213 | //// } |
elirobelo | 0:3bde34c58439 | 214 | // //check for green |
elirobelo | 0:3bde34c58439 | 215 | // led2=!led2; |
elirobelo | 0:3bde34c58439 | 216 | // } |
elirobelo | 0:3bde34c58439 | 217 | if( strstr(webdata, "box=b") != NULL ) { |
elirobelo | 0:3bde34c58439 | 218 | //check for blue |
elirobelo | 0:3bde34c58439 | 219 | color = 3; |
elirobelo | 0:3bde34c58439 | 220 | // while(!correct) { |
elirobelo | 0:3bde34c58439 | 221 | // color = checkColorSensor(); |
elirobelo | 0:3bde34c58439 | 222 | // if (color == 3) correct = true; |
elirobelo | 0:3bde34c58439 | 223 | // } |
elirobelo | 0:3bde34c58439 | 224 | led3=!led3; |
elirobelo | 0:3bde34c58439 | 225 | } |
elirobelo | 0:3bde34c58439 | 226 | if( strstr(webdata, "direction=north") != NULL ) { |
elirobelo | 0:3bde34c58439 | 227 | led4=!led4; |
elirobelo | 0:3bde34c58439 | 228 | direction = 1; |
elirobelo | 0:3bde34c58439 | 229 | // while(correct) { |
elirobelo | 0:3bde34c58439 | 230 | // if (sen1.read() < .8) { |
elirobelo | 0:3bde34c58439 | 231 | // //wait(.2); |
elirobelo | 0:3bde34c58439 | 232 | // sol1 = 1; |
elirobelo | 0:3bde34c58439 | 233 | // correct = false; |
elirobelo | 0:3bde34c58439 | 234 | // } |
elirobelo | 0:3bde34c58439 | 235 | // } |
elirobelo | 0:3bde34c58439 | 236 | // sol1 = false; |
elirobelo | 0:3bde34c58439 | 237 | } |
elirobelo | 0:3bde34c58439 | 238 | if( strstr(webdata, "direction=south") != NULL ) { |
elirobelo | 0:3bde34c58439 | 239 | led4=!led4; |
elirobelo | 0:3bde34c58439 | 240 | direction = 2; |
elirobelo | 0:3bde34c58439 | 241 | // while(correct) { |
elirobelo | 0:3bde34c58439 | 242 | // if (sen2.read() < .8) { |
elirobelo | 0:3bde34c58439 | 243 | // //wait(.2); |
elirobelo | 0:3bde34c58439 | 244 | // sol2 = 1; |
elirobelo | 0:3bde34c58439 | 245 | // correct = false; |
elirobelo | 0:3bde34c58439 | 246 | // } |
elirobelo | 0:3bde34c58439 | 247 | // } |
elirobelo | 0:3bde34c58439 | 248 | // sol2 = false; |
elirobelo | 0:3bde34c58439 | 249 | } |
elirobelo | 0:3bde34c58439 | 250 | if( strstr(webdata, "direction=east") != NULL ) { |
elirobelo | 0:3bde34c58439 | 251 | led4=!led4; |
elirobelo | 0:3bde34c58439 | 252 | direction = 3; |
elirobelo | 0:3bde34c58439 | 253 | // while(correct) { |
elirobelo | 0:3bde34c58439 | 254 | // if (sen3.read() < .8) { |
elirobelo | 0:3bde34c58439 | 255 | // //wait(.2); |
elirobelo | 0:3bde34c58439 | 256 | // sol3 = 1; |
elirobelo | 0:3bde34c58439 | 257 | // correct = false; |
elirobelo | 0:3bde34c58439 | 258 | // } |
elirobelo | 0:3bde34c58439 | 259 | // } |
elirobelo | 0:3bde34c58439 | 260 | } |
elirobelo | 0:3bde34c58439 | 261 | if( strstr(webdata, "direction=west") != NULL ) { |
elirobelo | 0:3bde34c58439 | 262 | led4=!led4; |
elirobelo | 0:3bde34c58439 | 263 | direction = 4; |
elirobelo | 0:3bde34c58439 | 264 | // while(correct) { |
elirobelo | 0:3bde34c58439 | 265 | // if (sen4.read() < .8) { |
elirobelo | 0:3bde34c58439 | 266 | // //wait(.2); |
elirobelo | 0:3bde34c58439 | 267 | // sol4 = 1; |
elirobelo | 0:3bde34c58439 | 268 | // correct = false; |
elirobelo | 0:3bde34c58439 | 269 | // } |
elirobelo | 0:3bde34c58439 | 270 | // } |
elirobelo | 0:3bde34c58439 | 271 | // sol4 = 0; |
elirobelo | 0:3bde34c58439 | 272 | } |
elirobelo | 0:3bde34c58439 | 273 | if( strstr(webdata, "POST") != NULL ) { // set update flag if POST request |
elirobelo | 0:3bde34c58439 | 274 | update=1; |
elirobelo | 0:3bde34c58439 | 275 | } |
elirobelo | 0:3bde34c58439 | 276 | if( strstr(webdata, "GET") != NULL && strstr(webdata, "favicon") == NULL ) { // set update flag for GET request but do not want to update for favicon requests |
elirobelo | 0:3bde34c58439 | 277 | update=1; |
elirobelo | 0:3bde34c58439 | 278 | } |
elirobelo | 0:3bde34c58439 | 279 | } |
elirobelo | 0:3bde34c58439 | 280 | // Starts webserver |
elirobelo | 0:3bde34c58439 | 281 | void startserver() |
elirobelo | 0:3bde34c58439 | 282 | { |
elirobelo | 0:3bde34c58439 | 283 | gettime(); |
elirobelo | 0:3bde34c58439 | 284 | //gettemp(); |
elirobelo | 0:3bde34c58439 | 285 | //getbattery(); |
elirobelo | 0:3bde34c58439 | 286 | pc.printf("++++++++++ Resetting ESP ++++++++++\r\n"); |
elirobelo | 0:3bde34c58439 | 287 | strcpy(cmdbuff,"node.restart()\r\n"); |
elirobelo | 0:3bde34c58439 | 288 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 289 | wait(2); |
elirobelo | 0:3bde34c58439 | 290 | getreply(); |
elirobelo | 0:3bde34c58439 | 291 | |
elirobelo | 0:3bde34c58439 | 292 | pc.printf("\n++++++++++ Starting Server ++++++++++\r\n> "); |
elirobelo | 0:3bde34c58439 | 293 | |
elirobelo | 0:3bde34c58439 | 294 | // initial values |
elirobelo | 0:3bde34c58439 | 295 | sprintf(cmdbuff, "count,time,analog1,analog2=0,\"%s\",\"%s\",\"%s\"\r\n",timebuf,Temp,Vcc); |
elirobelo | 0:3bde34c58439 | 296 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 297 | getreply(); |
elirobelo | 0:3bde34c58439 | 298 | wait(0.5); |
elirobelo | 0:3bde34c58439 | 299 | |
elirobelo | 0:3bde34c58439 | 300 | //create server |
elirobelo | 0:3bde34c58439 | 301 | sprintf(cmdbuff, "srv=net.createServer(net.TCP,%d)\r\n",SERVtimeout); |
elirobelo | 0:3bde34c58439 | 302 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 303 | getreply(); |
elirobelo | 0:3bde34c58439 | 304 | wait(0.5); |
elirobelo | 0:3bde34c58439 | 305 | strcpy(cmdbuff,"srv:listen(80,function(conn)\r\n"); |
elirobelo | 0:3bde34c58439 | 306 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 307 | getreply(); |
elirobelo | 0:3bde34c58439 | 308 | wait(0.3); |
elirobelo | 0:3bde34c58439 | 309 | strcpy(cmdbuff,"conn:on(\"receive\",function(conn,payload) \r\n"); |
elirobelo | 0:3bde34c58439 | 310 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 311 | getreply(); |
elirobelo | 0:3bde34c58439 | 312 | wait(0.3); |
elirobelo | 0:3bde34c58439 | 313 | |
elirobelo | 0:3bde34c58439 | 314 | //print data to mbed |
elirobelo | 0:3bde34c58439 | 315 | strcpy(cmdbuff,"print(payload)\r\n"); |
elirobelo | 0:3bde34c58439 | 316 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 317 | getreply(); |
elirobelo | 0:3bde34c58439 | 318 | wait(0.2); |
elirobelo | 0:3bde34c58439 | 319 | |
elirobelo | 0:3bde34c58439 | 320 | //web page data |
elirobelo | 0:3bde34c58439 | 321 | strcpy(cmdbuff,"conn:send('<!DOCTYPE html><html><body><h1>Checkout</h1>')\r\n"); |
elirobelo | 0:3bde34c58439 | 322 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 323 | getreply(); |
elirobelo | 0:3bde34c58439 | 324 | wait(0.4); |
elirobelo | 0:3bde34c58439 | 325 | strcpy(cmdbuff,"conn:send('Hit count: '..count..'')\r\n"); |
elirobelo | 0:3bde34c58439 | 326 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 327 | getreply(); |
elirobelo | 0:3bde34c58439 | 328 | wait(0.2); |
elirobelo | 0:3bde34c58439 | 329 | strcpy(cmdbuff,"conn:send('<br>Last hit (based on mbed RTC time): '..time..'<br><hr>')\r\n"); |
elirobelo | 0:3bde34c58439 | 330 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 331 | getreply(); |
elirobelo | 0:3bde34c58439 | 332 | wait(0.4); |
elirobelo | 0:3bde34c58439 | 333 | strcpy(cmdbuff, "conn:send('<p><h2>Choose a Package Option</h2><ul>')\r\n"); |
elirobelo | 0:3bde34c58439 | 334 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 335 | getreply(); |
elirobelo | 0:3bde34c58439 | 336 | wait(0.5); |
elirobelo | 0:3bde34c58439 | 337 | strcpy(cmdbuff,"conn:send('<form method=\"POST\"')\r\n"); |
elirobelo | 0:3bde34c58439 | 338 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 339 | getreply(); |
elirobelo | 0:3bde34c58439 | 340 | wait(0.3); |
elirobelo | 0:3bde34c58439 | 341 | |
elirobelo | 0:3bde34c58439 | 342 | |
elirobelo | 0:3bde34c58439 | 343 | //Package Options |
elirobelo | 0:3bde34c58439 | 344 | strcpy(cmdbuff, "conn:send('<p><input type=\"radio\" name=\"box\" value=\"r\" checked> Red')\r\n"); |
elirobelo | 0:3bde34c58439 | 345 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 346 | getreply(); |
elirobelo | 0:3bde34c58439 | 347 | wait(0.3); |
elirobelo | 0:3bde34c58439 | 348 | strcpy(cmdbuff, "conn:send('<p><input type=\"radio\" name=\"box\" value=\"b\" > Blue')\r\n"); |
elirobelo | 0:3bde34c58439 | 349 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 350 | getreply(); |
elirobelo | 0:3bde34c58439 | 351 | wait(0.3); |
elirobelo | 0:3bde34c58439 | 352 | // strcpy(cmdbuff, "conn:send('<p><input type=\"radio\" name=\"box\" value=\"g\" > Green')\r\n"); |
elirobelo | 0:3bde34c58439 | 353 | // SendCMD(); |
elirobelo | 0:3bde34c58439 | 354 | // getreply(); |
elirobelo | 0:3bde34c58439 | 355 | // wait(0.3); |
elirobelo | 0:3bde34c58439 | 356 | |
elirobelo | 0:3bde34c58439 | 357 | |
elirobelo | 0:3bde34c58439 | 358 | |
elirobelo | 0:3bde34c58439 | 359 | //Direction Options |
elirobelo | 0:3bde34c58439 | 360 | strcpy(cmdbuff, "conn:send('<br><p><h2>What direction?</h2><ul>')\r\n"); |
elirobelo | 0:3bde34c58439 | 361 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 362 | getreply(); |
elirobelo | 0:3bde34c58439 | 363 | wait(0.5); |
elirobelo | 0:3bde34c58439 | 364 | |
elirobelo | 0:3bde34c58439 | 365 | strcpy(cmdbuff, "conn:send('<p><input type=\"radio\" name=\"direction\" value=\"north\" checked> North')\r\n"); |
elirobelo | 0:3bde34c58439 | 366 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 367 | getreply(); |
elirobelo | 0:3bde34c58439 | 368 | wait(0.3); |
elirobelo | 0:3bde34c58439 | 369 | strcpy(cmdbuff, "conn:send('<p><input type=\"radio\" name=\"direction\" value=\"south\" > South')\r\n"); |
elirobelo | 0:3bde34c58439 | 370 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 371 | getreply(); |
elirobelo | 0:3bde34c58439 | 372 | wait(0.3); |
elirobelo | 0:3bde34c58439 | 373 | strcpy(cmdbuff, "conn:send('<p><input type=\"radio\" name=\"direction\" value=\"east\" > East')\r\n"); |
elirobelo | 0:3bde34c58439 | 374 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 375 | getreply(); |
elirobelo | 0:3bde34c58439 | 376 | wait(0.3); |
elirobelo | 0:3bde34c58439 | 377 | strcpy(cmdbuff, "conn:send('<p><input type=\"radio\" name=\"direction\" value=\"west\" > West')\r\n"); |
elirobelo | 0:3bde34c58439 | 378 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 379 | getreply(); |
elirobelo | 0:3bde34c58439 | 380 | wait(0.3); |
elirobelo | 0:3bde34c58439 | 381 | |
elirobelo | 0:3bde34c58439 | 382 | |
elirobelo | 0:3bde34c58439 | 383 | //Submit button |
elirobelo | 0:3bde34c58439 | 384 | strcpy(cmdbuff,"conn:send('<p><input type=\"submit\" value=\"send-refresh\"></form>')\r\n"); |
elirobelo | 0:3bde34c58439 | 385 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 386 | getreply(); |
elirobelo | 0:3bde34c58439 | 387 | wait(0.3); |
elirobelo | 0:3bde34c58439 | 388 | |
elirobelo | 0:3bde34c58439 | 389 | |
elirobelo | 0:3bde34c58439 | 390 | // End web page data |
elirobelo | 0:3bde34c58439 | 391 | strcpy(cmdbuff, "conn:on(\"sent\",function(conn) conn:close() end)\r\n"); // close current connection |
elirobelo | 0:3bde34c58439 | 392 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 393 | getreply(); |
elirobelo | 0:3bde34c58439 | 394 | wait(0.3); |
elirobelo | 0:3bde34c58439 | 395 | strcpy(cmdbuff, "end)\r\n"); |
elirobelo | 0:3bde34c58439 | 396 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 397 | getreply(); |
elirobelo | 0:3bde34c58439 | 398 | wait(0.2); |
elirobelo | 0:3bde34c58439 | 399 | strcpy(cmdbuff, "end)\r\n"); |
elirobelo | 0:3bde34c58439 | 400 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 401 | getreply(); |
elirobelo | 0:3bde34c58439 | 402 | wait(0.2); |
elirobelo | 0:3bde34c58439 | 403 | |
elirobelo | 0:3bde34c58439 | 404 | strcpy(cmdbuff, "tmr.alarm(0, 1000, 1, function()\r\n"); |
elirobelo | 0:3bde34c58439 | 405 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 406 | getreply(); |
elirobelo | 0:3bde34c58439 | 407 | wait(0.2); |
elirobelo | 0:3bde34c58439 | 408 | strcpy(cmdbuff, "if wifi.sta.getip() == nil then\r\n"); |
elirobelo | 0:3bde34c58439 | 409 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 410 | getreply(); |
elirobelo | 0:3bde34c58439 | 411 | wait(0.2); |
elirobelo | 0:3bde34c58439 | 412 | strcpy(cmdbuff, "print(\"Connecting to AP...\\n\")\r\n"); |
elirobelo | 0:3bde34c58439 | 413 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 414 | getreply(); |
elirobelo | 0:3bde34c58439 | 415 | wait(0.2); |
elirobelo | 0:3bde34c58439 | 416 | strcpy(cmdbuff, "else\r\n"); |
elirobelo | 0:3bde34c58439 | 417 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 418 | getreply(); |
elirobelo | 0:3bde34c58439 | 419 | wait(0.2); |
elirobelo | 0:3bde34c58439 | 420 | strcpy(cmdbuff, "ip, nm, gw=wifi.sta.getip()\r\n"); |
elirobelo | 0:3bde34c58439 | 421 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 422 | getreply(); |
elirobelo | 0:3bde34c58439 | 423 | wait(0.2); |
elirobelo | 0:3bde34c58439 | 424 | strcpy(cmdbuff,"print(\"IP Address: \",ip)\r\n"); |
elirobelo | 0:3bde34c58439 | 425 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 426 | getreply(); |
elirobelo | 0:3bde34c58439 | 427 | wait(0.2); |
elirobelo | 0:3bde34c58439 | 428 | strcpy(cmdbuff,"tmr.stop(0)\r\n"); |
elirobelo | 0:3bde34c58439 | 429 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 430 | getreply(); |
elirobelo | 0:3bde34c58439 | 431 | wait(0.2); |
elirobelo | 0:3bde34c58439 | 432 | strcpy(cmdbuff,"end\r\n"); |
elirobelo | 0:3bde34c58439 | 433 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 434 | getreply(); |
elirobelo | 0:3bde34c58439 | 435 | wait(0.2); |
elirobelo | 0:3bde34c58439 | 436 | strcpy(cmdbuff,"end)\r\n"); |
elirobelo | 0:3bde34c58439 | 437 | SendCMD(); |
elirobelo | 0:3bde34c58439 | 438 | getreply(); |
elirobelo | 0:3bde34c58439 | 439 | wait(0.2); |
elirobelo | 0:3bde34c58439 | 440 | |
elirobelo | 0:3bde34c58439 | 441 | pc.printf("\n\n++++++++++ Ready ++++++++++\r\n\n"); |
elirobelo | 0:3bde34c58439 | 442 | } |
elirobelo | 0:3bde34c58439 | 443 | |
elirobelo | 0:3bde34c58439 | 444 | |
elirobelo | 0:3bde34c58439 | 445 | // ESP Command data send |
elirobelo | 0:3bde34c58439 | 446 | void SendCMD() |
elirobelo | 0:3bde34c58439 | 447 | { |
elirobelo | 0:3bde34c58439 | 448 | int i; |
elirobelo | 0:3bde34c58439 | 449 | char temp_char; |
elirobelo | 0:3bde34c58439 | 450 | bool empty; |
elirobelo | 0:3bde34c58439 | 451 | i = 0; |
elirobelo | 0:3bde34c58439 | 452 | // Start Critical Section - don't interrupt while changing global buffer variables |
elirobelo | 0:3bde34c58439 | 453 | NVIC_DisableIRQ(UART1_IRQn); |
elirobelo | 0:3bde34c58439 | 454 | empty = (tx_in == tx_out); |
elirobelo | 0:3bde34c58439 | 455 | while ((i==0) || (cmdbuff[i-1] != '\n')) { |
elirobelo | 0:3bde34c58439 | 456 | // Wait if buffer full |
elirobelo | 0:3bde34c58439 | 457 | if (((tx_in + 1) % buffer_size) == tx_out) { |
elirobelo | 0:3bde34c58439 | 458 | // End Critical Section - need to let interrupt routine empty buffer by sending |
elirobelo | 0:3bde34c58439 | 459 | NVIC_EnableIRQ(UART1_IRQn); |
elirobelo | 0:3bde34c58439 | 460 | while (((tx_in + 1) % buffer_size) == tx_out) { |
elirobelo | 0:3bde34c58439 | 461 | } |
elirobelo | 0:3bde34c58439 | 462 | // Start Critical Section - don't interrupt while changing global buffer variables |
elirobelo | 0:3bde34c58439 | 463 | NVIC_DisableIRQ(UART1_IRQn); |
elirobelo | 0:3bde34c58439 | 464 | } |
elirobelo | 0:3bde34c58439 | 465 | tx_buffer[tx_in] = cmdbuff[i]; |
elirobelo | 0:3bde34c58439 | 466 | i++; |
elirobelo | 0:3bde34c58439 | 467 | tx_in = (tx_in + 1) % buffer_size; |
elirobelo | 0:3bde34c58439 | 468 | } |
elirobelo | 0:3bde34c58439 | 469 | if (esp.writeable() && (empty)) { |
elirobelo | 0:3bde34c58439 | 470 | temp_char = tx_buffer[tx_out]; |
elirobelo | 0:3bde34c58439 | 471 | tx_out = (tx_out + 1) % buffer_size; |
elirobelo | 0:3bde34c58439 | 472 | // Send first character to start tx interrupts, if stopped |
elirobelo | 0:3bde34c58439 | 473 | esp.putc(temp_char); |
elirobelo | 0:3bde34c58439 | 474 | } |
elirobelo | 0:3bde34c58439 | 475 | // End Critical Section |
elirobelo | 0:3bde34c58439 | 476 | NVIC_EnableIRQ(UART1_IRQn); |
elirobelo | 0:3bde34c58439 | 477 | return; |
elirobelo | 0:3bde34c58439 | 478 | } |
elirobelo | 0:3bde34c58439 | 479 | |
elirobelo | 0:3bde34c58439 | 480 | // Get Command and ESP status replies |
elirobelo | 0:3bde34c58439 | 481 | void getreply() |
elirobelo | 0:3bde34c58439 | 482 | { |
elirobelo | 0:3bde34c58439 | 483 | read_line(); |
elirobelo | 0:3bde34c58439 | 484 | sscanf(rx_line,replybuff); |
elirobelo | 0:3bde34c58439 | 485 | } |
elirobelo | 0:3bde34c58439 | 486 | |
elirobelo | 0:3bde34c58439 | 487 | // Read a line from the large rx buffer from rx interrupt routine |
elirobelo | 0:3bde34c58439 | 488 | void read_line() { |
elirobelo | 0:3bde34c58439 | 489 | int i; |
elirobelo | 0:3bde34c58439 | 490 | i = 0; |
elirobelo | 0:3bde34c58439 | 491 | // Start Critical Section - don't interrupt while changing global buffer variables |
elirobelo | 0:3bde34c58439 | 492 | NVIC_DisableIRQ(UART1_IRQn); |
elirobelo | 0:3bde34c58439 | 493 | // Loop reading rx buffer characters until end of line character |
elirobelo | 0:3bde34c58439 | 494 | while ((i==0) || (rx_line[i-1] != '\r')) { |
elirobelo | 0:3bde34c58439 | 495 | // Wait if buffer empty |
elirobelo | 0:3bde34c58439 | 496 | if (rx_in == rx_out) { |
elirobelo | 0:3bde34c58439 | 497 | // End Critical Section - need to allow rx interrupt to get new characters for buffer |
elirobelo | 0:3bde34c58439 | 498 | NVIC_EnableIRQ(UART1_IRQn); |
elirobelo | 0:3bde34c58439 | 499 | while (rx_in == rx_out) { |
elirobelo | 0:3bde34c58439 | 500 | } |
elirobelo | 0:3bde34c58439 | 501 | // Start Critical Section - don't interrupt while changing global buffer variables |
elirobelo | 0:3bde34c58439 | 502 | NVIC_DisableIRQ(UART1_IRQn); |
elirobelo | 0:3bde34c58439 | 503 | } |
elirobelo | 0:3bde34c58439 | 504 | rx_line[i] = rx_buffer[rx_out]; |
elirobelo | 0:3bde34c58439 | 505 | i++; |
elirobelo | 0:3bde34c58439 | 506 | rx_out = (rx_out + 1) % buffer_size; |
elirobelo | 0:3bde34c58439 | 507 | } |
elirobelo | 0:3bde34c58439 | 508 | // End Critical Section |
elirobelo | 0:3bde34c58439 | 509 | NVIC_EnableIRQ(UART1_IRQn); |
elirobelo | 0:3bde34c58439 | 510 | rx_line[i-1] = 0; |
elirobelo | 0:3bde34c58439 | 511 | return; |
elirobelo | 0:3bde34c58439 | 512 | } |
elirobelo | 0:3bde34c58439 | 513 | |
elirobelo | 0:3bde34c58439 | 514 | |
elirobelo | 0:3bde34c58439 | 515 | // Interupt Routine to read in data from serial port |
elirobelo | 0:3bde34c58439 | 516 | void Rx_interrupt() { |
elirobelo | 0:3bde34c58439 | 517 | DataRX=1; |
elirobelo | 0:3bde34c58439 | 518 | //led3=1; |
elirobelo | 0:3bde34c58439 | 519 | // Loop just in case more than one character is in UART's receive FIFO buffer |
elirobelo | 0:3bde34c58439 | 520 | // Stop if buffer full |
elirobelo | 0:3bde34c58439 | 521 | while ((esp.readable()) && (((rx_in + 1) % buffer_size) != rx_out)) { |
elirobelo | 0:3bde34c58439 | 522 | rx_buffer[rx_in] = esp.getc(); |
elirobelo | 0:3bde34c58439 | 523 | // Uncomment to Echo to USB serial to watch data flow |
elirobelo | 0:3bde34c58439 | 524 | pc.putc(rx_buffer[rx_in]); |
elirobelo | 0:3bde34c58439 | 525 | rx_in = (rx_in + 1) % buffer_size; |
elirobelo | 0:3bde34c58439 | 526 | } |
elirobelo | 0:3bde34c58439 | 527 | //led3=0; |
elirobelo | 0:3bde34c58439 | 528 | return; |
elirobelo | 0:3bde34c58439 | 529 | } |
elirobelo | 0:3bde34c58439 | 530 | |
elirobelo | 0:3bde34c58439 | 531 | |
elirobelo | 0:3bde34c58439 | 532 | // Interupt Routine to write out data to serial port |
elirobelo | 0:3bde34c58439 | 533 | void Tx_interrupt() { |
elirobelo | 0:3bde34c58439 | 534 | //led2=1; |
elirobelo | 0:3bde34c58439 | 535 | // Loop to fill more than one character in UART's transmit FIFO buffer |
elirobelo | 0:3bde34c58439 | 536 | // Stop if buffer empty |
elirobelo | 0:3bde34c58439 | 537 | while ((esp.writeable()) && (tx_in != tx_out)) { |
elirobelo | 0:3bde34c58439 | 538 | esp.putc(tx_buffer[tx_out]); |
elirobelo | 0:3bde34c58439 | 539 | tx_out = (tx_out + 1) % buffer_size; |
elirobelo | 0:3bde34c58439 | 540 | } |
elirobelo | 0:3bde34c58439 | 541 | //led2=0; |
elirobelo | 0:3bde34c58439 | 542 | return; |
elirobelo | 0:3bde34c58439 | 543 | } |
elirobelo | 0:3bde34c58439 | 544 | |
elirobelo | 0:3bde34c58439 | 545 | void gettime() |
elirobelo | 0:3bde34c58439 | 546 | { |
elirobelo | 0:3bde34c58439 | 547 | time_t seconds = time(NULL); |
elirobelo | 0:3bde34c58439 | 548 | strftime(timebuf,50,"%H:%M:%S %a %d %b %y", localtime(&seconds)); |
elirobelo | 0:3bde34c58439 | 549 | } |
elirobelo | 0:3bde34c58439 | 550 | |
elirobelo | 0:3bde34c58439 | 551 | void setRTC() |
elirobelo | 0:3bde34c58439 | 552 | { |
elirobelo | 0:3bde34c58439 | 553 | t.tm_sec = (0); // 0-59 |
elirobelo | 0:3bde34c58439 | 554 | t.tm_min = (minute); // 0-59 |
elirobelo | 0:3bde34c58439 | 555 | t.tm_hour = (hour); // 0-23 |
elirobelo | 0:3bde34c58439 | 556 | t.tm_mday = (dayofmonth); // 1-31 |
elirobelo | 0:3bde34c58439 | 557 | t.tm_mon = (month-1); // 0-11 "0" = Jan, -1 added for Mbed RCT clock format |
elirobelo | 0:3bde34c58439 | 558 | t.tm_year = ((year)+100); // year since 1900, current DCF year + 100 + 1900 = correct year |
elirobelo | 0:3bde34c58439 | 559 | set_time(mktime(&t)); // set RTC clock |
elirobelo | 0:3bde34c58439 | 560 | } |
elirobelo | 0:3bde34c58439 | 561 | |
elirobelo | 0:3bde34c58439 | 562 | //void ALSread() |
elirobelo | 0:3bde34c58439 | 563 | //{ |
elirobelo | 0:3bde34c58439 | 564 | // data_present = RGBsensor.Read(ISL29125_RGB, GRBdata); |
elirobelo | 0:3bde34c58439 | 565 | // if(data_present) printf("RGB : %04X-%04X-%04X\r\n", GRBdata[1], GRBdata[0], GRBdata[2]); |
elirobelo | 0:3bde34c58439 | 566 | // if(Overflow) |
elirobelo | 0:3bde34c58439 | 567 | // { |
elirobelo | 0:3bde34c58439 | 568 | // printf("\r\nIRQ : %d\r\n",Overflow); |
elirobelo | 0:3bde34c58439 | 569 | // myled = !myled; |
elirobelo | 0:3bde34c58439 | 570 | // Overflow = 0; |
elirobelo | 0:3bde34c58439 | 571 | // } |
elirobelo | 0:3bde34c58439 | 572 | //} |
elirobelo | 0:3bde34c58439 | 573 |