eecs-bsp-test-code/9/main.c

54 lines
1.0 KiB
C

#include "Key.H"
#include "STC15F2K60S2.H"
#include "displayer.h"
#include "sys.H"
#include "universal_decode_table.h"
code unsigned long SysClock = 11059200; //必须。定义系统工作时钟频率(Hz),用户必须修改成与实际工作频率(下载时选择的)一致
char start = 1;
int minute = 0, sec = 0, ms = 0;
void count()
{
if (start == 0)
{
return;
}
ms++;
sec += ms / 1000;
ms = ms % 1000;
minute += sec / 60;
sec = sec % 60;
Seg7Print(minute % 10, 12, sec / 10, sec % 10, 12, ms / 100, ms % 100 / 10, ms % 10);
}
void startStop()
{
if (GetKeyAct(enumKey1) == enumKeyPress)
{
start = 1;
}
if (GetKeyAct(enumKey2) == enumKeyPress)
{
start = 0;
}
}
void main()
{
DisplayerInit();
KeyInit();
SetDisplayerArea(0, 7);
Seg7Print(10, 10, 10, 10, 10, 10, 10, 10);
LedPrint(0x00);
SetEventCallBack(enumEventSys1mS, count);
SetEventCallBack(enumEventKey, startStop);
MySTC_Init();
while (1)
{
MySTC_OS();
}
}