- /*
- @: KS0108,DS19264-5,19264 power-3.3V
- @:2015/10/17 21:04
- @:STM32F103RBT6 8位并口 IO->19264
- */
- //-----------------头文件------------------------------------
- #include "bsp.h"
- #include "hzlib.h"
- #include "zimo.h"
- #include "stm32f10x.h"
- #include "ds19264-5.h"
- //-------------------------------------------------并口定义---------------------------------------------
- #define Data_IO_IN {GPIOC->CRL |= 0xFFFFFFFF; GPIOC->CRL &= 0x44444444;} //方向设置为输入
- #define Data_IO_OUT {GPIOC->CRL &= 0x00000000; GPIOC->CRL |= 0x33333333;} //方向设置为输出
- #define Data_I() GPIOC->IDR &= 0x00FF //数据输入
- #define Data_O(x) {GPIOC->BSRR = 0x00FF0000; GPIOC->BSRR = x;} //数据输出
- //----------------------------------------------STM32F103 新定义---------------------------------------
- #define RS_H IO_SET(LCD_RS)
- #define RS_L IO_RESET(LCD_RS)
-
- #define RW_H IO_SET(LCD_RW)
- #define RW_L IO_RESET(LCD_RW)
-
- #define E_H IO_SET(LCD_E)
- #define E_L IO_RESET(LCD_E)
-
- #define CS1_H IO_SET(LCD_CS1)
- #define CS1_L IO_RESET(LCD_CS1)
-
- #define CS2_H IO_SET(LCD_CS2)
- #define CS2_L IO_RESET(LCD_CS2)
- #define CS3_H IO_SET(LCD_CS3)
- #define CS3_L IO_RESET(LCD_CS3)
-
- #define RST_H IO_SET(LCD_RST)
- #define RST_L IO_RESET(LCD_RST)
- #define RST(x) x?RST_H:RST_L// 复位信号,低电平有效;
- #define EN(x) x?E_H:E_L //使能信号
- #define RS(x) x?RS_H:RS_L //数据,指令选择信号,低电平选择指令,高电平选择数据;
- #define CS1(x) x?CS1_H:CS1_L //左片选信号;
- #define CS2(x) x?CS2_H:CS2_L //中片选信号;
- #define CS3(x) x?CS3_H:CS3_L //右片选信号;
- #define RW(x) x?RW_H:RW_L //读写信号,高电平为读,低电平为写;
- #define Dir_IN 0x00
- #define Dir_OUT 0x01
- #define LCM_CMD 0x00
- #define LCM_DAT 0x01
- #define RW_READ 0x01
- #define RW_WRITE 0x00
- //屏幕选择
- #define LCD_sel_left {CS3_H;CS2_H;CS1_L;} //左屏
- #define LCD_sel_middle {CS1_H;CS2_L;CS3_H;} //中屏
- #define LCD_sel_right {CS2_H;CS1_H;CS3_L;} //右屏
- u8 Col,Page;
- //------------------------------------液晶延时函数---------------------------------------------
- void delay_us(u8 cd)
- {
- u16 ma;
- for(;cd>0;cd--)
- for(ma=0;ma<50;ma++);//old,ma=50
- }
- void delay_ms(unsigned int cd)
- {
- u16 ma;
- for(;cd>0;cd--)
- for(ma=0;ma<1000;ma++);
- }
- //液晶读写数据方向控制
- //低电平输出,高电平读入
- void OCM_DIR_InOut(u8 x)
- {
- if(x==Dir_IN)
- {
- //IN
- Data_IO_IN;
- }
- else
- {
- //OUT
- Data_IO_OUT;
- }
- }
- //IO输出数据
- void OCM_Data_Out(u8 dat)
- {
- Data_O(dat); //指令
- }
- //IO读数据
- u8 OCM_Data_In(void)
- {
- u8 dat = Data_I();
- return dat; //指令
- }
- //=============================================================================
- void LCD_reset_hard(void)
- {
- RST_L;
- delay_ms(1);
- RST_H;
- } //硬件复位
- /*--------------------------------------------------------------*/
- //读出指令(状态)
- unsigned char LCD_read_cmd(void)
- {
- unsigned char read_cmd;
- Data_IO_OUT;
- Data_O(0xff); //输入
- RS_L; //指令
- RW_H; //读出
- E_H; //高电平读出
- Data_IO_IN;
- delay_us(10);//old=20
- read_cmd = Data_I(); //指令
- E_L;
- return (read_cmd);
- }
- /*--------------------------------------------------------------*/
- //读出数据
- //先只须空读一次, 以后接着就无须空读
- //空读之后读出的数据都是有效的!!!
- unsigned char LCD_read_dat(void)
- {
- unsigned char read_dat;
- Data_IO_OUT;
- Data_O(0xff); //输入
- RS_H; //数据
- RW_H; //读出
- E_H; //高电平读出
- Data_IO_IN;
- delay_us(10);//old=20
- read_dat = Data_I(); //数据
- E_L;
- return (read_dat);
- }
- /*--------------------------------------------------------------*/
- //检查忙标志位
- void LCD_check_busy(void)
- {
- unsigned char lcd_status;
- do
- {
- lcd_status = LCD_read_cmd();
- }
- while(lcd_status & 0x80);
- //delay_us(20);
- }
- /*--------------------------------------------------------------*/
- //写入指令
- void LCD_write_cmd(unsigned char cmd)
- {
- //LCD_check_busy();
- delay_us(3);//old=15
- RS_L; //指令
- RW_L; //写入
- Data_IO_OUT;
- Data_O(cmd); //指令
- E_H;
- delay_us(3);//old=20
- E_L; //下降沿写入
- }
- /*--------------------------------------------------------------*/
- //写入数据
- void LCD_write_dat(unsigned char dat)
- {
- //LCD_check_busy();
- delay_us(3);//old=15
- RS_H; //数据
- RW_L; //写入
- Data_IO_OUT;
- Data_O(dat); //数据
- E_H;
- delay_us(3);//old=20
- E_L; //下降沿写入
- }
- /*--------------------------------------------------------------*/
- //液晶字节定位(8*1)
- //液晶规划:
- //x: 0 - 7 (行)
- //y: 0 -127 (列)
- void LCD_byte_pos(unsigned char x, unsigned char y)
- {
- if(y < 64)
- {
- LCD_sel_left //左半屏
- }
- else if(y>=64 && y<128)
- {
- y -= 64;
- LCD_sel_middle
- }
- else
- {
- y -= 128;
- LCD_sel_right
- } //右半屏
- // LCD_write_cmd(Start_Line); //起始行地址
- LCD_write_cmd(X_Page_Addr + x); //页地址0-7
- LCD_write_cmd(Y_Col_Addr + y); //列地址0-63
- }
- /*--------------------------------------------------------------*/
- //液晶字符定位(8*8)
- //液晶规划:
- //x: 0 - 7 (行)
- //y: 0 -15 (列)
- void LCD_char_pos(unsigned char x, unsigned char y)
- {
- y <<= 3;
- LCD_byte_pos(x, y);
- }
- /*--------------------------------------------------------------*/
- //显示清屏
- void LCD_clr_scr(unsigned char sel_dat)
- {
- unsigned char i, j;
-
- if(sel_dat == 0)
- {
- LCD_sel_left
- for(j = 0; j < 8; j++)
- {
- LCD_write_cmd(X_Page_Addr + j);
- LCD_write_cmd(Y_Col_Addr);
- for(i = 0; i < 64; i++) LCD_write_dat(0x00);
- }
- }
- else if(sel_dat == 1)
- {
- LCD_sel_middle
- for(j = 0; j < 8; j++)
- {
- LCD_write_cmd(X_Page_Addr + j);
- LCD_write_cmd(Y_Col_Addr);
- for(i = 0; i < 64; i++) LCD_write_dat(0x00);
- }
- }
- else if(sel_dat == 2)
- {
- LCD_sel_right
- for(j = 0; j < 8; j++)
- {
- LCD_write_cmd(X_Page_Addr + j);
- LCD_write_cmd(Y_Col_Addr);
- for(i = 0; i < 64; i++) LCD_write_dat(0x00);
- }
- }
- //else if(sel_dat == 2) LCD_sel_all
- else if(sel_dat == 3)
- {
- LCD_sel_left
- for(j = 0; j < 8; j++)
- {
- LCD_write_cmd(X_Page_Addr + j);
- LCD_write_cmd(Y_Col_Addr);
- for(i = 0; i < 64; i++) LCD_write_dat(0x00);
- }
- LCD_sel_middle
- for(j = 0; j < 8; j++)
- {
- LCD_write_cmd(X_Page_Addr + j);
- LCD_write_cmd(Y_Col_Addr);
- for(i = 0; i < 64; i++) LCD_write_dat(0x00);
- }
- LCD_sel_right
- for(j = 0; j < 8; j++)
- {
- LCD_write_cmd(X_Page_Addr + j);
- LCD_write_cmd(Y_Col_Addr);
- for(i = 0; i < 64; i++) LCD_write_dat(0x00);
- }
- }
- }
- /*--------------------------------------------------------------*/
- //读出8bytes数据
- //液晶规划:
- //x: 0 - 7 (行)
- //y: 0 -15 (列)
- void LCD_read_8bytes(unsigned char x, unsigned char y, unsigned char *read_dat)
- {
- unsigned char i;
- LCD_char_pos(x, y); LCD_read_dat(); //空读一次!!!
- for(i = 0; i < 8; i++)
- {
- *read_dat = LCD_read_dat();
- read_dat++;
- }
- }
- /*--------------------------------------------------------------*/
- #if Font_type //(8*16字体)
- /*--------------------------------------------------------------*/
- //液晶字符输出(8*16字体)
- //x: 0 -3 (行)
- //y: 0 -15 (列)
- void LCD_printc(unsigned char x, unsigned char y, unsigned char c_dat,unsigned char flag)
- {
- unsigned char i, j;
- for(j = 0; j < 2; j++)
- {
- LCD_char_pos((x * 2 + j), y);
- for(i = 0; i < 8; i++)
- {
- if(flag == ZHENGXIAN)
- LCD_write_dat( Font_code[c_dat - 32][8 * j + i]);
- else
- LCD_write_dat(~Font_code[c_dat - 32][8 * j + i]);
- }
- }
- }
- /*--------------------------------------------------------------*/
- #else //(8*8字体)
- /*--------------------------------------------------------------*/
- //液晶字符输出(8*8字体)
- //x: 0 - 7 (行)
- //y: 0 -15 (列)
- //flag:高四位为0,正显,不为零,反显
- void LCD_printc(unsigned char x, unsigned char y, unsigned char c_dat,unsigned char flag)
- {
- unsigned char i;
- //me,判断坐标范围,old y>15
- if(x>7 ) x=0;
- if(y>23) y=0;
- //定位显示位置
- LCD_char_pos(x, y);
- for(i = 0; i < 6; i++)
- {
- if(flag == ZHENGXIAN)
- LCD_write_dat( Font_code[c_dat - 32][i]);
- else
- LCD_write_dat(~Font_code[c_dat - 32][i]);
- }
- }
- //显示ASC码
- void LCD_printcu8(unsigned char x, unsigned char y, u8 c_dat,u8 flag)
- {
- unsigned char i;
- if(x>7 || y>15)//me,判断坐标范围
- return;
- LCD_char_pos(x, y);
- for(i = 0; i < 6; i++)
- if(flag == ZHENGXIAN)
- LCD_write_dat(Font_code[c_dat - 32][i]);
- else
- LCD_write_dat(~Font_code[c_dat - 32][i]);
- }
- #endif
- /*--------------------------------------------------------------*/
- //液晶字符串输出
- //x: 0 - 3 (行)
- //y: 0 -15 (列)
- //flag:高四位为0正显,不为零反显
- void LCD_prints(unsigned char x, unsigned char y, unsigned char *s_dat,unsigned char flag)
- {
- while(*s_dat)
- {
- LCD_printc(x, y++, *s_dat++,flag);
- }
- }
- /*--------------------------------------------------------------*/
- //液晶字符反 {MOD}区域(8*8字体)
- //x: 0 - 7 (行)
- //y: 0 -15 (列)
- void LCD_inverse(unsigned char x, unsigned char y)
- {
- unsigned char i;
- unsigned char read_buffer[8];
- LCD_read_8bytes(x, y, read_buffer);
- LCD_char_pos(x, y);
- for(i = 0; i < 8; i++) LCD_write_dat(~read_buffer[i]);
- }
- void LCD_inverse1(unsigned char x, unsigned char y)
- {
- unsigned char i;
- unsigned char read_buffer[6];
- LCD_read_8bytes(x, y, read_buffer);
- LCD_char_pos(x, y);
- for(i = 0; i < 6; i++) LCD_write_dat(~read_buffer[i]);
- }
- /*--------------------------------------------------------------*/
- //液晶反 {MOD}显示
- void LCD_scr_inverse(void)
- {
- unsigned char i, j;
- for(j = 0; j < 8; j++)
- {
- for(i = 0; i < 16; i++) LCD_inverse(j, i);
- }
- }
- /*--------------------------------------------------------------*/
- #if Font_type //(8*16字体)
- /*--------------------------------------------------------------*/
- //液晶字符反 {MOD}输出(8*16字体)
- //x: 0 - 3 (行)
- //y: 0 -15 (列)
- void LCD_inversec(unsigned char x, unsigned char y)
- {
- x <<= 1;
- LCD_inverse(x, y);
- LCD_inverse(x+1, y);
- }
- /*--------------------------------------------------------------*/
- #else //(8*8字体)
- /*--------------------------------------------------------------*/
- //液晶字符反 {MOD}输出(8*8字体)
- //x: 0 - 7 (行)
- //y: 0 -15 (列)
- void LCD_inversec(unsigned char x, unsigned char y)
- {
- LCD_inverse(x, y);
- }
- #endif
- /*--------------------------------------------------------------*/
- //液晶字符串反 {MOD}输出
- //x: 0 -3/7 (行)
- //y: 0 -15 (列)
- //num: num < 16 - y
- void LCD_inverses(unsigned char x, unsigned char y, unsigned char num)
- {
- while(num--) LCD_inversec(x, y++);
- }
- /*--------------------------------------------------------------*/
- //液晶汉字输出(16*16字体)
- //取码规则: 低位在前, 列行扫描, 阴码(1-亮, 0-灭)
- //x: 0 - 3 (行)
- //y: 0 - 7 (列)
- //flag:0-显示;1-反显
- //len:待显示汉字的长度
- void LCD_PrintHZ16(unsigned char x, unsigned char y, unsigned char index,unsigned char flag)
- {
- unsigned char i, j;
- //unsigned char hh = sizeof(hz_gs)/32;
- unsigned char wz = index ;
-
- //if((len==0) || (len>9)) return;//长度不对,可进一步判断,几个汉字,从第几列开始//
- y <<= 1;//汉字
-
- for(j = 0; j < 2; j++)
- {
- LCD_char_pos(x+j, y);
-
- if(flag & FANXIAN)
- for(i = 0; i < 16; i++)
- {
- //tt=LCD_read_dat();
- LCD_write_dat(~zimo[wz][i+j*16]);//(hh-0x10)*94+ll-1=字模位置,hh and ll=qu qweima,quweima=neima-0xA0A0
- }
- else if(flag & ZHENGXIAN)
- for(i = 0; i < 16; i++)
- {
- //tt=LCD_read_dat();
- LCD_write_dat( zimo[wz][i+j*16]);
- }
-
- }
- }
- /*--------------------------------------------------------------*/
- //液晶单个汉字输出(16*16字体)
- //取码规则: 低位在前, 列行扫描, 阴码(1-亮, 0-灭)
- //x: 0 - 3 (行)
- //y: 0 - 7 (列)
- //h_dat:汉字数组的指针
- //flag:0,正常显示,1,反显
- void LCD_printHZ(unsigned char x, unsigned char y, const unsigned char *hzsy,unsigned char len,unsigned char flag)
- {
- unsigned char i;
- for(i=0;i<len;i++)
- {
- LCD_PrintHZ16(x, y+i, hzsy[i],flag);
- }
- }
- /*--------------------------------------------------------------*/
- //液晶汉字输出(16*16字体)
- //取码规则: 低位在前, 列行扫描, 阴码(1-亮, 0-灭)
- //x: 0 - 3 (行)
- //y: 0 - 7 (列)
- //flag:0-显示;1-反显
- //len:待显示汉字的长度
- void LCD_printhz(unsigned char x, unsigned char y, unsigned char *neima,unsigned char flag,unsigned char len)
- {
- unsigned char i, j, k;
- unsigned short qweima,*qw;
- unsigned char hh,ll;
- if((len==0) || (len>8)) return;//长度不对,可进一步判断,几个汉字,从第几列开始//
- x <<= 1;y <<= 1;
- for(k=0;k<len;k++)
- {
- //位码转换
- qweima=*((unsigned short *)(neima+k*2));
- hh=qweima&0xFF;//变换字节
- ll=(qweima >>8) & 0xFF;
- qweima =hh<<8 | ll;
- //----------------
- qweima=qweima-41120;//B0A1-A0A0=1001 ->啊,1
- qw=&qweima;
- hh=*((unsigned char *)qw+1);
- ll=*(unsigned char *)qw;
- //----------------
- for(j = 0; j < 2; j++)
- {
- LCD_char_pos((x + j), y+k*2);
-
- if(flag & 0xF0)
- for(i = 0; i < 16; i++) LCD_write_dat(~zimo[(hh-0x10)*94+ll-1][i+j*16]);//(hh-0x10)*94+ll-1=字模位置,hh and ll=qu qweima,quweima=neima-0xA0A0
- //for(i = 0; i < 16; i++) LCD_write_dat( ~ *(zimo+(hh-0x10)*94+ll-1+i+j*16));
- else
- for(i = 0; i < 16; i++) LCD_write_dat( zimo[(hh-0x10)*94+ll-1][i+j*16]);
- //for(i = 0; i < 16; i++) LCD_write_dat( *(zimo+(hh-0x10)*94+ll-1+i+j*16));
-
- }
- //y <<= 1;
- }
- }
- /*--------------------------------------------------------------*/
- //液晶汉字反 {MOD}输出(16*16字体)
- //x: 0 - 3 (行)
- //y: 0 - 7 (列)
- void LCD_inversech(unsigned char x, unsigned char y)
- {
- x <<= 1; y <<= 1;
- LCD_inverse(x, y);
- LCD_inverse(x, y+1);
- LCD_inverse(x+1, y);
- LCD_inverse(x+1, y+1);
- }
- /*--------------------------------------------------------------*/
- //液晶汉字词组反 {MOD}输出
- //x: 0 - 3 (行)
- //y: 0 - 8 (列)
- //num: num < 8 - y 汉字个数
- void LCD_inversesh(unsigned char x, unsigned char y, unsigned char num)
- {
- while(num--) {LCD_inversech(x, y); y++;}
- }
- /*--------------------------------------------------------------*/
- //液晶定位写入数据一个字节
- //液晶规划:
- //x: 0 - 7 (页)
- //y: 0 -127 (列)
- void LCD_write_dat_pos(unsigned char x, unsigned char y, unsigned char dat)
- {
- LCD_byte_pos(x, y);
- LCD_write_dat(dat);
- }
- /*--------------------------------------------------------------*/
- //液晶定位读出数据一个字节
- //液晶规划:
- //x: 0 - 7 (页)
- //y: 0 -127 (列)
- unsigned char LCD_read_dat_pos(unsigned char x, unsigned char y)
- {
- unsigned char read_dat;
- LCD_byte_pos(x, y);
- read_dat = LCD_read_dat(); //dummy读
- read_dat = LCD_read_dat(); //数据有效
-
- return (read_dat);
- }
- /*--------------------------------------------------------------*/
- //显示128X64图片
- //取码规则: 低位在前, 列行扫描, 阴码(1-亮, 0-灭)
- void LCD_picture(unsigned char *img_dat)
- {
- unsigned char i, j;
- for(j = 0; j < 8; j++)
- {
- for(i = 0; i < 128; i++)
- {
- LCD_write_dat_pos(j, i, img_dat[j * 128 + i]);
- }
- }
- }
- /*--------------------------------------------------------------*/
- //定位显示指定大小图片
- //取码规则: 低位在前, 列行扫描, 阴码(1-亮, 0-灭)
- //pag: 0 - 7 页坐标
- //col: 0 - 127 列坐标
- //x: 0 - (127-col) 图片宽
- //y: 0 - (63-pag*8) 图片高
- void LCD_pos_picture(unsigned char pag, unsigned char col, unsigned char x, unsigned char y, unsigned char *img_dat)
- {
- unsigned char i, j;
- y = (y + 4) >> 3; //四舍五入
- for(j = 0; j < y; j++)
- {
- for(i = 0; i < x; i++)
- {
- LCD_write_dat_pos(pag + j, col + i, img_dat[j * x + i]);
- }
- }
- }
- /*--------------------------------------------------------------*/
- //画点函数
- //x: 0 - 127 横坐标
- //y: 0 - 63 列坐标
- //attr: =1, 画点
- // =0, 消点
- void LCD_pixel(unsigned char x, unsigned char y, unsigned char attr)
- {
- unsigned char pixel_dat, temp_dat, yy;
-
- yy = y >> 3; //划分到页
- pixel_dat = LCD_read_dat_pos(yy, x);//读出数据
- temp_dat = 0x01 << (y & 0x07); //页中的点
- if(attr) pixel_dat |= temp_dat; //画点
- else pixel_dat &= ~temp_dat; //消点
- LCD_write_dat_pos(yy, x, pixel_dat);//写入组合数据
- }
- /*--------------------------------------------------------------*/
- //画横线
- //y: 0 - 63 列坐标
- //attr: =1, 画线
- // =0, 消线
- void LCD_line_h(unsigned char x,unsigned char ex,unsigned char y, unsigned char attr)
- {
- unsigned char i;
- for(i = x; i < ex; i++) LCD_pixel(i, y, attr);
- }
- /*--------------------------------------------------------------*/
- //画竖线
- //x: 0 - 128 横坐标
- //attr: =1, 画线
- // =0, 消线
- void LCD_line_v(unsigned char x, unsigned char attr)
- {
- unsigned char i;
- for(i = 0; i < 64; i++) LCD_pixel(x, i, attr);
- }
- /*--------------------------------------------------------------*/
- //显示直线
- //x: 0 - 128 横坐标
- //y: 0 - 63 纵坐标
- //attr: =1, 画线
- // =0, 消线
- void LCD_line(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char attr)
- {
- char dx, dy;
- int inc_x, inc_y;
- int xerr = 0, yerr = 0; //初始化变量
- unsigned char i, ds;
- dx = x2 - x1; //计算坐标增量
- dy = y2 - y1;
- if(dx > 0)
- inc_x = 1; //设置单步方向
- else
- {
- if(dx == 0)
- {
- inc_x = 0;
- } //垂直线
- else
- {
- inc_x = -1;
- dx =(char)( (-1)*dx);
- }
- }
- if(dy > 0)
- inc_y = 1; //设置单步方向
- else
- {
- if(dy == 0)
- {
- inc_y = 0;
- } //水平线
- else
- {
- inc_y = -1;
- dy = (char)((-1)*dy);
- }
- }
- if(dx > dy)
- ds = dx; //选取基本增量坐标轴
- else
- ds = dy;
- for(i = 0; i <= ds+1; i++) //画线输出
- {
- LCD_pixel(x1, y1, attr); //画点
- xerr += dx;
- yerr += dy;
- if(xerr > ds)
- {
- xerr -= ds;
- x1 += inc_x;
- }
- if(yerr > ds)
- {
- yerr -= ds;
- y1 += inc_y;
- }
- }
- }
- /*--------------------------------------------------------------*/
- //画矩形
- //x1: 0 - 128 起点更坐标
- //y1: 0 - 63 起点纵坐标
- //x2: 0 - 128 长度
- //y2: 0 - 63 高度
- //attr: =1, 画线
- // =0, 消线
- void LCD_rectangle(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char attr)
- {
- LCD_line(x1, y1, x1+x2, y1,attr);//-
- LCD_line(x1, y1, x1, y1+y2,attr);//|
- LCD_line(x1, y1+y2, x1+x2, y1+y2, attr);//_
- LCD_line(x1+x2,y1, x1+x2, y1+y2, attr);// |
- }
- /*--------------------------------------------------------------*/
- //复位LCD128*64
- void LCD_reset_12864(void)
- {
- LCD_sel_left;
- LCD_write_cmd(Display_Off); //关闭显示
- LCD_sel_middle;
- LCD_write_cmd(Display_Off); //关闭显示
- LCD_sel_right;
- LCD_write_cmd(Display_Off); //关闭显示
-
- CS1_L;CS2_L;CS3_L;
- LCD_write_cmd(X_Page_Addr); //起始页地址
- LCD_write_cmd(Start_Line); //起始行
- LCD_write_cmd(Y_Col_Addr); //起始列地址
- CS1_H;CS2_H;CS3_H;
- LCD_sel_middle;
- LCD_write_cmd(Display_On); //开启显示
- LCD_sel_left;
- LCD_write_cmd(Display_On); //开启显示
- LCD_sel_right;
- LCD_write_cmd(Display_On); //开启显示
- //LCD_clr_scr(RSCR); //清左屏
- //LCD_clr_scr(LSCR); //清左屏
- LCD_clr_scr(3);
- }
- //清除某个矩形
- void LCD_clr_position(u8 startx,u8 starty,u8 endx,u8 endy)
- {
- unsigned char j = endx -startx + 1;
- u16 i = endy - starty;
- //清屏
- for(;j>0;j--)
- {
- i = endy - starty;
- while(i--)
- {
- LCD_printc(startx,endy-i, 32,ZHENGXIAN);
- }
- }
- }
- /*--------------------------------------------------------------*/
- //液晶字符输出(8*16字体)
- //x: 0 -3 (行)
- //y: 0 -15 (列)
- //flag=0,正常显示,否则反显
- void LCD_Printsz(unsigned char x, unsigned char y, unsigned char sz,unsigned char flag)
- {
- unsigned char i, j;
- unsigned char tt=sz;
- for(j = 0; j < 2; j++)
- {
- LCD_char_pos(x + j,y);
- if(flag==ZHENGXIAN)
- for(i = 0; i < 8; i++)
- LCD_write_dat(shuzi[tt][8 * j + i]);//9.6temp
- else
- for(i = 0; i < 8; i++)
- LCD_write_dat(~shuzi[tt][8 * j + i]);//9.6temp
- }
- }
- /*--------------------------------------------------------------*/
- //液晶字符输出(8*16字体)
- //x: 0 -3 (行)
- //y: 0 -15 (列)
- //flag=0,正常显示,否则反显
- void LCD_PrintUINT(unsigned char x, unsigned char y, unsigned int sz,unsigned char len,unsigned char flag)
- {
- unsigned char i, j,k;
- unsigned char dd[3];
-
- if(sz>999) return;
-
- dd[0]=sz%10;
- dd[1]=sz%100/10;
- dd[2]=sz%1000/100;
- for(k=0;k<len;k++)
- {
- for(j = 0; j < 2; j++)
- {
- LCD_char_pos(x + j,y);
- if(flag==ZHENGXIAN)
- for(i = 0; i < 8; i++)
- LCD_write_dat(shuzi[dd[len-k-1]][8 * j + i]);//9.6temp
- else
- for(i = 0; i < 8; i++)
- LCD_write_dat(~shuzi[dd[len-k-1]][8 * j + i]);//9.6temp
- }
- y++;
- }
- }
- /*--------------------------------------------------------------*/
- //初始化LCD128*64
- void LCD_init_19264(void)
- {
- LCD_reset_hard(); //硬件复位
- LCD_reset_12864(); //软件复位
- }
复制代码
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
貌似是8080,IO模拟的无所谓啊,根据手册来...
如果要用F(S)MC总线的话才需要考虑是那种总线
小哥哥,能否把头文件也贴出来呢
头文件没什么东西,重点是看Io输出高低电平就行,字库根据自己的需求弄个
一周热门 更多>