毕业设计单片机液晶显示器多功能显示(3)

2019-04-21 17:07

安徽财贸职业学院

LCD_write_char : 显示英文字符 输入参数:c :显示的字符; 编写日期 :2009-5-1 最后修改日期 :2009-5-1

-----------------------------------------------------------------------*/ void LCD_write_char(unsigned char c) {

unsigned char line; c -= 32;

for (line=0; line<6; line++)

LCD_write_byte(font6x8[c][line], 1); }

/*----------------------------------------------------------------------- LCD_write_english_String : 英文字符串显示函数 输入参数:*s :英文字符串指针;

X、Y : 显示字符串的位置,x 0-83 ,y 0-5 编写日期 :2009-5-1 最后修改日期 :2009-5-1

-----------------------------------------------------------------------*/

void LCD_write_english_string(unsigned char X,unsigned char Y,char *s) {

LCD_set_XY(X,Y); while (*s) { }

/*----------------------------------------------------------------------- LCD_write_chinese_string: 在LCD上显示汉字 输入参数:X、Y :显示汉字的起始X、Y坐标; ch_with :汉字点阵的宽度

-9-

LCD_write_char(*s); s++;

}

安徽财贸职业学院

num :显示汉字的个数; line :汉字点阵数组中的起始行数 row :汉字显示的行间距 编写日期 :2009-5-1 最后修改日期 :2009-5-1 测试:

LCD_write_chi(0,0,12,7,0,0); LCD_write_chi(0,2,12,7,0,0); LCD_write_chi(0,4,12,7,0,0);

-----------------------------------------------------------------------*/ void LCD_write_chinese_string(unsigned char X, unsigned char Y, unsigned char ch_with,unsigned char num, unsigned char line,unsigned char row) {

unsigned char i,n;

LCD_set_XY(X,Y); //设置初始位置

for (i=0;i

for (n=0; n

if (n==ch_with) //写汉字的下半部分 {

if (i==0) LCD_set_XY(X,Y+1); else

LCD_set_XY((X+(ch_with+row)*i),Y+1); }

LCD_write_byte(write_chinese[line+i][n],1); } i++;

LCD_set_XY((X+(ch_with+row)*i),Y); }

-10-

安徽财贸职业学院

}

/*----------------------------------------------------------------------- LCD_move_chinese_string: 汉字移动

输入参数:X、Y :显示汉字的起始X、Y坐标; T :移动速度; 编写日期 :2009-5-1 最后修改日期 :2009-5-2

-----------------------------------------------------------------------*/ void chinese_string (unsigned char X, unsigned char Y, unsigned char T) {

unsigned char i,n,j=0;

unsigned char buffer_h[84]={0}; unsigned char buffer_l[84]={0};

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

buffer_h[83] = move_chinese_string[i/12][j]; buffer_l[83] = move_chinese_string[i/12][j+12]; j++;

if (j==12) j=0;

for (n=0; n<83; n++) {

buffer_h[n]=buffer_h[n+1]; buffer_l[n]=buffer_l[n+1]; }

LCD_set_XY(X,Y); for (n=0; n<83; n++) {

LCD_write_byte(buffer_h[n],1); }

-11-

安徽财贸职业学院

LCD_set_XY(X,Y+1); for (n=0; n<83; n++) {

LCD_write_byte(buffer_l[n],1); }

delay_nms(T); } }

/*----------------------------------------------------------------------- LCD_draw_map : 位图绘制函数

输入参数:X、Y :位图绘制的起始X、Y坐标; *map :位图点阵数据; Pix_x :位图像素(长) Pix_y :位图像素(宽) 编写日期 :2009-5-1 最后修改日期 :2009-5-2

-----------------------------------------------------------------------*/

void LCD_draw_bmp_pixel(unsigned char X,unsigned char Y,unsigned char *map, unsigned char Pix_x,unsigned char Pix_y) {

unsigned int i,n; unsigned char row;

if (Pix_y%8==0) row=Pix_y/8; //计算位图所占行数 else

row=Pix_y/8+1;

for (n=0;n

LCD_set_XY(X,Y); for(i=0; i

-12-

安徽财贸职业学院

{

LCD_write_byte(map[i+n*Pix_x], 1); }

Y++; //换行 } }

/*----------------------------------------------------------------------- LCD_write_byte : 使用SPI接口写数据到LCD 输入参数:data :写入的数据; command :写数据/命令选择; 编写日期 :2009-5-1 最后修改日期 :2009-5-2

-----------------------------------------------------------------------*/ void LCD_write_byte(unsigned char dat, unsigned char command) {

unsigned char i;

//PORTB &= ~LCD_CE ; LCD_CE = 0;

if (command == 0)

// PORTB &= ~LCD_DC ; // 传送命令 LCD_DC = 0; else

// PORTB |= LCD_DC ; LCD_DC = 1;

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

if(dat&0x80)

LCD_SDIN = 1; LCD_SDIN = 0; else

LCD_SCLK = 0; dat = dat << 1;

// 传送数据

// 使能LCD

-13-


毕业设计单片机液晶显示器多功能显示(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:山西省忻州一中2014-2015学年高二下学期期末考试数学(理)试卷

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: