📄 checktime.lst
字号:
case 4://date10
if(time[idx+1])
time[idx]--;
else
{
if(time[idx] > 1)
time[idx]--;
}
break;
C51 COMPILER V7.06 CHECKTIME 04/09/2005 13:15:55 PAGE 5
case 3://month0
case 5://date0
if(time[idx-1])
time[idx]--;
else
{
if(time[idx] > 1)
time[idx]--;
}
break;
case 6://hour10
case 7://hour0
case 8://minute10
case 9://minute0
case 10://second10
case 11://second0
if(time[idx])
time[idx]--;
break;
}
buf[0] = hex2digit(time[idx]);
buf[1] = 0;
printstring16(0,DISPLAYTIMEX+pos*2,DISPLAYTIMEY,buf);
setcursorpos(pos);
}
#else
269 void increasetime(uchar pos)
270 {
271 1 uchar tmp,idx;
272 1 uchar buf[2];
273 1
274 1 if(pos == 0 || pos == 1)
275 1 return;
276 1
277 1 tmp = (pos-2)/3;
278 1 idx = tmp*2;
279 1 if(!(pos%3)) idx++;
280 1
281 1 if(time[idx] == 9)
282 1 time[idx] = 0;
283 1 else
284 1 time[idx]++;
285 1
286 1 buf[0] = hex2digit(time[idx]);
287 1 buf[1] = 0;
288 1 printstring16(0,DISPLAYTIMEX+pos*2,DISPLAYTIMEY,buf);
289 1 setcursorpos(pos);
290 1 }
291
292 void decreasetime(uchar pos)
293 {
294 1 uchar tmp,idx;
295 1 uchar buf[2];
296 1
297 1 if(pos == 0 || pos == 1)
298 1 return;
299 1
300 1 tmp = (pos-2)/3;
301 1 idx = tmp*2;
302 1 if(!(pos%3)) idx++;
303 1
C51 COMPILER V7.06 CHECKTIME 04/09/2005 13:15:55 PAGE 6
304 1 if(time[idx] > 0)
305 1 time[idx]--;
306 1 else
307 1 time[idx] = 9;
308 1
309 1 buf[0] = hex2digit(time[idx]);
310 1 buf[1] = 0;
311 1 printstring16(0,DISPLAYTIMEX+pos*2,DISPLAYTIMEY,buf);
312 1 setcursorpos(pos);
313 1 }
314 #endif
315
316 void checktime()
317 {
318 1 uchar i,buf[20],key,finished,csrpos,ok,year,month,date,hour,minute,second;
319 1
320 1 finished = 0;
321 1 clear(0x0000);
322 1 clear(0x4000);
323 1 printstring16(0,0,0,"现已进入校时程序");
324 1 printstring16(0,0,24,"按1左移");
325 1 printstring16(0,0,26,"按2右移");
326 1 printstring16(0,31,24,"按3加1");
327 1 printstring16(0,31,26,"按4减1");
328 1 printstring16(0,0,28,"按5确认退出");
329 1
330 1 year = readyear();
331 1 time[0] = (year>>4)&0x0f;
332 1 time[1] = year&0x0f;
333 1 month = readmonth();
334 1 time[2] = (month>>4)&0x0f;
335 1 time[3] = month&0x0f;
336 1 date = readdate();
337 1 time[4] = (date>>4)&0x0f;
338 1 time[5] = date&0x0f;
339 1 hour = readhour();
340 1 time[6] = (hour>>4)&0x0f;
341 1 time[7] = hour&0x0f;
342 1 minute = readminute();
343 1 time[8] = (minute>>4)&0x0f;
344 1 time[9] = minute&0x0f;
345 1 second = readsecond();
346 1 time[10] = (second>>4)&0x0f;
347 1 time[11] = second&0x0f;
348 1
349 1 for(i=0;i<12;i++)
350 1 if(time[i] > 10) time[i] = 0;
351 1 sprintf(buf,"20%02bx-%02bx-%02bx %02bx:%02bx:%02bx",year,month,date,hour,minute,second);
352 1 printstring16(0,DISPLAYTIMEX,DISPLAYTIMEY,buf);
353 1
354 1 csrpos = 0;
355 1 setcursorpos(csrpos);
356 1
357 1 while(!finished)
358 1 {
359 2 while((key=readkey()) == KEY_NONE)
360 2 delay(30);
361 2 switch(key)
362 2 {
363 3 case KEY_LEFT:
364 3 if(csrpos)
365 3 {
C51 COMPILER V7.06 CHECKTIME 04/09/2005 13:15:55 PAGE 7
366 4 csrpos--;
367 4 if((csrpos > 3) && ((csrpos-1)%3 == 0))
368 4 csrpos--;
369 4 }
370 3 else
371 3 csrpos = 18;
372 3 setcursorpos(csrpos);
373 3 break;
374 3 case KEY_RIGHT:
375 3 if(csrpos == 18)
376 3 csrpos = 0;
377 3 else
378 3 {
379 4 csrpos++;
380 4 if((csrpos != 1) && ((csrpos-1)%3 == 0))
381 4 csrpos++;
382 4 }
383 3 setcursorpos(csrpos);
384 3 break;
385 3 case KEY_UP:
386 3 increasetime(csrpos);
387 3 break;
388 3 case KEY_DOWN:
389 3 decreasetime(csrpos);
390 3 break;
391 3 case KEY_ENTER:
392 3 ok = 0;
393 3 year = time[0]*10+time[1];
394 3 month = time[2]*10+time[3];
395 3 date = time[4]*10+time[5];
396 3 hour = time[6]*10+time[7];
397 3 minute = time[8]*10+time[9];
398 3 second = time[10]*10+time[11];
399 3
400 3 if(second < 60 &&
401 3 minute < 60 &&
402 3 hour < 24 &&
403 3 month < 13 &&
404 3 month > 0 &&
405 3 date > 0)
406 3 {
407 4 if(month == 2)
408 4 {
409 5 if(year/4)
410 5 {
411 6 if(date<29) ok = 1;
412 6 }
413 5 else
414 5 {
415 6 if(date<30) ok = 1;
416 6 }
417 5 }
418 4 else
419 4 {
420 5 if(isbigmonth(month))
421 5 {
422 6 if(date<32)
423 6 ok = 1;
424 6 }
425 5 else
426 5 {
427 6 if(date<31)
C51 COMPILER V7.06 CHECKTIME 04/09/2005 13:15:55 PAGE 8
428 6 ok = 1;
429 6 }
430 5 }
431 4 }
432 3
433 3 if(ok)
434 3 {
435 4 writesecond(0x00);
436 4 writeyear((time[0]<<4)|time[1]);
437 4 writemonth((time[2]<<4)|time[3]);
438 4 writedate((time[4]<<4)|time[5]);
439 4 writehour((time[6]<<4)|time[7]);
440 4 writeminute((time[8]<<4)|time[9]);
441 4 writesecond((time[10]<<4)|time[11]);
442 4 printstring16(0,DISPLAYTIMEX+13,DISPLAYTIMEY+4,"时间设置成功");
443 4 finished = 1;
444 4 }
445 3 else
446 3 {
447 4 printstring16(0,DISPLAYTIMEX+13,DISPLAYTIMEY+4,"时间设置错误");
448 4 }
449 3 break;
450 3 }
451 2 }
452 1
453 1 delay(500);
454 1 }
455
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1068 ----
CONSTANT SIZE = 123 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 1 36
IDATA SIZE = 12 ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -