锐单电子商城 , 一站式电子元器件采购平台!
  • 电话:400-990-0325

LCD12864驱动程序-51单片机

时间:2024-04-12 23:07:09

/****************************************************************************/

/* */ /* Copyright (c) 2012, pcwebmaster */ /* All rights reserved. */ /* */ /* Email:pcwebmaste@163.com */ /* */ /****************************************************************************/ /****************************************************************************/ /* 文件名: 12864.c */ /* 版 本:Version 1.0 */ /* 描 述:实现液晶和单片机的通讯协议,根据计算机发给的命令进行人机交互 */ /* 作 者:pcwebmaste */ /* 函 数: */ /* LCD12864_init */ /* LCD12864WriteCommand */ /* LCD12864WriteByte */ /* LCD12864_init */ /* LCD12864SetXY */ /* LCD12864PrintfString */ /* 历史记录: */ /* pcwebmaste 2008-07-10 Creat Inital version. (Version 1.0) */ /* 模块化 2012-06-02 Creat Inital version. (Version 2.0) */ /****************************************************************************/ #include "12864.h" #define LOW 0 #define HIGH 1 sbit wela = P2^6; sbit dula = P2^7; #define LCD12864_RS(x) {if((x))P3 |= 1< 基本指令操作 lcd12864writecommand(0x0c); 显示开,关光标 lcd12864writecommand(0x01); 清除lcd的显示内容 *函数名称:lcd12864setxy 入:x 横坐标 y 纵坐标 设置坐标 lcd12864setxy(unsigned x,unsigned y) if (x="=3)" {x="0x98;}" lcd12864writecommand(x+y); 显示地址 为什么这样写不行呢? switch(y) case 1: lcd12864writecommand(0x80+x); break; 2: lcd12864writecommand(0x90+x); 3: lcd12864writecommand(0x88+x); 4: lcd12864writecommand(0x98+x); default:break; *函数名称:lcd12864printfstring s字符串 打印字符串 lcd12864printfstring(unsigned y,unsigned *s) lcd12864setxy(x,y); 设置显示坐标 while(s && lcd12864writebyte(*s); 显示逐个字符 s++; **************************************************************************** copyright (c) 2012, pcwebmaster all rights reserved. email:pcwebmaste@163.com 文件名:lcd12864.c 版 本:version 1.0 描 述:实现液晶和单片机的通讯协议,根据计算机发给的命令进行人机交互 作 者:pcwebmaste 函 数: lcd12864_init lcd12864writecommand lcd12864writebyte lcd12864setxy lcd12864printfstring 历史记录: pcwebmaste 2008-07-10 creat inital version. (version 1.0) 模块化 2012-06-02 2.0) #ifndef __12864_h__ #include #include #define LCD12864_PORT P0 //数据口 #define LCD12864_RS_PIN 5 #define LCD12864_RW_PIN 6 #define LCD12864_EN_PIN 4 #define LCD12864_MD_PIN 7 unsigned char code dis1[] = {"中国昌乐是宝石"}; unsigned char code dis2[] = {"之都,西瓜之乡!"}; unsigned char code dis3[] = {"中国昌乐宝石城"}; unsigned char code dis4[] = {"人民欢迎您!"}; /******************************************** *函数名称:LCD12864_init *输 入:无 *输 出:lcd_busy 为1时,忙,等待。 lcd-busy 为0时,闲,可写指令与数据 *说 明:LCD12864LCD检查忙状态 /*******************************************/ bit LCD1286_busy(); /******************************************** *函数名称:LCD12864WriteCommand *输 入:ucCmd 要写入的命令 *输 出:无 *说 明:LCD12864 写命令 RS=L,RW=L,E=高脉冲,D0-D7=指令码。 ********************************************/ void LCD12864WriteCommand(unsigned char ucCmd); /******************************************** *函数名称:LCD12864WriteByte *输 入:ucByte 要写入的字节 *输 出:无 *说 明:LCD12864 写字节 RS=H,RW=L,E=高脉冲,D0-D7=数据。 ********************************************/ void LCD12864WriteByte(unsigned char ucByte); /******************************************** *函数名称:LCD12864_init *输 入:无 *输 出:无 *说 明:LCD12864LCD初始化设定 /*******************************************/ void LCD12864_init(); /*****
锐单商城拥有海量元器件数据手册IC替代型号,打造电子元器件IC百科大全!

相关文章