/* 8K_DIO.c : User can simple to use system key to set 7-seg LED's value. Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) MSC 6.0, MSVC 1.52. Compile mode: large Project: Smmi.c ..\Lib\(8000.Lib, 8000E.lib) Hardware: 8000 Detail description: UP button ==> Increasing value. DOWN button ==> Decreasing Value. Set ==> Selecting 7-seg LED's postion. Mode ==> Selecting 7-seg LED's postion. [15 Nov,2005] by Bill */ #include"..\LIB\8000a.h" void main(void) { int quit=0,iPostion=1,iTemp; int iTimes[5]={0}; unsigned char oldKeyStatus=0xff; InitLib(); Init5DigitLed(); Delay(100); //7-seg LED set 00000 Show5DigitLedWithDot(1,0); Show5DigitLed(2,0); Show5DigitLed(3,0); Show5DigitLed(4,0); Show5DigitLed(5,0); ClearSystemKey(); while(!quit) { if(IsSystemKey()) { iTemp=iPostion; switch(GetSystemKey()) { case SKEY_UP: Print("UP KEY\n\r"); if(oldKeyStatus & SKEY_UP_DOWN) { iTimes[iPostion-1]++; if(iTimes[iPostion-1] == 16) iTimes[iPostion-1]=0; Show5DigitLedWithDot(iPostion,iTimes[iPostion-1]); } break; case SKEY_DOWN: Print("DOWN KEY\n\r"); if(oldKeyStatus & SKEY_DOWN_DOWN) { iTimes[iPostion-1]--; if(iTimes[iPostion-1] < 0) iTimes[iPostion-1]=15; Show5DigitLedWithDot(iPostion,iTimes[iPostion-1]); } break; case SKEY_SET: Print("SET KEY\n\r"); if(oldKeyStatus & SKEY_SET_DOWN) { iPostion--; if(iPostion == 0 ) iPostion=5; Show5DigitLedWithDot(iPostion,iTimes[iPostion-1]); } break; case SKEY_MODE: Print("MODE KEY\n\r"); if(oldKeyStatus & SKEY_MODE_DOWN) { iPostion++; if(iPostion == 6) iPostion=1; Show5DigitLedWithDot(iPostion,iTimes[iPostion-1]); } break; } if(iTemp!=iPostion) { Show5DigitLed(iTemp,iTimes[iTemp-1]); } } if(Kbhit()) { if(Getch()=='q') quit=1; } } }