59 lines
1.1 KiB
C
59 lines
1.1 KiB
C
#include "STC15F2K60S2.H"
|
|
#include "displayer.h"
|
|
#include "hall.h"
|
|
#include "sys.H"
|
|
#include "universal_decode_table.h"
|
|
|
|
code unsigned long SysClock = 11059200; //必须。定义系统工作时钟频率(Hz),用户必须修改成与实际工作频率(下载时选择的)一致
|
|
|
|
char enableFlow = 0, ledOn = 0x10, ledOff = 0x00, counter = 20;
|
|
|
|
void HallEvent()
|
|
{
|
|
char event = GetHallAct();
|
|
if (event == enumHallGetClose)
|
|
{
|
|
enableFlow = 1;
|
|
}
|
|
else if (event == enumHallGetAway)
|
|
{
|
|
enableFlow = 0;
|
|
}
|
|
}
|
|
|
|
void flashLed()
|
|
{
|
|
if (!enableFlow)
|
|
{
|
|
LedPrint(ledOff);
|
|
return;
|
|
}
|
|
if (counter--)
|
|
{
|
|
return;
|
|
}
|
|
counter = 20;
|
|
ledOn <<= 1;
|
|
if (ledOn == 0x00)
|
|
{
|
|
ledOn = 0x10;
|
|
}
|
|
LedPrint(ledOn);
|
|
}
|
|
|
|
void main()
|
|
{
|
|
DisplayerInit();
|
|
HallInit();
|
|
SetEventCallBack(enumEventHall, HallEvent);
|
|
SetEventCallBack(enumEventSys10mS, flashLed);
|
|
SetDisplayerArea(0, 7);
|
|
Seg7Print(10, 10, 10, 10, 10, 10, 10, 10);
|
|
LedPrint(0x00);
|
|
MySTC_Init();
|
|
while (1)
|
|
{
|
|
MySTC_OS();
|
|
}
|
|
}
|