/* DEMO99.c: Shows how to use 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) (free from http://cc.codegear.com/free/cpp) MSC 6.0, MSVC 1.52. Compile mode: Large Project: DEMO99.c ..\..\Lib\7188el.Lib Hardware: 7188E Note: Function used: 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 [Oct 30, 2008] by Liam [July,13,2011] by Nicholas */ #include #include #include "..\..\lib\7188e.h" void LEDFun(int Count) { char Data[6]; 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(); 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(); }