基于LPC2146手持设备的开发——LCD篇

/********************************************************************
*文件名:lcdDriver.c
*文件描述:
*创建人:Sha zq
*创建日期: 2007年09月06日
*版本号:1.0.01
*E-mail:sasinop@hotmail.com
*修改记录:
 1) 修改WriteChar()函数,详细说明见函数描述部分。 Sha zq 2007-9-20 11:10
********************************************************************/

#include "config.h"

/*******************************************************
外部函数声明
********************************************************/
extern void  DelayNS(uint32  dly);


/*******************************************************
常用操作命令和参数定义
********************************************************/

#define  DISPON  0x3f /*显示on  */
#define  DISPOFF 0x3e /*显示off  */
#define  DISPFIRST 0xc0 /*显示起始行定义 */
#define  SETX  0xb8 /*X定位设定指令(页) */
#define  SETY  0x40 /*Y定位设定指令(列) */
#define  Lcdbusy 0x80 /*LCM忙判断位  */

#define  para1         0x40; /*列开始*/

/*****************************************************************
O_X: 在显示字符时定义为行地址: 0~7,在绘点显示时定义为行地址(0-63)
O_Y: 列地址(0~127)
com: 指令码寄存器
dat1: 数据寄存器    
******************************************************************/
unsigned int O_X,O_Y,com,dat1;

/*****************************************************************
code_1:字表行号
count1:页地址
******************************************************************/
unsigned char code_1,count1;

unsigned char cbyte;
//unsigned char col,row,cbyte,keyd,t,Signal;  //列y,行(页)x,输出数据;keyd为键值;t为数组下标;Signal为触发传感器的编号

/*****************************************************************
定义0--9的字符数组
******************************************************************/
 
 unsigned char writeCH[9][8]={
                                    0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00,    /*"1"=11h*/
                                    0x00,0x42,0x61,0x51,0x49,0x46,0x00,0x00,    /*"2"=12h*/
                                    0x00,0x21,0x41,0x45,0x4B,0x31,0x00,0x00,    /*"3"=13h*/
                                    0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00,    /*"4"=14h*/
                                    0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00,    /*"5"=15h*/
                                    0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00,    /*"6"=16h*/
                                    0x00,0x01,0x01,0x79,0x05,0x03,0x00,0x00,    /*"7"=17h*/
                                    0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00,    /*"8"=18h*/
                                    0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00,    /*"9"=19h*/
  };
  
/*****************************************************************
定义a--z的字符数组
******************************************************************/   


unsigned char writeEH[26][8]={
                                    0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00,    /*"a"=41h*/
                                    0x00,0x7F,0x48,0x44,0x44,0x38,0x00,0x00,    /*"b"=42h*/
                                    0x00,0x38,0x44,0x44,0x44,0x28,0x00,0x00,    /*"c"=43h*/
                                    0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00,    /*"d"=44h*/
                                    0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00,    /*"e"=45h*/
                                    0x00,0x00,0x08,0x7E,0x09,0x02,0x00,0x00,    /*"f"=46h*/
                                    0x00,0x0C,0x52,0x52,0x4C,0x3E,0x00,0x00,    /*"g"=47h*/
                                    0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00,    /*"h"=48h*/
                                    0x00,0x00,0x44,0x7D,0x40,0x00,0x00,0x00,    /*"i"=49h*/
                                    0x00,0x20,0x40,0x44,0x3D,0x00,0x00,0x00,    /*"j"=4Ah*/
                                    0x00,0x00,0x7F,0x10,0x28,0x44,0x00,0x00,    /*"k"=4Bh*/
                                    0x00,0x00,0x41,0x7F,0x40,0x00,0x00,0x00,    /*"l"=4Ch*/
                                    0x00,0x7C,0x04,0x78,0x04,0x78,0x00,0x00,    /*"m"=4Dh*/
                                    0x00,0x7C,0x08,0x04,0x04,0x78,0x00,0x00,    /*"n"=4Eh*/
                                    0x00,0x38,0x44,0x44,0x44,0x38,0x00,0x00,    /*"o'=4Fh*/
                                    0x00,0x7E,0x0C,0x12,0x12,0x0C,0x00,0x00,    /*"p"=50h*/
                                    0x00,0x0C,0x12,0x12,0x0C,0x7E,0x00,0x00,    /*"q"=51h*/
                                    0x00,0x7C,0x08,0x04,0x04,0x08,0x00,0x00,    /*"r"=52h*/
                                    0x00,0x58,0x54,0x54,0x54,0x64,0x00,0x00,    /*"s"=53h*/
                                    0x00,0x04,0x3F,0x44,0x40,0x20,0x00,0x00,    /*"t"=54h*/
                                    0x00,0x3C,0x40,0x40,0x3C,0x40,0x00,0x00,    /*"u"=55h*/
                                    0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00,    /*"v"=56h*/
                                    0x00,0x3C,0x40,0x30,0x40,0x3C,0x00,0x00,    /*"w"=57h*/
                                    0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00,    /*"x"=58h*/
                                    0x00,0x1C,0xA0,0xA0,0x90,0x7C,0x00,0x00,    /*"y"=59h*/
                                    0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00,    /*"z"=5Ah*/

 
};
 
/*  西文字符库定义  */
 unsigned char  CHTAB[62][8]={
                                    0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,0x00,    /*"0"=10h*/
                                    0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00,    /*"1"=11h*/
                                    0x00,0x42,0x61,0x51,0x49,0x46,0x00,0x00,    /*"2"=12h*/
                                    0x00,0x21,0x41,0x45,0x4B,0x31,0x00,0x00,    /*"3"=13h*/
                                    0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00,    /*"4"=14h*/
                                    0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00,    /*"5"=15h*/
                                    0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00,    /*"6"=16h*/
                                    0x00,0x01,0x01,0x79,0x05,0x03,0x00,0x00,    /*"7"=17h*/
                                    0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00,    /*"8"=18h*/
                                    0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00,    /*"9"=19h*/

                                    0x00,0x7E,0x11,0x11,0x11,0x7E,0x00,0x00,    /*"A"=21h*/
                                    0x00,0x41,0x7F,0x49,0x49,0x36,0x00,0x00,    /*"B"=22h*/
                                    0x00,0x3E,0x41,0x41,0x41,0x22,0x00,0x00,    /*"C"=23h*/
                                    0x00,0x41,0x7F,0x41,0x41,0x3E,0x00,0x00,    /*"D"=24h*/
                                    0x00,0x7F,0x49,0x49,0x49,0x49,0x00,0x00,    /*"E"=25h*/
                                    0x00,0x7F,0x09,0x09,0x09,0x01,0x00,0x00,    /*"F"=26h*/
                                    0x00,0x3E,0x41,0x41,0x49,0x7A,0x00,0x00,    /*"G"=27h*/
                                    0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00,    /*"h"=28h*/
                                    0x00,0x00,0x41,0x7F,0x41,0x00,0x00,0x00,    /*"I"=29h*/
                                    0x00,0x20,0x40,0x41,0x3F,0x01,0x00,0x00,    /*"J"=2Ah*/
                                    0x00,0x7F,0x08,0x14,0x22,0x41,0x00,0x00,    /*"K"=2Bh*/
                                    0x00,0x7F,0x40,0x40,0x40,0x40,0x00,0x00,    /*"L"=2Ch*/
                                    0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00,    /*"M"=2Dh*/
                                    0x00,0x7F,0x06,0x08,0x30,0x7F,0x00,0x00,    /*"N"=2Eh*/
                                    0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00,    /*"O"=2Fh*/
                                    0x00,0x7F,0x09,0x09,0x09,0x06,0x00,0x00,    /*"P"=30h*/
                                    0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00,    /*"Q"=31h*/
                                    0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00,    /*"R"=32h*/
                                    0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00,    /*"S"=33h*/
                                    0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00,    /*"T"=34h*/
                                    0x00,0x3F,0x40,0x40,0x40,0x3F,0x00,0x00,    /*"U"=35h*/
                                    0x00,0x1F,0x20,0x40,0x20,0x1F,0x00,0x00,    /*"V"=36h*/
                                    0x00,0x7F,0x20,0x18,0x20,0x7F,0x00,0x00,    /*"W"=37h*/
                                    0x00,0x63,0x14,0x08,0x14,0x63,0x00,0x00,    /*"X"=38h*/
                                    0x00,0x07,0x08,0x70,0x08,0x07,0x00,0x00,    /*"Y"=39h*/
                                    0x00,0x61,0x51,0x49,0x45,0x43,0x00,0x00,    /*"Z"=3Ah*/

                                    0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00,    /*"a"=41h*/
                                    0x00,0x7F,0x48,0x44,0x44,0x38,0x00,0x00,    /*"b"=42h*/
                                    0x00,0x38,0x44,0x44,0x44,0x28,0x00,0x00,    /*"c"=43h*/
                                    0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00,    /*"d"=44h*/
                                    0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00,    /*"e"=45h*/
                                    0x00,0x00,0x08,0x7E,0x09,0x02,0x00,0x00,    /*"f"=46h*/
                                    0x00,0x0C,0x52,0x52,0x4C,0x3E,0x00,0x00,    /*"g"=47h*/
                                    0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00,    /*"h"=48h*/
                                    0x00,0x00,0x44,0x7D,0x40,0x00,0x00,0x00,    /*"i"=49h*/
                                    0x00,0x20,0x40,0x44,0x3D,0x00,0x00,0x00,    /*"j"=4Ah*/
                                    0x00,0x00,0x7F,0x10,0x28,0x44,0x00,0x00,    /*"k"=4Bh*/
                                    0x00,0x00,0x41,0x7F,0x40,0x00,0x00,0x00,    /*"l"=4Ch*/
                                    0x00,0x7C,0x04,0x78,0x04,0x78,0x00,0x00,    /*"m"=4Dh*/
                                    0x00,0x7C,0x08,0x04,0x04,0x78,0x00,0x00,    /*"n"=4Eh*/
                                    0x00,0x38,0x44,0x44,0x44,0x38,0x00,0x00,    /*"o'=4Fh*/
                                    0x00,0x7E,0x0C,0x12,0x12,0x0C,0x00,0x00,    /*"p"=50h*/
                                    0x00,0x0C,0x12,0x12,0x0C,0x7E,0x00,0x00,    /*"q"=51h*/
                                    0x00,0x7C,0x08,0x04,0x04,0x08,0x00,0x00,    /*"r"=52h*/
                                    0x00,0x58,0x54,0x54,0x54,0x64,0x00,0x00,    /*"s"=53h*/
                                    0x00,0x04,0x3F,0x44,0x40,0x20,0x00,0x00,    /*"t"=54h*/
                                    0x00,0x3C,0x40,0x40,0x3C,0x40,0x00,0x00,    /*"u"=55h*/
                                    0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00,    /*"v"=56h*/
                                    0x00,0x3C,0x40,0x30,0x40,0x3C,0x00,0x00,    /*"w"=57h*/
                                    0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00,    /*"x"=58h*/
                                    0x00,0x1C,0xA0,0xA0,0x90,0x7C,0x00,0x00,    /*"y"=59h*/
                                    0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00,    /*"z"=5Ah*/

                                    };
                                   
/*  中文字符库定义  */
 unsigned char  CCTAB[16][8]={
                                   0x82,0x8A,0x92,0xB2,0x02,0xA7,0x92,0x5E,     /*蓬90 = 00H*/
                                   0x2A,0xAF,0x2A,0x5A,0x4A,0x83,0x82,0x00,
                                   0x00,0x80,0x40,0x3F,0x41,0x90,0x95,0x95,
                                   0x95,0xFF,0x95,0x95,0x95,0xD0,0x40,0x00,
                                   0x80,0x64,0x24,0x24,0x3F,0x24,0xA6,0x64,     /*勃90 = 01H*/
                                   0x20,0x20,0xFF,0x20,0x20,0xF0,0x20,0x00,
                                   0x00,0x08,0x49,0x89,0x7D,0x0B,0x89,0x40,
                                   0x30,0x0E,0x41,0x80,0x40,0x3F,0x00,0x00,
                                   0x40,0x42,0x44,0xCC,0x00,0x20,0x22,0xE2,     /*远90 = 02H*/
                                   0x22,0x22,0xE2,0x23,0x32,0x20,0x00,0x00,
                                   0x00,0x40,0x20,0x1F,0x20,0x50,0x4C,0x43,
                                   0x40,0x40,0x47,0x48,0x48,0x6E,0x20,0x00,
                                   0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0x7F,     /*大90 = 03H*/
                                   0xA0,0x20,0x20,0x20,0x20,0x30,0x20,0x00,
                                   0x00,0x40,0x40,0x20,0x10,0x0C,0x03,0x00,
                                   0x01,0x06,0x08,0x10,0x20,0x60,0x20,0x00
                                   };                         

/*============================================================
* 函 数 名: sendData
* 参  数:data
* 功能描述:
*     通过LPC2146,的GPIO口模拟并行口,与LCM模块通信
* 返 回 值:Null
* 作  者:Sha zq 日期:2007/09/10
=============================================================*/  
 void sendData(unsigned char data)
{
 IO0DIR=0x007F8000; //P0.15---P0.22 作为输出
 
 IO0SET =(data<<15); // 并行发送数据给LCD,使用GPIO:P0.15---P0.22
 
// returnVal = ((IO0PIN>>15 ) & 0xff);
}


/*============================================================
* 函 数 名: WrcmdL
* 参  数:x
* 参数说明:x为写入的命令
* 功能描述:
*     写命令到左屏
* 返 回 值:Null
* 作  者:Sha zq 日期:2007/09/19
==============================================================*/

void WrcmdL(unsigned char x)
 {
  //左屏
           IO1SET =0x00020000; //CS1=1
  IO1CLR =0x00010000; //CS2=0
  
  DelayNS(1); 
  //busy()
  
  IO1CLR =0x00040000;  //p1.18 为低;  D/I=0  /命令操作 
  IO1CLR =0x00080000; //p1.19 为低  R/W=0 /写输出
    
  //命令输出到数据口
  sendData(x);
  
  IO1SET =0x00400000; //E = 1  下降沿,写入到LCM
  DelayNS(0);  
  IO1CLR =0X00400000; //E=0
  
  IO0CLR =~x & 0x007f8000;
  IO0DIR=0x00000000; //P0.15---P0.22 作为输入
  
 }

/*============================================================
* 函 数 名: WrcmdR
* 参  数:x
* 参数说明:x为写入的命令
* 功能描述:
*     写命令到右屏
* 返 回 值:Null
* 作  者:Sha zq 日期:2007/09/19
==============================================================*/

void WrcmdR(unsigned char x)
 {
  //右屏
  
         IO1CLR =0x00020000; //p1.17 为低; CS1=0
  IO1SET =0x00010000;   //p1.16 为高   CS2=1  
 
         //busy ()
         DelayNS(1); 
  //命令输出到数据口
  sendData(x);  
  
  IO1SET =0x00400000; //E = 1  下降沿,写入到LCM
  DelayNS(0); 
  
  IO1CLR =0X00400000; //E=0
  
  IO0CLR =~x & 0x007f8000;
  IO0DIR=0x00000000; //P0.15---P0.22 作为输入
  
 }
 
/*============================================================
* 函 数 名: NWrdataL
* 参  数:x
* 参数说明:x为写入数据
* 功能描述:
*     写数据到左屏
* 返 回 值:Null
* 作  者:Sha zq 日期:2007/09/19
==============================================================*/

void NWrdataL(unsigned char  x)
 {
         // 左屏
         IO1SET =0x00020000; //CS1=1
  IO1CLR =0x00010000; //CS2=0
  
  DelayNS(1); 
  // busy()
 
  IO1SET =0x00040000;  //p1.18 为低;  D/I=1
  IO1CLR =0x00080000; //p1.19 为低  R/W=0 /写输出
  
  
  //数据输出到数据口
  sendData(x);
  
  IO1SET =0x00400000; //E = 1  下降沿,写入到LCM
  DelayNS(0);
    
  IO1CLR =0X00400000; //E=0
  
  
  IO0CLR =~x & 0x007f8000;
  IO0DIR=0x00000000; //P0.15---P0.22 作为输入
  
 }
 
 
/*============================================================
* 函 数 名: NWrdataR
* 参  数:x
* 参数说明:x为写入数据
* 功能描述:
*     写数据到右屏
* 返 回 值:Null
* 作  者:Sha zq 日期:2007/09/19
==============================================================*/

void NWrdataR(unsigned char  x)
 {
  //右屏 
         IO1CLR =0x00020000; //p1.17 为低; CS1=0
  IO1SET =0x00010000;   //p1.16 为高   CS2=1  
  // busy()  wtcom();
  
  DelayNS(1); 
 
  IO1SET =0x00040000;  //p1.18 为低;  D/I=1  //p_di=1; // 数据输出 
  IO1CLR =0x00080000; //p1.19 为低  R/W=0 /写输出
  
  
  //数据输出到数据口
  sendData(x);
  
  IO1SET =0x00400000; //E = 1  下降沿,写入到LCM
  DelayNS(0);
    
  IO1CLR =0X00400000; //E=0
  
  
  IO0CLR =~x & 0x007f8000;
  IO0DIR=0x00000000; //P0.15---P0.22 作为输入
 
 }

/*============================================================
* 函 数 名: RddataL
* 参  数:Null
* 功能描述:
*     读左屏数据
* 返 回 值:Null
* 作  者:Sha zq 日期:2007/09/18
==============================================================*/
void RddataL(void)
 { 
  
  IO0SET =0x007f8000; //(data<<15); 
 
   // 左屏
         IO1SET =0x00020000; //CS1=1
  IO1CLR =0x00010000; //CS2=0
  
  //wtcom();  //  waitting for enable  
  
  IO1SET =0x00040000;  //p1.18 为低;  D/I=1  
  IO1SET =0x00080000; //p1.19 为低  R/W=1 
  IO1SET =0x00400000; //E = 1  下降沿,写入到LCM
  
  
  cbyte = ((IO0PIN>>15 ) & 0xff);// Datalcm; //虚读一次
  
  //Elcm = 0;
  DelayNS(0);
    
  IO1CLR =0X00400000; //E=0
  
  //Locatexy();  //坐标定位,返回时保留分区状态不变 
  
  //Datalcm=0xFF;
  IO0SET =0x007f8000; //(data<<15);  
  
   // 左屏
         IO1SET =0x00020000; //CS1=1
  IO1CLR =0x00010000; //CS2=0
  
  IO1SET =0x00040000;  //p1.18 为低;  D/I=1  
  IO1SET =0x00080000; //p1.19 为低  R/W=1 
  IO1SET =0x00400000; //E = 1  下降沿,写入到LCM
  
  
  cbyte = ((IO0PIN>>15 ) & 0xff);// Datalcm; /再读一次
  
  DelayNS(0);
    
  IO1CLR =0X00400000; //E=0  
  
  
 }
 

/*============================================================
* 函 数 名: RddataR
* 参  数:Null
* 功能描述:
*     读右屏数据
* 返 回 值:Null
* 作  者:Sha zq 日期:2007/09/18
==============================================================*/

 void RddataR(void)
 {
  IO0SET =0x007f8000; //(data<<15);
 
   // 右屏
         IO1CLR =0x00020000; //CS1=0
  IO1SET =0x00010000; //CS2=1
  
  //wtcom();  //  waitting for enable  
  
  IO1SET =0x00040000;  //p1.18 为低;  D/I=1  
  IO1SET =0x00080000; //p1.19 为低  R/W=1 
  IO1SET =0x00400000; //E = 1  下降沿,写入到LCM
  
  
  cbyte = ((IO0PIN>>15 ) & 0xff);// Datalcm; //虚读一次
  
  DelayNS(0);
    
  IO1CLR =0X00400000; //E=0
  
  
  IO0SET =0x007f8000; //(data<<15);  
  
   // 右屏
         IO1CLR =0x00020000; //CS1=0
  IO1SET =0x00010000; //CS2=1
  
  IO1SET =0x00040000;  //p1.18 为低;  D/I=1  
  IO1SET =0x00080000; //p1.19 为低  R/W=1 
  IO1SET =0x00400000; //E = 1  下降沿,写入到LCM
    
  cbyte = ((IO0PIN>>15 ) & 0xff);// Datalcm; /再读一次
  
  DelayNS(0);
    
  IO1CLR =0X00400000; //E=0 
 }
 
/*============================================================
* 函 数 名: ClearLCD
* 参  数:Null
* 功能描述:
*     清除LCD
* 返 回 值:Null
* 作  者:Sha zq 日期:2007/09/18
==============================================================*/  
void ClearLCD(void)
{
                for(count1=0xb8;count1!=0xcf;count1++)  //以页地址作为循环量
                {
                //count1    为页地址变量
                WrcmdL(count1);  //写左指令
               
                WrcmdR(count1);  //写右指令2007-9-20 14:14

                //列地址设置
                WrcmdL(0xc0);  //写左指令
               
                WrcmdR(0xc0);  //写右指令
               
                for(com=0;com<64;com++)   //清除所有HD61202的内部RAM单元
                     {
   NWrdataL(0x00);
   NWrdataR(0x00);//data1=0x00;
                                           
                     }
                }
         }


/*============================================================
* 函 数 名: InitLCD
* 参  数:Null
* 功能描述:
*     初始化LCD,完成LCD的 复位,及相关命令
* 返 回 值:Null
* 作  者:Sha zq 日期:2007/09/17
============================================================*/  
  void InitLCD()
        {
         IO1CLR =0x01000000; //res=0  复位信号为低 
  DelayNS(300);
  IO1SET =0x01000000; //RES = 1 复位信号为高
  
           //显示起始行为"0"
            WrcmdL(0xc0);
            DelayNS(1);
            WrcmdR(0xc0);
                      
            DelayNS(0);
            
            //开显示         
           WrcmdL(0x3f);
           DelayNS(1);
           WrcmdR(0x3f);               
        }
       

/*==========================================================================
* 函 数 名: CW_PR
* 参  数:Null
* 功能描述:
*     写入西文字符函数
* 返 回 值:Null
* 作  者:Sha zq 日期:2007/09/18
===============================================================================*/
void CW_PR()
        {
           unsigned char j;
          
                j=para1;
                com=O_Y|0xb8;
               
                WrcmdL(com);
                DelayNS(5);
                WrcmdR(com);
               
                O_Y=j;
              if(O_X<O_Y)
                 {
                   com=O_X;
                   //PR1();
                   WrcmdL(com);
                  
                   O_Y=1;
                 }
              else
                 {
                   DelayNS(5);
                   com=O_X-j;
                   //PR4();
                   WrcmdR(com);
                   DelayNS(1);
                   O_Y=0;
                 }
                
                 com=com&0x3f;
              for(count1=0;count1<8;count1++)
                 {
                   dat1=CHTAB[code_1][count1];
                      if(O_Y==1)
                         {
                            //PR2();
                            NWrdataL(dat1);
                             DelayNS(5);
                         }
                      else
                         {
                         //DelayNS(5);
                          
                            NWrdataR(dat1);
                          
                         }
                           
                      com++;
                     
                      if(com==j)
                        {
                            if(O_X==1)
                               {
                                   com=0x40;
                                   //PR4();
                                   WrcmdR(com);
                                   DelayNS(10);
                                   O_Y=0;
                               }
                         else
                           {
                            return;
                           }
                        }
                 }
        }

 


/*==========================================================================
* 函 数 名: W_DOT
* 参  数:Null
* 功能描述:
*     绘点函数
* 返 回 值:Null
* 作  者:Sha zq 日期:2007/09/18
* 说 明:暂未使用
===============================================================================*/ 
  void W_DOT()
        {
         unsigned int j;
           j=para1;
           com=O_Y/8;
           code_1=O_Y%8;
           com=com|0xb8;
           //PR1();
           //PR4();
           WrcmdL(com);
        
        WrcmdR(com);
          
           O_Y=1;
                  for(;code_1!=0;)
                      {
                          O_Y=O_Y*2;
                          code_1--;
                      }
                          if(O_X<j)
                            {
                                com=O_X|0x40;
                                //PR1();
                                //PR3();
                                //PR3();
                                //PR1();
                                WrcmdL(com);
                                RddataL();
                                RddataL();
                                WrcmdL(com);
                               
                                dat1=dat1|O_Y;
                               //PR2();
                               NWrdataL(dat1);
                            }
                          else
                            {
                                com=O_X-j|0x40;
                               // PR4();
                                //PR6();
                                //PR6();
                                //PR4();
                                WrcmdR(com);
                                RddataR();
                                RddataR();
                                WrcmdR(com);
                                dat1=dat1|O_Y;
        //PR5();
        NWrdataR(dat1);

                            }
        }
       
       
/*==========================================================================
* 函 数 名: CCW_PR
* 参  数:Null
* 功能描述:
*     写中文字符
* 返 回 值:Null
* 作  者:Sha zq 日期:2007/09/18
* 说 明:暂未使用
===============================================================================*/ 
void CCW_PR()
        {
           unsigned char i,j,k;
                i=0;
                j=para1;
    loop:       com=O_Y|0xb8;
                //PR1();
                //PR4();
                WrcmdL(com);
                WrcmdR(com);
               
                  if(O_X<j)
                     {
                        com=O_X|0x40;
                     //PR1();
                     WrcmdL(com);
                        k=1;
                     }
                  else
                     {
                        com=O_X-j|0x40;
                     //PR4();
                     WrcmdR(com);
                        k=0;
                     }
                      com=com&0x3f;
                  for(count1=i;count1<i+16;count1++)
                     {
                        dat1=CCTAB[code_1][count1];

                             if(k==1)
                                {
                                   //PR2();
                                   NWrdataL(dat1);
                                }
                             else
                                {
                                   //PR5();
                                   NWrdataR(dat1);
                                }
                                   com++;
                             if(com==j)
                                {
                                   if(k==1)
                                     {
                                        com=0;
                                       // PR4();
                                        WrcmdR(com);
                                        k=0;
                                      }
                                   else
         {
     goto loop2;
         }
                                }
                     }
         loop2:      if(i==0)
                     {
                         i=16;
                         O_Y++;
                         if(O_Y==8)
                            {
                                 return;
                            }
                         else
                            {
                                 goto loop;
                            }
                     }
        }
       
/*==========================================================================
* 函 数 名: WriteChar
* 参  数:Null
* 功能描述:
*     显示西文字符函数
* 返 回 值:Null
* 作  者:Sha zq 日期:2007/09/19
* 修改记录:
*  1) com=O_X;修改为: com=O_X|0x40;
*  2) com=O_X-j;修改为:com=O_X-j|0x40;  // sha zq 2007-9-20 11:02
*  3) 将 1),2)中的 0x40 改为:0xc0  //sha zq 2007-9-20 14:35
*修改说明: 1. 用原来的方法,自定义行么问题,而列显示不正常,修改后正常。
  2. 改为0xc0后,矫正了列显示错位
===============================================================================*/  
void WriteChar()       
{
 unsigned char j;
          
                j=para1;
                com=O_Y|0xb8;               
                WrcmdL(com);
                DelayNS(1);
                WrcmdR(com);               
                O_Y=j;
              if(O_X<O_Y)
                 {
                   //com=O_X;                  
                   com=O_X|0x40;
                   WrcmdL(com);                  
                   O_Y=1;
                 }
              else
                 {
                   //com=O_X-j;                  
                   com=O_X-j|0x40;
                   WrcmdR(com);
                  // DelayNS(1);
                   O_Y=0;
                 }
                
                 com=com&0x3f;
              for(count1=0;count1<8;count1++)
                 {
                   dat1=CHTAB[code_1][count1];
                      if(O_Y==1)
                         {
                            NWrdataL(dat1);
                             DelayNS(1);
                         }
                      else
                         {
                            DelayNS(1);
                            NWrdataR(dat1);                           
                         }
                           
                      com++;
                     
                      if(com==j)
                        {
                            if(O_X==1)
                               {
                                   com=0x40;                                 
                                   WrcmdR(com);
                                   DelayNS(1);
                                   O_Y=0;
                               }
                         else
                           {
                            return;
                           }
                        }
                 }
                }


/*==========================================================================
* 函 数 名: WriteCharE
* 参  数:Null
* 功能描述:
*     显示西文字符函数,显示英文字符
* 返 回 值:Null
* 作  者:Sha zq 日期:2007-9-20 16:37
* 修改记录:
===============================================================================*/  
void WriteCharE()       
{
 unsigned char j;
          
                j=para1;
                com=O_Y|0xb8;               
                WrcmdL(com);
                DelayNS(1);
                WrcmdR(com);               
                O_Y=j;
              if(O_X<O_Y)
                 {
                   //com=O_X;                  
                   com=O_X|0x40;
                   WrcmdL(com);                  
                   O_Y=1;
                 }
              else
                 {
                   //com=O_X-j;                  
                   com=O_X-j|0x40;
                   WrcmdR(com);
                  // DelayNS(1);
                   O_Y=0;
                 }
                
                 com=com&0x3f;
              for(count1=0;count1<8;count1++)
                 {
                   dat1=writeEH[code_1][count1];
                      if(O_Y==1)
                         {
                            NWrdataL(dat1);
                             DelayNS(1);
                         }
                      else
                         {
                            DelayNS(1);
                            NWrdataR(dat1);                           
                         }
                           
                      com++;
                     
                      if(com==j)
                        {
                            if(O_X==1)
                               {
                                   com=0x40;                                 
                                   WrcmdR(com);
                                   DelayNS(1);
                                   O_Y=0;
                               }
                         else
                           {
                            return;
                           }
                        }
                 }
                }               

/*============================================================
* 函 数 名:displayNumber
* 参  数:row,  col,  no
* 参数说明:row取值范围 0--7,col 取值范0--15, no 取值范围:0--9
* 功能描述:
*    用来显示0--9的数字,
* 返 回 值:Null
* 作  者:Sha zq 日期:2007/09/19
============================================================*/           
void displayNumber(unsigned char row, unsigned char col, unsigned char no)
{
           O_Y=row;
           O_X=col*8;
           code_1=no;
           WriteChar();  
 
 }   

/*============================================================
* 函 数 名:displayEnglishLow
* 参  数:row,  col,  no
* 参数说明:row取值范围 0--7,col 取值范0--15, no 取值范围:0--25
* 功能描述:
*    用来显示0--9的数字,
* 返 回 值:Null
* 作  者:Sha zq 日期:2007-9-20 16:38
============================================================*/           
void displayEnglishLow(unsigned char row, unsigned char col, unsigned char no)
{
           O_Y=row;
           O_X=col*8;
           code_1=no;
           WriteCharE();  
 
 }                   
 

 

已经在LPC2146 上调试通过,效果良好 呵呵,米前只能显示 英文字符 呵呵

有我问题可以发邮件和我联系

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值