/* DEMO96.c: Shows how to use the User timer function to change 5-Digit LED in different time interval. 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: DEMO96.c ..\..\Lib\7188el.Lib Hardware: 7188E Note: Function used: TimerOpen --> start to use timer TimerClose--> stop to use timer InstallUserTimer --> install user timer function 5DigitLed will show 0 to F, position 1 will be update every 1 sec position 2 will be update every 0.5 sec position 3 will be update every 0.4 sec position 4 will be update every 0.3 sec position 5 will be update every 0.2 sec [02/Dec/2006] by Liam [July,13,2011] by Nicholas */ #include #include "..\..\lib\7188e.h" /* you must change this lib to suit the hardware that you want to use. */ 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]&=0x0F; 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; 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(); LedOff(); InstallUserTimer(MyTimerFun); while(!quit) { if(Kbhit() && Getch()=='q') quit=1; } TimerClose(); LedOn(); }