/* DEMO99.c: Using the T_StopWatchStart(), T_StopWatchGetTime(), T_StopWatchPause() and T_StopWatchContinue() functions to controll the 5-Digit 7-segment LED. Compiler: BC++ 3.1, Turbo C++ 1.01 (3.01), MSVC 1.52 Compile mode: Large Project: DEMO97.c ..\..\Lib\upac5000.lib Hardware: uPAC-5000 Description T_StopWatchStart --> Start to use a stopwatch T_StopWatchGetTime --> Read current stopwatch value T_StopWatchPause --> Pause the stopwatch T_StopWatchContinue --> Continue the stopwatch 5-Digit 7-segment LED will show the value of counter every 500ms [Dec 21, 2011] by Liam */ #include #include "..\..\lib\upac5000.h" void LEDFun(int Count) { char Data[8]; int i; sprintf(Data, "%05d", Count); for(i=0; i<5; i++) { Show5DigitLed(i+1, Data[i]-0x30); } } void main(void) { STOPWATCH sw; int quit=0, iCount=0; InitLib(); /* InitLib() must be called before other functions in the library may be used */ Print("Test User Timer Function & Show5DigitLed ...\r\n"); Print("Now every digit of Show5DigitLed will count in different speed\r\n"); Print("\r\nPress 'p' to pause the count\r\n"); Print("Press 'c' to continue count\r\n"); Print("Press 'q' to quit\r\n"); Init5DigitLed(); LedOff(); T_StopWatchStart((STOPWATCH *) &sw); while(!quit) { if(Kbhit()) { switch(Getch()) { case 'Q': case 'q': quit=1; break; case 'P': case 'p': T_StopWatchPause((STOPWATCH *) &sw); break; case 'C': case 'c': T_StopWatchContinue((STOPWATCH *) &sw); break; } } if(T_StopWatchGetTime(&sw)>=500) { iCount++; LEDFun(iCount); T_StopWatchStart((STOPWATCH *) &sw); } } LedOn(); }