Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BME280 BMP280 TextLCD mbed
putty.h
00001 #include "mbed.h" 00002 #include "data.h" 00003 Serial pc(USBTX, USBRX); 00004 char user_command[40] = {0}; 00005 char user_command2[40] = {0}; 00006 int n, datan = 0, datac = 0, counterd = 0, dates, times, interrupt = 0; 00007 float t; 00008 00009 00010 void readall() 00011 { 00012 datan = counterw; 00013 pc.printf("readall selected\n\r"); 00014 if (full == 1) 00015 { 00016 datac = 120; 00017 } 00018 else 00019 { 00020 datac = counterw; 00021 } 00022 pc.printf("printting %i datas\n\r", datac); 00023 while (counterd < datac) 00024 { 00025 pc.printf("light: %2.4f, temp: %3.4f, press: %3.4f\n\r", data_light[datan], data_temp [datan], data_press[datan]); 00026 if (datan == 0) 00027 { 00028 datan = 121; 00029 } 00030 datan--; 00031 counterd++; 00032 } 00033 counterd = 0; 00034 } 00035 00036 void readn() 00037 { 00038 00039 counterd = 0; 00040 n = atoi(user_command2); 00041 pc.printf("read %i datas\n\r",n); 00042 if (n > counterw) 00043 { 00044 pc.printf("we only have %i datas \n\r", counterw); 00045 } 00046 else 00047 { 00048 while (counterd < n) 00049 { 00050 pc.printf("light: %2.4f, temp: %3.4f, press: %3.4f\n\r",data_light[datan], data_temp [datan], data_press[datan]); 00051 if (datan == 0) 00052 { 00053 datan = 121; 00054 } 00055 datan--; 00056 counterd++; 00057 } 00058 } 00059 } 00060 00061 void deleteall() 00062 { 00063 pc.printf("deleted %i datas \n\r", counterw); 00064 counterw = 0; 00065 int counter = 0; 00066 while (counter < 121) 00067 { 00068 data_light[counter] = 0; 00069 data_temp [counter] = 0; 00070 data_press[counter] = 0; 00071 counter ++; 00072 full = 0; 00073 } 00074 } 00075 00076 void deleten() 00077 { 00078 datan = counterw; 00079 counterd = 0; 00080 n = atoi(user_command2); 00081 if (n > counterw && full == 0) 00082 { 00083 pc.printf("we only have %i datas \n\r", counterw); 00084 } 00085 else if(full == 1 && n> 120) 00086 { 00087 pc.printf("we only have 120 datas \n\r"); 00088 } 00089 else if(full == 0 && n < counterw) 00090 { 00091 pc.printf("deleted %i datas \n\r", n); 00092 counterw = counterw-n; 00093 while (counterd < n) 00094 { 00095 data_light[datan] = 0; 00096 data_temp [datan] = 0; 00097 data_press[datan] = 0; 00098 counterd ++; 00099 datan--; 00100 } 00101 } 00102 else if(full == 1 && n < 120) 00103 { 00104 pc.printf("deleted %i datas \n\r", n); 00105 counterw = counterw-n; 00106 while (counterd < 120) 00107 { 00108 data_light[datan] = 0; 00109 data_temp [datan] = 0; 00110 data_press[datan] = 0; 00111 counterd ++; 00112 datan--; 00113 } 00114 } 00115 } 00116 //void fill(char c[20], char c2[20]) 00117 //{ 00118 // int counterino = 0; 00119 // while (counterino <21) 00120 // { 00121 // user_command[counterino] = c[counterino]; 00122 // user_command2[counterino] = c2[counterino]; 00123 // counterino++; 00124 // } 00125 00126 //} 00127 void clear() 00128 { 00129 int counter = 0; 00130 while (counter < 40) 00131 { 00132 user_command[counter] = 0; 00133 counter ++; 00134 } 00135 } 00136 00137 00138 void clear2() 00139 { 00140 int counter = 0; 00141 while (counter < 40) 00142 { 00143 user_command2[counter] = 0; 00144 counter ++; 00145 } 00146 } 00147 00148 void selection() 00149 { 00150 counterd = 0; 00151 datan = counterw-1; 00152 if (user_command[0] == 'R'&& user_command[1] == 'E'&& user_command[2] == 'A'&& user_command[3] == 'D') 00153 { 00154 if (user_command2[0] == 'A'&& user_command2[1]== 'L'&& user_command2[2]== 'L') 00155 { 00156 readall(); 00157 } 00158 00159 else 00160 { 00161 readn(); 00162 } 00163 } 00164 00165 else if (user_command[0] == 'D'&& user_command[1] == 'E'&& user_command[2] == 'L'&& user_command[3] == 'E' && user_command[4] == 'T' && user_command[5] == 'E') 00166 { 00167 if (user_command2[0] == 'A'&& user_command2[1]== 'L'&& user_command2[2]== 'L') 00168 { 00169 pc.printf("deleteall selected\n\r"); 00170 deleteall(); 00171 } 00172 00173 else 00174 { 00175 n = atoi(user_command2); 00176 pc.printf("delete %i\n\r",n); 00177 deleten(); 00178 } 00179 } 00180 00181 else if (user_command[0] == 'S'&& user_command[1] == 'E'&& user_command[2] == 'T'&& user_command[3] == 'D' && user_command[4] == 'A' && user_command[5] == 'T' && user_command[6] == 'E') 00182 { 00183 dates = atoi(user_command2); 00184 yyyy = dates%10; 00185 dates /= 10; 00186 yyy = dates%10; 00187 dates /= 10; 00188 yy = dates%10; 00189 dates /= 10; 00190 y = dates%10; 00191 dates /= 10; 00192 mm = dates%10; 00193 dates /= 10; 00194 m = dates%10; 00195 dates /= 10; 00196 dd = dates%10; 00197 dates /= 10; 00198 d = dates%10; 00199 pc.printf("you set the date to %i%i/%i%i/%i%i%i%i\n\r", d,dd,m,mm,y,yy,yyy,yyyy); 00200 } 00201 else if (user_command[0] == 'S'&& user_command[1] == 'E'&& user_command[2] == 'T'&& user_command[3] == 'T' && user_command[4] == 'I' && user_command[5] == 'M' && user_command[6] == 'E') 00202 { 00203 times = atoi(user_command2); 00204 ss = times%10; 00205 times /= 10; 00206 s = times%10; 00207 times /= 10; 00208 mmi = times%10; 00209 times /= 10; 00210 mi = times%10; 00211 times /= 10; 00212 hh = times%10; 00213 times /= 10; 00214 h = times%10; 00215 pc.printf("you set the time to %i%i:%i%i:%i%i\n\r", h,hh,mi,mmi,s,ss); 00216 } 00217 else if (user_command[0] == 'S'&& user_command[1] == 'E'&& user_command[2] == 'T'&& user_command[3] == 'T') 00218 { 00219 t = atof(user_command2); 00220 pc.printf("you set the period to %2.2f", t); 00221 interrupt = 1; 00222 } 00223 } 00224 //int main() 00225 //{ 00226 // pc.printf("putty ready\n\r"); 00227 // while(1) 00228 // { 00229 // clear(); 00230 // clear2(); 00231 // while (user_command[0] == 0) 00232 // { 00233 // pc.scanf("%s",user_command); 00234 // pc.scanf("%s",user_command2); 00235 // pc.printf("you typed: %s %s\n\r",user_command,user_command2); 00236 // } 00237 // 00238 // selection(); 00239 // } 00240 //} 00241 00242 00243 void putty_write () 00244 { 00245 int count = 0; 00246 int wcount = 0; 00247 while (user_command[wcount]!= ' ') 00248 { 00249 user_command[count] = pc.getc(); 00250 pc.putc(user_command[count]); 00251 count++; 00252 wcount = count -1; 00253 } 00254 int count2 = 0; 00255 int wcount2 = 0; 00256 while(user_command2[wcount2]!= '\r') 00257 { 00258 user_command2[count2] = pc.getc(); 00259 pc.putc(user_command2[count2]); 00260 count2++; 00261 wcount2 = count2 -1; 00262 } 00263 00264 00265 pc.printf("you typed: %s %s\n\r",user_command,user_command2); 00266 selection(); 00267 clear(); 00268 clear2(); 00269 00270 }
Generated on Tue Jul 19 2022 21:47:04 by
