⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd.c

📁 2407例程.rar
💻 C
📖 第 1 页 / 共 3 页
字号:
/*================本程序为OCM4X8C128X64内带中文字符集的液晶显示模块驱动程序=============================*/ 
/* 液晶驱动 ST7920
/* 采用并行工作方式
/* 控制系统芯片采用TMS320LF2407,主频40M 
/* 作者:杨广龙
pin:    1--GND  2--+3.3V  3--NC   4--RS    5--R/W  6--E
        7~14==D0~D7
        15--PSB 16--NC    17--/rst    18--NC
        19--A   20--K (19,20可能是背光)
        背面R6调节显示对比度,焊掉R6,在3和18之间接电位器调节对比度
  1、 initial()在运行前对液晶显示屏初始化

  2、 液晶显示屏命令
               x==0x01   清屏幕 约1.6ms
               x==0x02   地址和光标归零 HOME
                  0x06   光标右移、地址增加方式
                  0x09   闪烁
                  0x0a   显示光标
                  0x0c   显示内容
                  0x0f   内容、光标、闪烁全显示*/
  
 
#include "2407c.h"
#include "math.h" 
/*#include "sintab.h"
#include "DS1302.H" */

/*=================单独定义A口每个管脚状态=============*/
#define RS	2
#define WR	3
#define CS	4
#define PS	5
#define RT	6

#define	BIT(x)	(1<<(x))
#define	ZRO(x)	(0<<(x))

#define	SET_BIT(p,b)	p |= BIT(b)
#define	CLR_BIT(p,b)	p &= ~BIT(b)

#define CLR_RS   CLR_BIT(*PADATDIR,RS)    //0
#define SET_RS   SET_BIT(*PADATDIR,RS)    //1
#define WRITE    CLR_BIT(*PADATDIR,WR)    //0
#define READ     SET_BIT(*PADATDIR,WR)    //1
#define SET_E    SET_BIT(*PADATDIR,CS)    //1
#define CLR_E    CLR_BIT(*PADATDIR,CS)    //0
#define psb      SET_BIT(*PADATDIR,PS)//H=并口; L=串口;    
#define rst      CLR_BIT(*PADATDIR,RT)//Reset Signal 低电平
/*=================单独定义E口每个管脚状态=============*/ 
#define CLK	1
#define IO	2
#define RST	3

#define	BIT(x)	(1<<(x))
#define	ZRO(x)	(0<<(x))

#define	SET_BIT(p,b)	p |= BIT(b)
#define	CLR_BIT(p,b)	p &= ~BIT(b)

#define CLR_CLK    CLR_BIT(*PEDATDIR,CLK)    //0
#define SET_CLK    SET_BIT(*PEDATDIR,CLK)    //1
#define CLR_IO     CLR_BIT(*PADATDIR,WR)    //0
#define SET_IO     SET_BIT(*PADATDIR,WR)    //1
#define SET_RST    SET_BIT(*PEDATDIR,RST)    //1
#define CLR_RST    CLR_BIT(*PEDATDIR,RST)    //0

/*=================以下是定义变量=============*/ 
typedef unsigned char  uchar; 
typedef unsigned int  uint;
/*-----------------用于lcd-----------------*/
#define x1    0x80
#define x2    0x88
#define z    0x88 
#define comm  0
#define dat   1
uchar inData; 
uchar str2[6];
int flag_cursor;
unsigned char MyChar0[2];
unsigned char MyChar1[2]; 
unsigned char MyChar2[2]; 
unsigned char MyChar3[2]; 
unsigned char MyChar4[2]; 
unsigned char MyChar5[2]; 
unsigned char MyChar6[2]; 
unsigned char MyChar7[2]; 
unsigned char MyChar8[2];
unsigned char MyChar9[2]; 
/*-----------------用于AD-----------------*/ 

#define ADCNUMBER 128
int hh=0;
int hhh=1;
int hhhh=0;   
int nNewConvert,nWork;
unsigned int uWork,uWork1,nADCount,nLed,*pResult1,*pResult2; 

unsigned int  ADRESULT[128];
unsigned int nADCIn0[ADCNUMBER];	/* 存储区1,保存通道ADCIN0的转换结果,循环保存 */
unsigned int nADCIn1[ADCNUMBER];	/* 存储区2,保存通道ADCIN1的转换结果,循环保存 */  
volatile  unsigned   int  *s;            //定义一个指针变量j
int       q=0,cesi; 
int a; 
int zd=0,cishu=0;  
int shiyan=0; 
int abcd=0;  
int jishu;
/*-----------------用于sci-----------------*/ 
int   cc8 ; 
const int   aa[10]={1,2,3,4,5,6,7,8,9,10};    
const int bb[64]={	0x7FFF,0x0000,0x7F61 ,0xF375, 0x7D89 , 0xE708,0x7A7C , 0xDAD9,
                    0x7640, 0xCF05 ,0x70E1 ,0xC3AA ,0x6A6C , 0xB8E4 , 0x62F1 , 0xAECD ,
                    0x5A81, 0xA57F, 0x5133, 0x9D0F, 0x471C , 0x9594,  0x3C56,  0x8F1F,
                    0x30FB, 0x89C0 ,0x2527, 0x8584 ,0x18F8 , 0x8277 , 0x0C8B , 0x809F,
                    0x0000 ,0x8001, 0xF375, 0x809F, 0xE708 , 0x8277 , 0xDAD9 , 0x8584,
                    0xCF05 ,0x89C0 ,0xC3AA, 0x8F1F,0xB8E4 , 0x9594 , 0xAECD , 0x9D0F,
                    0xA57F, 0xA57F, 0x9D0F, 0xAECD, 0x9594 , 0xB8E4 , 0x8F1F , 0xC3AA,
                    0x89C0, 0xCF05, 0x8584 ,0xDAD9 ,0x8277 , 0xE708 , 0x809F , 0xF375 }; 
/*-----------------用于时钟DS1302-----------------*/ 
int  result[5];
/*-----------------用于按键-----------------*/ 
#define SetKey 2    //设定    
#define AddKey 3    // +
#define SubKey 4    // -
#define Esc    5    //退出

/*=================子程序列表=================*/ 
/*--------------用于2407-----------------*/
void  inline  disable();     //屏蔽中断子程序
void  inline  enable();      //开关中断子程序
void  ADINIT();              //AD初始化子程序
void interrupt  T2INT();      //AD中断
void  interrupt  adint();     //AD中断服务子程序
void  interrupt  nothing();   //该中断服务程序主要为了防止干扰,不做任何其他操作
void  initial();              //2407初始化
/*--------------用于lcd-----------------*/
/*LCDStart(unsigned char com);  //写入半个字节数据 */
unsigned char re_lcd ();      //从lcd中读入显示数据
void init_lcd();              //LCD初始化
void dis_str (uchar x, uchar y, uchar *str);   //显示字母数字在x,y处
void itoa(int x);                              //数字转换成字符
/*LCDPrintDot(unsigned char PlaceX,unsigned char PlaceY,unsigned char DotStatus);     //在LCD屏幕的指定座标x,y上描点 
LCDClearPicture(unsigned char PlaceY,unsigned char PlaceX,
				unsigned char WidthX,unsigned char WidthY);   //LCD图形区域清屏 
LCDPrintPicture(unsigned char const *px,unsigned char PlaceY,unsigned char PlaceX,
				unsigned char WidthX,unsigned char WidthY,unsigned char format);    //向LCD中GDRAM写入图形代码
LCDPrintLargeNumber(unsigned char *pd,unsigned char n,unsigned char DotNumber,
				unsigned char PlaceY,unsigned char PlaceX);   //在指定区域显示16x32格式的数字
LCDSelectPlace(unsigned char PlaceY,unsigned char PlaceX);    //设定字符串将要从y行,x列写入 */
void chn_disp (uchar const *chn,unsigned char PlaceY,unsigned char PlaceX,uchar n); //显示汉字或字符
void chn_disp1 (uchar const *chn);            //上半屏显示汉字或字符
void img_disp (uchar const *img);             //显示图形
void img_disp1 (uchar const *img);            //下半屏显示图形
void lat_disp (uchar data1,uchar data2);      //显示点阵
void con_disp (uchar data1,uchar data2,uchar x0,uchar y0,uchar xl,uchar yl);        //当data1=0xff,data2=0xff时,在x0,y0处反白显示16xl*yl
void clrram (void);                           //清DDRAM
void wr_lcd (uchar dat_comm,uchar content);   //写入数据或指令
void chk_busy (void);                         //判忙函数
void delay(int pp );                          //延时1uS
void jdt(unsigned char percent,unsigned char PlaceY,unsigned char ShowFlag);        //进度条的显示(在x轴方向显示)
void jdt1(uchar i);                           //进度条的进度
void XYzb();                                  //打点法画横纵坐标
void Line(uchar xx1, uchar yy1, uchar xx2, uchar yy2, uchar DotStatus);             //两点间画线程序 
/*--------------用于时钟ds1302-----------------*/
void   RTInputByte(uchar);       /* 输入 1Byte */
uchar  RTOutputByte(void);       /* 输出?1Byte */
void   W1302(uchar, uchar);
uchar  R1302(uchar);
void   Set1302(uchar *);         /* 设置时间 */
void   Bcd2asc(uchar,uchar *);
void   Get1302(uchar curtime[]); /* 读取1302当前时间 */ 
/*--------------主函数-----------------*/
void main ();                                 //主函数

/*=================以下是定义显示内容=============*/
uchar const tab00[]={"电源参数采集系统"};
uchar const tab0[]={"系统载入中 . . ."};
uchar const tab1[]={"Vmax ="};
uchar const tab2[]={"Vavg ="};
uchar const tab3[]={"Imax ="};
uchar const tab4[]={"Iavg ="};
uchar const tab5[]={"V "};
uchar const tab6[]={"V "};
uchar const tab7[]={"A "};
uchar const tab8[]={"A "};
uchar const tab11[]={"."};
uchar const tab12[]={"Vavg"};
uchar const tab22[]={"Iavg"};
uchar const tab33[]={"Hz"}; 
uchar const tab44[]={"A 相"};
uchar const tab55[]={"B 相"};
uchar const tab66[]={"C 相"};
uchar const tabaa[]={"0"};
uchar const tabz1[]={"电压电流特征值"};
uchar const tabz2[]={"电压电流波形"};
uchar const tabz3[]={"数据上传"};
uchar const tabz4[]={"系统时间"}; 
uchar const tabsc1[]={"串口"}; 
uchar const tabsc2[]={"232 "};
uchar const tabsc3[]={"速率"};
uchar const tabsc4[]={"24K"};
uchar const tabsc5[]={"USB"};
uchar const tabsc6[]={"CAN"};
uchar const tabsc7[]={"速率"};
uchar const tabsc8[]={"24K"}; 

uchar const tabbx1[]={"A "}; 
uchar const tabbx2[]={" V"};
uchar const tabbx3[]={"B "};
uchar const tabbx4[]={" V"};
uchar const tabbx5[]={"C "};
uchar const tabbx6[]={" V"};
uchar const tabbx7[]={"A "};
uchar const tabbx8[]={" I"};
uchar const tabbx9[]={"B "}; 
uchar const tabbx10[]={" I"};
uchar const tabbx11[]={"C "};
uchar const tabbx12[]={"I"};
uchar const tabbx13[]={"直流"};
uchar const tabbx14[]={" V"};
uchar const tabbx15[]={"直流"};
uchar const tabbx16[]={" I"};  

uchar const tabsj1[]={"2006年"}; 
uchar const tabsj2[]={"月"}; 
uchar const tabsj3[]={"日"};

uchar const tabzf[]={"50"};     



  
 





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -