📄 linuxdiag.c
字号:
//LinuxDiag.c 自检 #include <time.h> #include "pos.h"extern struct tm *glb_now;extern struct DT_struct { int year; int month; int day; int hour; int min; int sec; };//只让用户输入 时分秒, 年月日 从系统读出void ChangeSystemTime( void ) //实时时钟中的 时间参数{ unsigned char DateTimeStr[32],tmpstr[8]; int looptimes,inf; struct DT_struct DT_s; int year,month,day; GetSystemDate( &year, &month, &day, DateTimeStr ); LCD6963_ClearScreen(); //清屏幕 //LCD_DisplayOneLine( 2,0 ,"年年年月月日日",'D',1,0 ); LCD_DisplayOneLine( 0,0 ,"请输入时间:",'D',1,0 ); LCD_DisplayOneLine( 2,0 ,DateTimeStr,'D',0,0 ); LCD_DisplayOneLine( 4,0 ," __ 时 __ 分 __ 秒",'D',0,0 ); //2004 年 04 月 20 日 DT_s.year = year; DT_s.month = month; DT_s.day = day; // 04 时 04 分 20 秒 if ( KB_NumStrInput( 4,2,4,'D',2,0,tmpstr,0 ) != 2 ) //输入 时 return ; //输入不正确,返回 DT_s.hour = atoi(tmpstr); if( DT_s.hour > 23 ) return ; if ( KB_NumStrInput( 4,8,8+2,'D',2,0,tmpstr,0 ) != 2 ) //输入 分 return ; DT_s.min = atoi(tmpstr); if( DT_s.min > 59 ) return ; if ( KB_NumStrInput( 4,14,14+2,'D',2,0,tmpstr,0 ) != 2 ) //输入 秒 return ; DT_s.sec = atoi(tmpstr); if( DT_s.sec > 59 ) return ; SetTimeAndDate( &DT_s ); //设置日期时间 LCD_DisplayOneLine( 8,9*6 ,"按ESC键,可终止时间显示",'D',0,0 ); //测试 for(looptimes=0;looptimes<600;looptimes++) { GetTimeAndDate( DateTimeStr ); //printf("%s\n",DateTimeStr); LCD_DisplayOneLine( 6, 0,(unsigned char *)DateTimeStr,'D',1,0); //反白显示 //ShowTimeAndDate(); sleep(1); //延时一秒 if( KB_GetStatus() ) { if( KB_GetValue() == KEY_ESC ) break; } //end if } //end for //清屏幕 LCD_DisplayOneLine( 8, 0,(unsigned char *)" ",'D',0,1); }void Main_5_0_8_MenuPro( void ) //实时时钟{ char DateTimeStr[32],tmpstr[8]; int looptimes,inf; struct DT_struct DT_s; //LCD_DisplayOneLine( 8, 0,(unsigned char *)"按ESC键终止显示",'D',0,0); //反白显示 memset(DateTimeStr,0,32); //得到 日期时间 GetTimeAndDate( DateTimeStr ); //,&DT_s ); //printf("%s\n",DateTimeStr); //LCD_DisplayOneLine( 8, 9*6,(unsigned char *)DateTimeStr,'D',1,0); //反白显示 //用户 输入日期时间 LCD6963_ClearScreen(); //清屏幕 //LCD_DisplayOneLine( 2,0 ,"年年年月月日日",'D',1,0 ); LCD_DisplayOneLine( 0,0 ,"请输入日期,时间:",'D',1,0 ); LCD_DisplayOneLine( 2,0 ,"____ 年 __ 月 __ 日",'D',0,0 ); LCD_DisplayOneLine( 4,0 ," __ 时 __ 分 __ 秒",'D',0,0 ); //2004 年 04 月 20 日 if ( KB_NumStrInput( 2,0,4,'D',4,0,tmpstr,0 ) != 4 ) //输入 年 return ; //输入不正确,返回 DT_s.year = atoi(tmpstr); if( DT_s.year < 2000 ) return ; if ( KB_NumStrInput( 2,8,8+2,'D',2,0,tmpstr,0 ) != 2 ) //输入 月 return ; DT_s.month = atoi(tmpstr); if( DT_s.month > 12 ) return ; if ( KB_NumStrInput( 2,14,14+2,'D',2,0,tmpstr,0 ) != 2 ) //输入 日 return ; DT_s.day = atoi(tmpstr); if( DT_s.day > 31 ) return ; // 04 时 04 分 20 秒 if ( KB_NumStrInput( 4,2,4,'D',2,0,tmpstr,0 ) != 2 ) //输入 时 return ; //输入不正确,返回 DT_s.hour = atoi(tmpstr); if( DT_s.hour > 23 ) return ; if ( KB_NumStrInput( 4,8,8+2,'D',2,0,tmpstr,0 ) != 2 ) //输入 分 return ; DT_s.min = atoi(tmpstr); if( DT_s.min > 59 ) return ; if ( KB_NumStrInput( 4,14,14+2,'D',2,0,tmpstr,0 ) != 2 ) //输入 秒 return ; DT_s.sec = atoi(tmpstr); if( DT_s.sec > 59 ) return ; //DT_s.year = 2004; DT_s.month = 2; DT_s.day = 28; //DT_s.hour = 23; DT_s.min = 59; DT_s.sec = 56; SetTimeAndDate( &DT_s ); //设置日期时间 LCD_DisplayOneLine( 8,9*6 ,"按ESC键,可终止时间显示",'D',0,0 ); //测试 for(looptimes=0;looptimes<600;looptimes++) { GetTimeAndDate( DateTimeStr ); //printf("%s\n",DateTimeStr); LCD_DisplayOneLine( 6, 0,(unsigned char *)DateTimeStr,'D',1,0); //反白显示 //ShowTimeAndDate(); sleep(1); //延时一秒 if( KB_GetStatus() ) { if( KB_GetValue() == KEY_ESC ) break; } //end if } //end for //清屏幕 LCD_DisplayOneLine( 8, 0,(unsigned char *)" ",'D',0,1); }const char KEY_CHK_NAME[]={" F1, F2, F3, F4, F5, F6, F7, F8, F9,F10,F11,F12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, q, w, e, r, t, y, u, i, o, p, a, s, d, f, g, h, j, k, l, z, x, c, v, b, n, m,sft,crl,alt,spc, up, dn,lft,rit,"};const unsigned char KEY_CHK_TAB[]={//F1--F120x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,//1--9,00x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x30,//q,w,e,r,t,y,u,i,o,p,0x71,0x77,0x65,0x72,0x74,0x79,0x75,0x69,0x6F,0x70,//a,s,d,f,g,h,j,k,l,0x61,0x73,0x64,0x66,0x67,0x68,0x6A,0x6B,0x6C,//z,x,c,v,b,n,m,0x7A,0x78,0x63,0x76,0x62,0x6E,0x6D,//sft,crl,alt,spc, up, dn,lft,rit,0x92,0x93,0x94,0x20,0x96,0x97,0x98,0x99,};void Main_5_0_12_MenuPro( void ) //检查 键盘{ int kc,cnt=0; char str0[32],HexStr[]={"0123456789ABCDEF"}; memset( str0,0,32 ); LCD6963_ClearScreen(); //清屏幕 LCD_DisplayOneLine( 0,0 ,"请按提示依次按键:",'D',0,1 ); do { memmove(str0,"请按",4); memmove( &str0[4],&KEY_CHK_NAME[cnt*4],3 ); LCD_DisplayOneLine( 2,0 ,str0,'D',0,0 ); //printf("%d\n",cnt); while( ! KB_GetStatus() ) ; kc = KB_GetValue(); if( kc != KEY_CHK_TAB[cnt] ) { LCD_DisplayOneLine( 2,8*6 ,"按键错误!",'D',0,0 ); //printf( "Error !!%d,%d\n",kc,KEY_CHK_TAB[cnt] ); } else { LCD_DisplayOneLine( 2,0 ," ",'D',0,1 ); cnt++; } printf( "%x,%d\n",kc,cnt ); if( kc == KEY_ESC ) break; } while( cnt < 12+10+10+9+7+8 ); //显示用户按键和键值,按ESC退出 LCD6963_ClearScreen(); //清屏幕 LCD_DisplayOneLine( 0,0 ,"任意键测试,请按ESC退出:",'D',0,0 ); do { while(!KB_GetStatus()); kc = KB_GetValue(); printf("%x\n",kc); memmove( str0,"刚才按下:___0x",14 ); str0[14] = HexStr[kc >> 4]; str0[15] = HexStr[kc & 0x0f]; if( kc >= 0x20 && kc <= 0x7f ) str0[10] = kc & 0xff; LCD_DisplayOneLine( 2,0 ,str0,'D',0,1 ); if( kc == KEY_ESC ) break; } while(1);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -