/* 1. Compiler: TC 2.0 2. Mode: Large 3. Project: Demo96.prj Demo96.c ..\lib\8000l.lib ..\lib\tcpipl.lib 4. Explain: (1). Demonstration for use Timer functions. (2). To use the InstallUserTimer functions. 5. Hordware: 8831 It's compiled by Tony ------------------------------------------------------------------------ */ #include #include #include #include #include #include"..\LIB\8000.h" /* ------------------------------------------------------------------- */ int Data[5]={ 0,0,0,0,0 }; void MyTimerFun(void) { static int count[5]={0,0,0,0,0}; int i; for(i=0;i<5;i++){ count[i]++; } if(count[0]>=1000){ count[0]=0; Data[0]++; Data[0]&=0x0F; Show5DigitLedWithDot(1,Data[0]); } if(count[1]>=500){ count[1]=0; Data[1]++; Data[1]&=0xFF; Show5DigitLedSeg(2,Data[1]); } if(count[2]>=400){ count[2]=0; Data[2]++; Data[2]&=0x0F; Show5DigitLed(3,Data[2]); } if(count[3]>=300){ count[3]=0; Data[3]++; Data[3]&=0x0F; Show5DigitLed(4,Data[3]); } if(count[4]>=200){ count[4]=0; Data[4]++; Data[4]&=0x0F; Show5DigitLed(5,Data[4]); } } void main(void) { int quit=0; unsigned Ver; if(!Is8000()){ /*detect the current operation system*/ Print("\n\rdemo96.exe must run on 8831 wirh MiniOS7"); return; } Ver=GetLibVersion(); Print("\n\rLib version=%d.%02d",Ver>>8,Ver&0xff); Print("\n\rTest User Timer Function & Show5DigitLed ..."); Print("\n\rNow every digit of Show5DigitLed will count in different speed "); Print("\n\rPress 'q' to quit\n\r"); Init5DigitLed(); TimerOpen(); SetLedL1(0); InstallUserTimer(MyTimerFun); while(!quit){ if(Kbhit() && Getch()=='q') quit=1; } TimerClose(); SetLedL1(1); }