mirror of https://github.com/IoTcat/HOMES.git
parent
112aa836cf
commit
1a8b507956
5 changed files with 1203 additions and 1213 deletions
@ -0,0 +1,48 @@ |
||||
/* function for detect the keyborad to wait for a keyboard event and return it with ASCII */ |
||||
int input__detect_input_ASCII() |
||||
{ |
||||
int nKey; |
||||
|
||||
/* clear former cache */ |
||||
fflush(stdin); |
||||
|
||||
/* get key value */ |
||||
nKey = _getch(); |
||||
|
||||
return nKey; |
||||
} |
||||
|
||||
|
||||
|
||||
/* function for get keyboard arrow event */ |
||||
int input__get_arrow() |
||||
{ |
||||
int nVal=0; |
||||
|
||||
while(1) |
||||
{ |
||||
nVal=input__detect_input_ASCII(); |
||||
|
||||
if(nVal==224) |
||||
{ |
||||
/* get arraw value */ |
||||
int nKey=input__detect_input_ASCII(); |
||||
|
||||
if(nKey==75) |
||||
return -1; |
||||
if(nKey==77) |
||||
return 1; |
||||
if(nKey==72) |
||||
return -1; |
||||
if(nKey==80) |
||||
return 1; |
||||
else |
||||
return 0; |
||||
} |
||||
|
||||
if(nVal==13) |
||||
return 6; |
||||
if(nVal==27) |
||||
return 9; |
||||
} |
||||
} |
@ -0,0 +1,59 @@ |
||||
/* function for adjust window color, size and position */ |
||||
void print__setup() |
||||
{ |
||||
/* set window title */ |
||||
system(PROGRAM_TITLE);
|
||||
/* set window size */ |
||||
system(WINDOW_SIZE); |
||||
/* set window color */ |
||||
system(WINDOW_COLOR); |
||||
} |
||||
|
||||
|
||||
/* function for print many space */ |
||||
void print__space(int nSpace) |
||||
{ |
||||
int i; |
||||
for(i=0;i<nSpace;i++) |
||||
printf(" "); |
||||
} |
||||
|
||||
|
||||
/* display a header */ |
||||
void print__header() |
||||
{ |
||||
time_t timep; |
||||
|
||||
struct tm *curtm; |
||||
time (&timep); |
||||
curtm=gmtime(&timep); |
||||
printf("%d-%d-%d %d:%d:%02d",curtm->tm_year+1900, curtm->tm_mon+1,curtm->tm_mday, curtm->tm_hour,curtm->tm_min, curtm->tm_sec); |
||||
|
||||
print__space(19); |
||||
|
||||
if(g_pUsr) |
||||
printf("User: %6s",g_pUsr ); |
||||
|
||||
printf("this is the header"); |
||||
|
||||
printf("\n----------------------------------------------------------------------------------------"); |
||||
} |
||||
|
||||
|
||||
|
||||
/* function for print a standard item */ |
||||
void print__item(char chItem[20],int nMrk,int nSpc) |
||||
{ |
||||
printf("\n\n"); |
||||
|
||||
print__space(nSpc+(88-strlen(chItem))/2); |
||||
|
||||
printf("%11s",chItem ); |
||||
|
||||
if(nMrk==1) |
||||
{ |
||||
print__space(3); |
||||
printf("<<--"); |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue