|
#include
#include "Port.h"
// 数码管是共阳极
// SEG线硬件连接方法定义(某位为 '1' 表示与数码管相对应的引脚相连)
#define SEG_A 0x01
#define SEG_B 0x02
#define SEG_C 0x04
#define SEG_D 0x08
#define SEG_E 0x10
#define SEG_F 0x20
#define SEG_G 0x40
#define SEG_Dot 0x80
// const unsigned char BitCnt[4] PROGMEM = // 如果数据是这样定义的
const unsigned char BitCnt[4] =
{
0,
1,
2,
3
};
// const unsigned char DisplayData[] PROGMEM = // 如果数据是这样定义的
const unsigned char DisplayData[] =
{
(SEG_A+SEG_B|SEG_C|SEG_D|SEG_E|SEG_F), // 0
(SEG_B|SEG_C), // 1
(SEG_A|SEG_B|SEG_D|SEG_E|SEG_G), // 2
(SEG_A|SEG_B|SEG_C|SEG_D|SEG_G), // 3
(SEG_B|SEG_C|SEG_F|SEG_G), // 4
(SEG_A|SEG_C|SEG_D|SEG_G|SEG_F), // 5
(SEG_A|SEG_C|SEG_D|SEG_E|SEG_G|SEG_F), // 6
(SEG_A|SEG_B|SEG_C), // 7
(SEG_A|SEG_B|SEG_C|SEG_D|SEG_E|SEG_F|SEG_G), // 8
(SEG_A|SEG_B|SEG_C|SEG_D|SEG_F|SEG_G), // 9
'\0',
(SEG_A|SEG_F|SEG_G|SEG_C|SEG_D), // S
(SEG_A|SEG_F|SEG_G|SEG_E|SEG_D), // E
(SEG_F|SEG_E|SEG_D)
};
// 显示缓冲区
unsigned char DisplayBuffer[4]=
{
1, 2, 3, 4
};
void ShowLed(void)
{
static unsigned char i;
DISPLAY_BIT_CNT |= 0x0f; // 消隐
// 下面两条语句怎么处理??
DISPLAY_LED = ~DisplayData[DisplayBuffer];
DISPLAY_BIT_CNT &= ~(1 << BitCnt[i++]);
if (i >= 4)
{
i = 0;
}
}
|
|