📄 main.c
字号:
//-------------------------------------------------------------
// Copyright of xxxx Corp.
// Model :
// Version :
// Date :
//-------------------------------------------------------------
// Description :
// Update Note :
//-------------------------------------------------------------
//sbit key1 = P1^0;
//sbit key2 = P1^1;
//sbit key3 = P1^2;
//-------------------------------------------------------------
#define _MAIN_C
#include "header\include.h"
//--------------------------------------------------
// Global Variables
//--------------------------------------------------
UINT8 code seg_code[12] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf,0xff};//0xbf Display "-";
UINT8 code bit_code[8] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
void test(void);
//--------------------------------------------------
// Global Variables
//--------------------------------------------------
UINT8 ucBitFlag = 0; //for system bit fags
//--------------------------------------------------
// Description :
// Input Value : None
// Output Value : None
//--------------------------------------------------
void main(void)//main
{
SystemInit();
ActiveTimerEvent(5 ,test);
while(1)
{
TimeHandler();
Display();
KeyHandler();
}
}
//--------------------------------------------------
// Description :
// Input Value : None
// Output Value : None
//--------------------------------------------------
static void test(void)
{
P3 = 0x00;
}
//--------------------------------------------------
// Description :
// Input Value : None
// Output Value : None
//--------------------------------------------------
void SystemInit(void)
{
CLR_TIMERUN();
CLR_ALARM_ONOFF();
CLR_TIMER0_CRITICAL();
TimerEventInit();
UpdataTime(&stCurrTime);
UpdataTime(&stAlarmTime);
Timer0Init();
}
//--------------------------------------------------
// Description :
// Input Value : None
// Output Value : None
//--------------------------------------------------
void Display(void)
{
UINT8 i, k;
StTime * pTime;
if(SystemState == NormalDisplay)
{
for(i=0; i<8; i++)
{
P2 = bit_code[i];
P0 = seg_code[stCurrTime.TimeArray[i]];
Delay();
}
}
else
{
if(SystemState == ModifyTime)
pTime = &stCurrTime;
else
pTime = &stAlarmTime;
switch (mdfitem)
{
case mdfhour:
k = 0;
break;
case mdfminute:
k = 3;
break;
case mdfsecond:
k = 6;
break;
}
for(i=0;i<2;i++)
{
P2 = bit_code[i+k];
P0 = seg_code[pTime->TimeArray[i+k]];
Delay();
}
}
}
//--------------------------------------------------
// Description :
// Input Value : None
// Output Value : None
//--------------------------------------------------
void Delay(void)//Delay for Display
{
UINT16 i=100;
while(i--);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -