Line 1... |
Line 1... |
1 |
#include ".\main.h" |
1 |
#include ".\main.h" |
2 |
|
2 |
|
3 |
#define LCD_RS PIN_B1 // rizeni registru LCD displeje |
- |
|
4 |
#define LCD_E PIN_B0 // enable LCD displeje |
- |
|
5 |
#define LCD_DATA_LSB PIN_C0 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou) |
- |
|
6 |
|
- |
|
7 |
|
- |
|
8 |
#bit SPEN=0x18.7 |
- |
|
9 |
#bit RCIF=0x0C.5 |
- |
|
10 |
|
- |
|
11 |
#include <stdio.h> |
3 |
#include <stdio.h> |
12 |
#include <string.h> |
4 |
#include <string.h> |
13 |
#include <stdlib.h> |
5 |
#include <stdlib.h> |
14 |
|
6 |
|
15 |
#define DELKA 40 |
7 |
#define DELKA 40 |
- |
|
8 |
#define VYKON 100 |
16 |
|
9 |
|
17 |
char odp[DELKA]; |
10 |
char odp[DELKA]; |
18 |
|
11 |
|
19 |
int1 check_new_sms() |
12 |
int1 check_new_sms() |
20 |
{ |
13 |
{ |
21 |
fprintf(MOBIL,"AT+CMGL=1\r"); //vycti prijate SMS (0=nove;1=vsechny) |
14 |
fprintf(MOBIL,"AT+CMGL=0\r"); //vycti prijate SMS (0=nove;1=vsechny) |
22 |
while(fgetc(MOBIL)!=0x0A); // predkoc prvni radek odpovedi |
15 |
while(fgetc(MOBIL)!=0x0A); // predkoc prvni radek odpovedi |
23 |
odp[0]=fgetc(MOBIL); // Nacti prvni dva znaky druheho radku odpovedi |
16 |
odp[0]=fgetc(MOBIL); // Nacti prvni dva znaky druheho radku odpovedi |
24 |
odp[1]=fgetc(MOBIL); |
17 |
odp[1]=fgetc(MOBIL); |
25 |
while(fgetc(MOBIL)!=0x0A); // Preskoc zbytek radku |
18 |
while(fgetc(MOBIL)!=0x0A); // Preskoc zbytek radku |
26 |
|
19 |
|
Line 154... |
Line 147... |
154 |
set_pwm1_duty(0); |
147 |
set_pwm1_duty(0); |
155 |
set_pwm2_duty(0); |
148 |
set_pwm2_duty(0); |
156 |
|
149 |
|
157 |
while(TRUE) |
150 |
while(TRUE) |
158 |
{ |
151 |
{ |
159 |
int status; |
152 |
unsigned int8 n; |
160 |
char *ptr; |
153 |
char *ptr; |
161 |
int time; |
154 |
int time; |
162 |
|
155 |
|
163 |
restart_wdt(); |
- |
|
164 |
|
- |
|
165 |
output_low(PIN_A4) ; |
156 |
output_low(PIN_A4) ; |
166 |
delay_ms(150); |
157 |
delay_ms(150); |
167 |
output_high(PIN_A4); |
158 |
output_high(PIN_A4); |
168 |
delay_ms(150); |
159 |
delay_ms(150); |
169 |
output_low(PIN_A4) ; |
160 |
output_low(PIN_A4) ; |
Line 173... |
Line 164... |
173 |
|
164 |
|
174 |
|
165 |
|
175 |
if(check_new_sms()) // Je odpoved "OK"? |
166 |
if(check_new_sms()) // Je odpoved "OK"? |
176 |
{ |
167 |
{ |
177 |
// printf(lcd_putc,"736 655 250"); |
168 |
// printf(lcd_putc,"736 655 250"); |
178 |
delay_ms(1000); |
169 |
delay_ms(5000); |
179 |
} |
170 |
} |
180 |
else |
171 |
else |
181 |
{ |
172 |
{ |
182 |
read_sms(); |
173 |
read_sms(); |
183 |
|
174 |
|
184 |
/* if (odp[0] == 'A' || odp[0] == 'a') |
175 |
if (toupper(odp[0]) == 'A') |
185 |
{ |
176 |
{ |
186 |
set_pwm1_duty(500); |
177 |
set_pwm1_duty(VYKON); |
187 |
set_pwm2_duty(500); |
178 |
set_pwm2_duty(VYKON); |
188 |
Delay_ms(10000); |
179 |
Delay_ms(10000); |
189 |
fprintf(VRTULE,"JACK[BARmk"); // "JACK BAR :)" |
180 |
fprintf(VRTULE,"JACK[BARmk"); // "JACK BAR :)" |
190 |
Delay_ms(2000); |
181 |
Delay_ms(2000); |
191 |
fprintf(VRTULE,"JACK[BARmk"); // "JACK BAR :)" |
182 |
fprintf(VRTULE,"JACK[BARmk"); // "JACK BAR :)" |
192 |
Delay_ms(5000); |
183 |
Delay_ms(5000); |
193 |
set_pwm1_duty(0); |
184 |
set_pwm1_duty(0); |
194 |
set_pwm2_duty(0); |
185 |
set_pwm2_duty(0); |
- |
|
186 |
del_sms(); |
- |
|
187 |
break; |
195 |
}*/ |
188 |
} |
196 |
|
189 |
|
197 |
/* if (odp[1] == 'h') |
190 |
if (toupper(odp[0]) == 'B') |
198 |
{ |
191 |
{ |
199 |
set_pwm1_duty(500); |
192 |
set_pwm1_duty(VYKON); |
200 |
set_pwm2_duty(500); |
193 |
set_pwm2_duty(VYKON); |
201 |
Delay_ms(10000); |
194 |
Delay_ms(10000); |
202 |
fprintf(VRTULE,"[ERROR[d[["); // " ERROR 3 " |
195 |
for(n=0;n<=1;n++) |
203 |
Delay_ms(2000); |
196 |
{ |
204 |
fprintf(VRTULE,"[ERROR[d[["); // " ERROR 3 " |
197 |
fprintf(VRTULE,"[ERROR[d[["); // " ERROR 3 " |
205 |
Delay_ms(2000); |
198 |
Delay_ms(2000); |
206 |
fprintf(VRTULE,"[OVERFLOW["); // " OVERFLOW " |
199 |
fprintf(VRTULE,"[OVERFLOW["); // " OVERFLOW " |
207 |
Delay_ms(2000); |
200 |
Delay_ms(2000); |
208 |
fprintf(VRTULE,"[OVERFLOW["); |
201 |
} |
209 |
Delay_ms(5000); |
202 |
Delay_ms(5000); |
210 |
set_pwm1_duty(0); |
203 |
set_pwm1_duty(0); |
211 |
set_pwm2_duty(0); |
204 |
set_pwm2_duty(0); |
- |
|
205 |
del_sms(); |
- |
|
206 |
break; |
212 |
}*/ |
207 |
} |
213 |
|
208 |
|
214 |
if (odp[2] == 'o') |
209 |
if (toupper(odp[0]) == 'C') |
215 |
{ |
210 |
{ |
216 |
set_pwm1_duty(500); |
211 |
set_pwm1_duty(VYKON); |
217 |
set_pwm2_duty(500); |
212 |
set_pwm2_duty(VYKON); |
218 |
Delay_ms(10000); |
213 |
Delay_ms(10000); |
- |
|
214 |
for(n=0;n<=1;n++) |
- |
|
215 |
{ |
219 |
fprintf(VRTULE,"[ERROR[e[["); // " ERROR 4 " |
216 |
fprintf(VRTULE,"[ERROR[e[["); // " ERROR 4 " |
- |
|
217 |
Delay_ms(2000); |
- |
|
218 |
fprintf(VRTULE,"[OPAKUJTE["); // " OPAKUJTE " |
220 |
Delay_ms(2000); |
219 |
Delay_ms(2000); |
221 |
fprintf(VRTULE,"[ERROR[e[["); // " ERROR 4 " |
220 |
fprintf(VRTULE,"[[VOLBU[[["); // " VOLBU " |
- |
|
221 |
Delay_ms(2000); |
- |
|
222 |
} |
222 |
Delay_ms(2000); |
223 |
Delay_ms(3000); |
- |
|
224 |
set_pwm1_duty(0); |
- |
|
225 |
set_pwm2_duty(0); |
- |
|
226 |
del_sms(); |
- |
|
227 |
break; |
- |
|
228 |
} |
- |
|
229 |
|
- |
|
230 |
if (toupper(odp[0]) == 'D') |
- |
|
231 |
{ |
- |
|
232 |
set_pwm1_duty(VYKON); |
- |
|
233 |
set_pwm2_duty(VYKON); |
- |
|
234 |
Delay_ms(10000); |
223 |
fprintf(VRTULE,"[OPAKUJTE["); // " OPAKUJTE " |
235 |
fprintf(VRTULE,"[[PEACE[[["); // " PEACE " |
224 |
Delay_ms(2000); |
236 |
Delay_ms(2000); |
225 |
fprintf(VRTULE,"[OPAKUJTE["); |
237 |
fprintf(VRTULE,"[[PEACE[[["); |
- |
|
238 |
Delay_ms(3000); |
- |
|
239 |
set_pwm1_duty(0); |
- |
|
240 |
set_pwm2_duty(0); |
- |
|
241 |
del_sms(); |
- |
|
242 |
break; |
- |
|
243 |
} |
- |
|
244 |
|
- |
|
245 |
if (toupper(odp[0]) == 'E') |
- |
|
246 |
{ |
- |
|
247 |
set_pwm1_duty(VYKON); |
- |
|
248 |
set_pwm2_duty(VYKON); |
- |
|
249 |
Delay_ms(10000); |
- |
|
250 |
for(n=0;n<=1;n++) |
- |
|
251 |
{ |
- |
|
252 |
fprintf(VRTULE,"[[[MORE[[["); // " MORE " |
- |
|
253 |
Delay_ms(2000); |
- |
|
254 |
fprintf(VRTULE,"[[ZE[JO[[["); // " ZE JO " |
- |
|
255 |
Delay_ms(2000); |
- |
|
256 |
} |
- |
|
257 |
Delay_ms(5000); |
- |
|
258 |
set_pwm1_duty(0); |
- |
|
259 |
set_pwm2_duty(0); |
- |
|
260 |
del_sms(); |
- |
|
261 |
break; |
- |
|
262 |
} |
- |
|
263 |
|
- |
|
264 |
if (toupper(odp[0]) == 'F') |
- |
|
265 |
{ |
- |
|
266 |
set_pwm1_duty(VYKON); |
- |
|
267 |
set_pwm2_duty(VYKON); |
- |
|
268 |
Delay_ms(10000); |
- |
|
269 |
for(n=0;n<=1;n++) |
- |
|
270 |
{ |
- |
|
271 |
fprintf(VRTULE,"[ROZBITY[["); // " ROZBITY " |
- |
|
272 |
Delay_ms(2000); |
- |
|
273 |
fprintf(VRTULE,"[[BUDIK[[["); // " BUDIK " |
- |
|
274 |
Delay_ms(2000); |
- |
|
275 |
} |
- |
|
276 |
Delay_ms(5000); |
- |
|
277 |
set_pwm1_duty(0); |
- |
|
278 |
set_pwm2_duty(0); |
- |
|
279 |
del_sms(); |
- |
|
280 |
break; |
- |
|
281 |
} |
- |
|
282 |
|
- |
|
283 |
if (toupper(odp[0]) == 'G') |
- |
|
284 |
{ |
- |
|
285 |
set_pwm1_duty(VYKON); |
- |
|
286 |
set_pwm2_duty(VYKON); |
- |
|
287 |
Delay_ms(10000); |
- |
|
288 |
for(n=0;n<=1;n++) |
- |
|
289 |
{ |
- |
|
290 |
fprintf(VRTULE,"[ZAPOJIT[["); // " ZAPOJIT " |
- |
|
291 |
Delay_ms(2000); |
- |
|
292 |
fprintf(VRTULE,"[ZASUVKU[["); // " ZASUVKU " |
- |
|
293 |
Delay_ms(2000); |
- |
|
294 |
} |
- |
|
295 |
Delay_ms(5000); |
- |
|
296 |
set_pwm1_duty(0); |
- |
|
297 |
set_pwm2_duty(0); |
- |
|
298 |
del_sms(); |
- |
|
299 |
break; |
- |
|
300 |
} |
- |
|
301 |
|
- |
|
302 |
if (toupper(odp[0]) == 'H') |
- |
|
303 |
{ |
- |
|
304 |
set_pwm1_duty(VYKON); |
- |
|
305 |
set_pwm2_duty(VYKON); |
- |
|
306 |
Delay_ms(10000); |
- |
|
307 |
for(n=0;n<=1;n++) |
- |
|
308 |
{ |
- |
|
309 |
fprintf(VRTULE,"[[MARTIN[["); // " MARTIN " |
- |
|
310 |
Delay_ms(2000); |
- |
|
311 |
fprintf(VRTULE,"[[SVEJDA[["); // " SVEJDA " |
- |
|
312 |
Delay_ms(2000); |
- |
|
313 |
fprintf(VRTULE,"[[TOMAS[[["); // " TOMAS " |
- |
|
314 |
Delay_ms(2000); |
- |
|
315 |
fprintf(VRTULE,"[[[KAPL[[["); // "KAPL" |
- |
|
316 |
Delay_ms(2000); |
- |
|
317 |
fprintf(VRTULE,"[[JAKUB[[["); // " JAKUB " |
- |
|
318 |
Delay_ms(2000); |
- |
|
319 |
fprintf(VRTULE,"[[KAKONA[["); // "KAKONA" |
- |
|
320 |
Delay_ms(2000); |
- |
|
321 |
} |
- |
|
322 |
Delay_ms(3000); |
- |
|
323 |
set_pwm1_duty(0); |
- |
|
324 |
set_pwm2_duty(0); |
- |
|
325 |
del_sms(); |
- |
|
326 |
break; |
- |
|
327 |
} |
- |
|
328 |
|
- |
|
329 |
if (toupper(odp[0]) == 'I') |
- |
|
330 |
{ |
- |
|
331 |
set_pwm1_duty(VYKON); |
- |
|
332 |
set_pwm2_duty(VYKON); |
- |
|
333 |
Delay_ms(10000); |
- |
|
334 |
for(n=0;n<=1;n++) |
- |
|
335 |
{ |
- |
|
336 |
fprintf(VRTULE,"ODPOVED[NA"); // "ODPOVED NA" |
- |
|
337 |
Delay_ms(2000); |
- |
|
338 |
fprintf(VRTULE,"[[VASI[[[["); // " VASI " |
- |
|
339 |
Delay_ms(2000); |
- |
|
340 |
fprintf(VRTULE,"[[OTAZKU[["); // " OTAZKU " |
- |
|
341 |
Delay_ms(2000); |
- |
|
342 |
fprintf(VRTULE,"[[[[JE[[[["); // "JE" |
- |
|
343 |
Delay_ms(2000); |
- |
|
344 |
fprintf(VRTULE,"[[[[ec[[[["); // " 42 " |
- |
|
345 |
Delay_ms(2000); |
- |
|
346 |
} |
- |
|
347 |
Delay_ms(3000); |
- |
|
348 |
set_pwm1_duty(0); |
- |
|
349 |
set_pwm2_duty(0); |
- |
|
350 |
del_sms(); |
- |
|
351 |
break; |
- |
|
352 |
} |
- |
|
353 |
else |
- |
|
354 |
{ |
- |
|
355 |
set_pwm1_duty(VYKON); |
- |
|
356 |
set_pwm2_duty(VYKON); |
- |
|
357 |
Delay_ms(10000); |
- |
|
358 |
fprintf(VRTULE,"[[NEUMIS[["); // "NEUMIS" |
226 |
Delay_ms(2000); |
359 |
Delay_ms(2000); |
227 |
fprintf(VRTULE,"[[VOLBU[[["); // " VOLBU " |
360 |
fprintf(VRTULE,"[[[PSAT[[["); // " PSAT " |
228 |
Delay_ms(2000); |
361 |
Delay_ms(2000); |
229 |
fprintf(VRTULE,"[[VOLBU[[["); |
362 |
fprintf(VRTULE,"[[TRUBKO[["); // " TRUBKO " |
230 |
Delay_ms(3000); |
363 |
Delay_ms(3000); |
231 |
set_pwm1_duty(0); |
364 |
set_pwm1_duty(0); |
232 |
set_pwm2_duty(0); |
365 |
set_pwm2_duty(0); |
- |
|
366 |
del_sms(); |
233 |
} |
367 |
} |
234 |
} |
368 |
} |
235 |
read_time(); |
369 |
read_time(); |
236 |
time=strtoul(odp,&ptr,10); |
370 |
time=strtoul(odp,&ptr,10); |
237 |
if((time >= 30 && time <= 35) || (time >= 0 && time <= 5)) |
371 |
if((time >= 30 && time <= 32) || (time >= 0 && time <= 2) || (time >= 45 && time <= 47) || (time >= 15 && time <= 17)) |
238 |
{ |
372 |
{ |
239 |
set_pwm1_duty(500); |
373 |
set_pwm1_duty(VYKON); |
240 |
set_pwm2_duty(500); |
374 |
set_pwm2_duty(VYKON); |
241 |
} |
375 |
} |
242 |
else |
376 |
else |
243 |
{ |
377 |
{ |
244 |
set_pwm1_duty(0); |
378 |
set_pwm1_duty(0); |
245 |
set_pwm2_duty(0); |
379 |
set_pwm2_duty(0); |