单片机源程序如下:
- #include "lcd12864.h"
- /* LCD写指令函数 */
- void LCD_Write_Com(unsigned char Com)
- {
- LCD_E = 0;
- LCD_RW = 0;
- LCD_RS = 0;
- LCD_E = 1;
- DB = Com;
- LCD_E = 0;
- }
- /* LCD写数据函数 */
- void LCD_Write_Data(unsigned char Data)
- {
- LCD_E = 0;
- LCD_RW = 0;
- LCD_RS = 1;
- LCD_E = 1;
- DB = Data;
- LCD_E = 0;
- }
- /* LCD写数据函数 */
- void LCD_Clear(void)
- {
- unsigned char i,j;
-
- /* 选择需要操作的半屏 */
- LCD_CS1 = 0;
- LCD_CS2 = 0;
-
- /* 设置LCD屏幕地址 */
- LCD_Write_Com(First_Line);
- LCD_Write_Com(First_Col);
-
- for(i = 0; i < 8; i++) //LCD12864一共有8页
- {
- LCD_Write_Com(First_Page + i); //控制页地址递增
- for(j = 0;j < 64; j++)
- {
- LCD_Write_Data(0x00); //写入数据刷白屏幕
- }
- }
- }
- /* LCD初始化函数 */
- void LCD_Init(void)
- {
- LCD_Write_Com(Disp_On); //开启液晶屏显示
- LCD_Clear();
- }
- /* 16*16大小的中文显示函数
- Page:在那一页
- Col: 在那一列
- *DZK:需要显示什么
- Num: 需要显示字模数组中的第几个汉字
- */
- void LCD_Chinses_Disp(unsigned char Page, unsigned char Col, unsigned char *DZK, unsigned char Num)
- {
- unsigned char i,j;
-
- Col = Col * 16;
- Num = Num * 32;
-
- LCD_Write_Com(First_Page + Page);
- LCD_Write_Com(First_Col + Col);
-
- for(i = 0; i < 2; i++)
- {
- LCD_Write_Com(First_Page + Page + i);
- LCD_Write_Com(First_Col + Col);
- for(j = 0; j < 16; j++)
- {
- LCD_Write_Data( DZK[16 * i + j + Num] );
- }
- }
- }
复制代码
所有资料51hei提供下载:
hello.rar
(46.41 KB, 下载次数: 37)
|