📄 storagecontrol.lst
字号:
243 4 limitSet = 0;
244 4 Paratemp = tmax;
245 4 while(1)
246 4 {
247 5 keyId = key_scan();
248 5 if (keyId == UP) //上限
249 5 {
250 6 GotoXY(7,0);
251 6 tmin = Paratemp;
252 6 limitSet = 0;
253 6 }
254 5 if (keyId == DOWN) //下限
255 5 {
256 6 GotoXY(7,1);
257 6 tmax = Paratemp;
258 6 limitSet = 1;
259 6 }
260 5 if (keyId == ENT) //确定退出设置
261 5 {
262 6 if (limitSet == 0)
263 6 tmax = Paratemp;
264 6 if (limitSet == 1)
265 6 tmin = Paratemp;
266 6
267 6 LCD_Write(LCD_COMMAND,LCD_CLEAR_SCREEN); //清屏
268 6 //delay_ms(10);
269 6 GotoXY(0,0);
270 6 Print("1. temperature");
271 6 //delay_ms(10);
272 6 GotoXY(0,1);
273 6 Print("2. humidity");
274 6 delay_ms(10);
275 6
276 6 break;
277 6 }
278 5 if (keyId < 10)
279 5 {
280 6 Paratemp = Paratemp * 10 + keyId;
281 6 }
282 5
283 5 //刷新显示
284 5 if (limitSet == 0)
285 5 {
286 6 GotoXY(5,0);
287 6 himi_to_str(&Parat, Paratemp);
288 6 Print(Parat);
289 6 //delay_ms(10);
290 6 GotoXY(5,1);
291 6 himi_to_str(&Parat, tmin);
292 6 Print(Parat);
293 6 //delay_ms(10);
294 6 }
295 5 if (limitSet == 1)
296 5 {
297 6 GotoXY(5,0);
298 6 himi_to_str(&Parat, tmax);
299 6 Print(Parat);
300 6 //delay_ms(10);
301 6 GotoXY(5,1);
302 6 himi_to_str(&Parat, Paratemp);
303 6 Print(Parat);
C51 COMPILER V8.05a STORAGECONTROL 05/12/2009 10:20:45 PAGE 6
304 6 //delay_ms(10);
305 6 }
306 5 delay_ms(100);
307 5 }
308 4
309 4 }
310 3 if (keyId == 2) //进入湿度设置
311 3 {
312 4 LCD_Write(LCD_COMMAND,LCD_CLEAR_SCREEN); //清屏
313 4 //delay_ms(10);
314 4 GotoXY(0,0);
315 4 Print("hMAX:");
316 4 //delay_ms(10);
317 4 GotoXY(0,1);
318 4 //Print("hMIN:");
319 4 delay_ms(10);
320 4
321 4 GotoXY(8,0);
322 4 LCD_SetDisplay(LCD_SHOW|LCD_CURSOR|LCD_FLASH);
323 4
324 4 limitSet = 0;
325 4 Paratemp = hmax;
326 4 while(1)
327 4 {
328 5 keyId = key_scan();
329 5 if (keyId == UP) //上限
330 5 {
331 6 GotoXY(7,0);
332 6 hmin = Paratemp;
333 6 limitSet = 0;
334 6 }
335 5 if (keyId == DOWN) //下限
336 5 {
337 6 GotoXY(7,1);
338 6 hmax = Paratemp;
339 6 limitSet = 1;
340 6 }
341 5 if (keyId == ENT) //确定退出设置
342 5 {
343 6 if (limitSet == 0)
344 6 hmax = Paratemp;
345 6 if (limitSet == 1)
346 6 hmin = Paratemp;
347 6
348 6 LCD_Write(LCD_COMMAND,LCD_CLEAR_SCREEN); //清屏
349 6 //delay_ms(10);
350 6 GotoXY(0,0);
351 6 Print("1. temperature");
352 6 //delay_ms(10);
353 6 GotoXY(0,1);
354 6 Print("2. humidity");
355 6 //delay_ms(10);
356 6
357 6 break;
358 6 }
359 5 if (keyId < 10)
360 5 {
361 6 Paratemp = Paratemp * 10 + keyId;
362 6 }
363 5
364 5 //刷新显示
365 5 if (limitSet == 0)
C51 COMPILER V8.05a STORAGECONTROL 05/12/2009 10:20:45 PAGE 7
366 5 {
367 6 GotoXY(5,0);
368 6 himi_to_str(&Parat, Paratemp);
369 6 Print(Parat);
370 6 //delay_ms(10);
371 6 GotoXY(5,1);
372 6 himi_to_str(&Parat, tmin);
373 6 Print(Parat);
374 6 //delay_ms(10);
375 6 }
376 5 if (limitSet == 1)
377 5 {
378 6 GotoXY(5,0);
379 6 himi_to_str(&Parat, tmax);
380 6 Print(Parat);
381 6 //delay_ms(10);
382 6 GotoXY(5,1);
383 6 himi_to_str(&Parat, Paratemp);
384 6 Print(Parat);
385 6 //delay_ms(10);
386 6 }
387 5 delay_ms(100);
388 5 }
389 4
390 4 }
391 3 if (keyId == ENT)
392 3 {
393 4 if (limitSet == 0)
394 4 tmax = Paratemp;
395 4 if (limitSet == 1)
396 4 tmin = Paratemp;
397 4
398 4 LCD_Write(LCD_COMMAND,LCD_CLEAR_SCREEN); //清屏
399 4 //delay_ms(10);
400 4 LCD_SetDisplay(LCD_SHOW|LCD_NO_CURSOR|LCD_NO_FLASH);
401 4 break;
402 4 }
403 3 delay_ms(100);
404 3 }
405 2 }
406 1
407 1 }
408
409
410 void monitor(void)
411 {
412 1 if (temperature < tmin)
413 1 err_flag = err_flag | 0x01;
414 1 else if (temperature > tmax)
415 1 err_flag = err_flag | 0x02;
416 1 else
417 1 err_flag = err_flag & 0xfc;
418 1
419 1 if (himidity < hmin)
420 1 err_flag = err_flag | 0x04;
421 1 else if (himidity > hmax)
422 1 err_flag = err_flag | 0x08;
423 1 else
424 1 err_flag = err_flag & 0xf3;
425 1
426 1 if (err_flag != 0)
427 1 {
C51 COMPILER V8.05a STORAGECONTROL 05/12/2009 10:20:45 PAGE 8
428 2 GotoXY(0,1);
429 2 if (err_flag == 1)
430 2 {
431 3 ERR_MIN = 0;
432 3 }
433 2 if (err_flag == 2)
434 2 {
435 3 ERR_MAX = 0;
436 3 }
437 2 if (err_flag == 4)
438 2 {
439 3 ERR_MAX = 0;
440 3 }
441 2 if (err_flag == 8)
442 2 {
443 3 ERR_MAX = 0;
444 3 }
445 2 buzzer = ~buzzer;
446 2 RUN = 1;
447 2 }
448 1 else
449 1 {
450 2 RUN = 0;
451 2 ERR_MIN = 1;
452 2 ERR_MAX = 1;
453 2 buzzer = 1;
454 2 }
455 1 }
456
457
458 void Timer2_Server(void) interrupt 5 using 1
459 {
460 1 TF2=0; /*T2定时器发生溢出中断时,需要用户自己清除溢出标记,而51的其他定时器是自动清除的 */
-
461 1
462 1 count++;
463 1 RUN = ~RUN;
464 1
465 1 }
466
467
468
469
470
471
472
473
474
475
476
477
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1872 ----
CONSTANT SIZE = 130 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 18 82
IDATA SIZE = ---- ----
BIT SIZE = ---- 1
END OF MODULE INFORMATION.
C51 COMPILER V8.05a STORAGECONTROL 05/12/2009 10:20:45 PAGE 9
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -