基于单片机设计课程设计论文 - 图文 下载本文

} }

void data_pro() {

uchar i;

for(i=0; i<6; i++) {

DTdata_tab[i]=*(ds_addr+DTdata_addr[i]); }

data_hl(); }

void data_hl() {

uchar i;

for(i=0; i<6; i++) {

if(i==3) {

if((DTdata_tab[i]&0x80)!=0) {

DTdata_tab[i]=(DTdata_tab[i]&0x7f)&0x7f; } }

data_h=DTdata_tab[i]/16; data_l=DTdata_tab[i]; lcd_pos(DT_lcdplace[i]);

lcd_wdat(data_h+48); //'0'=48 lcd_wdat(data_l+48); //'0'=48 } }

void date_init(void) //diaplay date: {

uchar i;

lcd_pos(0x00); for(i=0; i<15; i++) {

lcd_wdat(initdisp[i]); }

lcd_pos(0x40); for(i=16; i<29; i++) {

lcd_wdat(initdisp[i]); } }

/*void data_disp(uchar addr,addr1,data_1,data_0) {

uchar temp; lcd_pos(addr);

lcd_wdat(dis4[data_1]); lcd_wdat(dis4[data_0]);

29

data_1=data_1<<4; temp=data_1+data_0;

WrComm1BDa_1302(addr1,temp); }

Dsisplay.h

//----------------------------------------------------------------- // lcd_display子程序头文件 // 头文件名:lcd_display.h // 编程序者:cc // 编写时间:20.. // 修改日期:

//-----------------------------------------------------------------

#ifndef _lcd_display_h #define _lcd_display_h

//----------------------------------------------------------------- // 数据类型宏定义

//------------------------------------------------------------ #define uchar unsigned char #define uint unsigned int

//----------------------------------------------------------------- // I/O口定义

//------------------------------------------------------------

//----------------------------------------------------------------- // 外部变量声明

//------------------------------------------------------------ extern uchar code dis4[]; extern uchar code initdisp[]; extern uchar code DT_place[]; extern uchar code DT_lcdplace[]; extern uchar code DTdata_addr[]; extern uchar DTdata_tab[];

extern uchar code chars[8][6];

extern uchar data_h,data_l;

extern uchar xdata *ds_addr;

//----------------------------------------------------------------- // 外部函数声明

//------------------------------------------------------------

extern void date_init(void);

30

extern void data_wr();

//extern void char_disp(uchar loca,num);

extern void data_pro(); extern void data_hl();

#endif

4.2 调整部分软件设计 KEY.C

#include #include #include \

#include \#include \

// 初始化程序

// void key (void) //

// 函数功能: key process// 入口参数: 无// 返回参数: 无// 全局变量: 无// 调用模块: void key(void) {

uchar keyval=0; bit keyflag=0; if(keyset==0) { delay(10); if(keyset==0) { while(keyset==0); lcd_wcmd(0x0e); while(keyval!=6) { lcd_pos(DT_lcdplace[keyval]); if(keyset==0)

31

{ delay(10); if(keyset==0) { keyval++; while(keyset==0); } }

if(keyadd==0) { delay(10); if(keyadd==0) { keyflag=1; DTdata_tab[keyval]++; if((DTdata_tab[keyval]&0x0f)==0x0a) { DTdata_tab[keyval]=DTdata_tab[keyval]+6;

}

while(keyadd==0); } } if(keysub==0) { delay(10); if(keysub==0) { keyflag=1; DTdata_tab[keyval]--; if((DTdata_tab[keyval]&0x0f)==0x0f) { DTdata_tab[keyval]=DTdata_tab[keyval]-6; }

while(keysub==0);

}

}

if(keyflag==1) { keyflag=0;

datapro();

32