主函数
#include<ioCC2530.h>
#include"hal_LCD\LcdControl.h"
#define uint unsigned int
#define uchar unsigned char
#define uint unsigned int
#define uchar unsigned char
#define master_node
#ifdef master_node
#define LED1 P1_0
#define LED2 P1_1
#else
#define LED1 P1_1
#define LED2 P1_0
#endif
#define ON 1
#define OFF 0
#ifdef master_node
#define K1 P1_3
#define K2 P0_1
#else
#define K1 P0_1
#define K2 P0_7
#endif
void Delay(uint);
void InitLed(void);
void InitKey(void);
void LEDfun(void);
uchar KeyScan(void);
void Display_Picture(uint8 *picX);
int GlintFlag[2];
uchar KeyValue=0;
uint num = 999;
void Delay(uint n)
{
uint t;
for(t=0;t<n;t++);
for(t=0;t<n;t++);
for(t=0;t<n;t++);
for(t=0;t<n;t++);
for(t=0;t<n;t++);
}
void InitLed()
{
P1SEL&=~0x03;
P1DIR|=0x03;
LED2=OFF;
LED1=OFF;
}
void InitKey()
{
#ifdef master_node
P0SEL &=~0x02;
P0DIR &=~0x02;
P0INP |=0x02;
P1SEL &=~0x08;
P1DIR &=~0x08;
P1INP |=0x08;
#else
P0SEL &=~0x82;
P0DIR &=~0x82;
P0INP |=0x82;
#endif
}
uchar KeyScan(void)
{
if(K1 == 0)
{
Delay(2000);
if(K1 == 0)
{
while(!K1);
return (1);
}
}
else if(K2 == 0)
{
Delay(2000);
if(K2 == 0)
{
while(!K2);
return(2);
}
}
else
;
return(KeyValue);
}
void main(void)
{
InitLed();
InitKey();
HalLcd_HW_Init(pic2);
while(1){
KeyValue=KeyScan();
if(KeyValue == 2){
num=num-1;
KeyValue = 0;
}
if(KeyValue == 1){
num++;
KeyValue = 0;
}
if(num/1000!=0){
LCDDataShow(num/1000 ,2,3,0,7);
}
else {
LCDDataShow(0 ,2,3,0,7);
}
LCDDataShow(num/100%10,2,3,8 ,15);
LCDDataShow(num/10%10 ,2,3,16,23);
LCDDataShow(num%10 ,2,3,24,31);
}
}
完整代码下载