/* ********************************************************** *函数名:LCD_WriteChar *功能: LCD写一个6X8的字符 *参数:c *返回值:无 备 注: ********************************************************** */ void LCD_WriteChar(unsigned char x,unsigned char y,unsigned char c) { unsigned char i; c -= 32; //数组的行号 LCD_Set_XY(x,y); for(i=0; i<6; i++) { LCD_WriteByte(font6x12[c][i], 1); if(i==5) { y++; LCD_Set_XY(x,y); } } }
/* ********************************************************** *函数名:LCD_Clear *功能: LCD清屏函数 *参数:无 *返回值:无 *备 注: ********************************************************** */ void LCD_Clear(void) { unsigned char t; unsigned char k; LCD_Set_XY(0, 0);//设置RAM起始地址 for(t=0;t<6;t++) { for(k=0;k<84;k++) { LCD_WriteByte(0x00,1); } } }
/* ********************************************************** *函数名:LCD_DrawPicture *功能: 绘图 *参数: X、Y :位图绘制的起始X、Y坐标; *map :位图点阵数据; Pix_x :位图像素(长) <=84 Pix_y :位图像素(宽) <=48 *返回值:无 *备 注: ********************************************************** */ void LCD_DrawPicture(unsigned char X,unsigned char Y,unsigned char const *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; //如果为位图所占行数不是整数 LCD_Set_XY(X,Y); for (n=0;n<row;n++) //换行 { for(i=0;i<Pix_x;i++) { LCD_Set_XY(X+i,Y+n); LCD_WriteByte(map[i+n*Pix_x], 1); } } }
void LCD_Write_Chinese_String(uchar X, uchar Y, uchar ch_with, uchar num, uchar line, uchar row) { uchar i,n; LCD_Set_XY(X,Y); //设置初始位置 for (i=0;i<num;) { for (n=0; n<ch_with*2; 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_WriteByte(write_chinese[line+i][n],1); } i++; LCD_Set_XY((X+(ch_with+row)*i),Y); } }
__interrupt void P1_ISR (void) // 按键控制PGA的通道切换 { if(P1IFG & BIT0) // P1.0中断,调节PGA的端口A { if(CD4051_A) { CD4051_A0; CHANNEl--; } else { CD4051_A1; CHANNEL++; } } else if(P1IFG & BIT6) { if(CD4051_B) { CD4051_B0; CHANNEL -= 2; } else { CD4051_B1; CHANNEL += 2; } } else if(P1IFG & BIT7) { if(CD4051_C) { CD4051_C0; CHANNEL -= 4; } else { CD4051_C1; CHANNEL += 4; } } LCD_Set_XY(66, 0); LCD_Write_Char((char)(CHANNEL + '0')); P1IFG = 0; // P1端口的中断标志位清零,等待下一次中断 }