/*========================================================================= ** 函数名: LCD_draw_pixel ** 函数功能简介: 将一个二维图像矩阵在nokia5110中显示 ** 输入参数: image :要显示图像矩阵的首地址(指针)(可以是数组名); line :图像行数(像素点); row : 图像列数(像素点); threshold: 二值化阀值(如果是二值化以后的图像,阀值为0); X :开始显示的X坐标; Y :开始显示的Y坐标(0-5); ** 返回参数: 无 ** 作 者: 张盛平 ** 编写日期: 2013-6-29 ** 修改历史: 2013-6-29 ** 添加日期: 2013-07-04 ===========================================================================*/ void LCD_draw_pixel(void *image, unsigned char line, unsigned char row, unsigned char threshold,unsigned char X, unsigned char Y) { unsigned char *p_image, i, j, k, temp,n; p_image = image; // if(line > 0) n=line/8; for(i=0;i<n;i++) { LCD_set_XY(0+X,i+Y); for(j=0;j<row;j++) { for(k=0;k<8;k++) { ((*(p_image+(i*8+k)*row+j))>threshold) ? (temp &= ~(1<<k)):(temp |= 1<<k) ; } LCD_write_byte(temp,1); } } if(line%8) { for(j=0;j<row;j++) { for(k=0;k<line%8;k++) { ((*(p_image+(i*8+k)*row+j))>threshold) ? (temp &= ~(1<<k)) : (temp |= 1<<k); } LCD_write_byte(temp,1); } } }
/* * write char in big font */ void LCD4884::LCD_write_char_big (unsigned char X,unsigned char Y, unsigned char ch, char mode) { unsigned char i, j; unsigned char *pFont; unsigned char ch_dat; pFont = (unsigned char *) big_number; if (ch == '.') ch = 10; else if (ch == '+') ch = 11; else if (ch == '-') ch = 12; else ch = ch & 0x0f; for (i=0; i<3; i++) { LCD_set_XY(X, Y + i); for (j=0; j<16; j++) { ch_dat = pgm_read_byte(pFont+ch*48 + i*16 +j); if (mode != MENU_NORMAL) ch_dat ^= 0xff; LCD_write_byte(ch_dat, 1); } } }
void LCD4884::LCD_write_string(byte X, byte Y, const char *s, char mode) { LCD_set_XY(X, Y); while (*s) { LCD_write_char(*s, mode); s++; } }
void LCD4884::LCD_write_string(unsigned char X,unsigned char Y,char *s, char mode) { LCD_set_XY(X,Y); while (*s) { LCD_write_char(*s, mode); s++; } }
/*----------------------------------------------------------------------- LCD_write_english_String : 英文字符串显示函数 输入参数:*s :英文字符串指针; X、Y : 显示字符串的位置,x 0-83 ,y 0-5 编写日期 :2004-8-10 最后修改日期 :2004-8-10 -----------------------------------------------------------------------*/ void LCD_write_english_string(unsigned char X,unsigned char Y,char *s) { LCD_set_XY(X,Y); while (*s) { LCD_write_char(*s); s++; } }
/*FUNCTION*------------------------------------------------------------------- * * Function Name : LCD_write_String * Returned Value : void * Comments : * This function put a string to LCD * *END*----------------------------------------------------------------------*/ void LCD_write_String(unsigned char X,unsigned char Y,unsigned char invert,char *s) { LCD_set_XY(X,Y); while (*s) { LCD_write_char(*s,invert); s++; } }
void LCD_Display_String(unsigned char X,unsigned char Y, uint8 *s) { LCD_set_XY(X, Y); while(*s != 0) { LCD_write_char(*s); s++; } }
void LCD4884::LCD_write_chinese(byte X, byte Y, const byte *c, byte ch_with, byte num, byte line, byte row) { byte 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_write_byte(c[(i * ch_with * 2) + n], 1); } i++; LCD_set_XY((X + (ch_with + row) * i), Y); } }
/*----------------------------------------------------------------------- LCD_clear : LCD清屏函数,并且将XY坐标清零 编写日期 :2004-8-10 最后修改日期 :2004-8-10 -----------------------------------------------------------------------*/ void LCD_clear(void) { unsigned int i; LCD_write_byte(0x0c, 0); LCD_write_byte(0x80, 0); for (i=0; i<504; i++) LCD_write_byte(0, 1); LCD_set_XY(0,0); //将XY坐标清零 }
void LCD4884::LCD_write_chinese(unsigned char X, unsigned char Y,unsigned char *c,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<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_write_byte(c[(i*ch_with*2) + n], 1); } i++; LCD_set_XY((X+(ch_with+row)*i),Y); } }
void LCD_cursor(unsigned char row) { unsigned char t; unsigned char k; LCD_set_XY(0,0); for(t=0;t< row;t++) { for(k=0;k<84;k++) { LCD_write_byte(0xff,1); } } sce1; }
/*FUNCTION*------------------------------------------------------------------- * * Function Name : LCD_clear * Returned Value : void * Comments : * This function clear LCD * *END*----------------------------------------------------------------------*/ void LCD_clear(void) { unsigned char t; unsigned char k; LCD_set_XY(0,0); for(t=0;t<6;t++) { for(k=0;k<84;k++) { LCD_write_byte(0x0,1); } } sce1; }
/*==============图像显示函数(智能车不常用,数组的一字节写nokia5110的8个点)======== LCD_draw_picture : 将一个二维图像矩阵在nokia5110中显示 输入参数:start_x :显示图像的开始的行号; start_y :显示图像的开始的列号; map : 图像数组; line : 行数; row :列数(0-5); 编写日期 :2013-6-29 最后修改日期 :2013-6-29 加入日期 :2013-07-04 ================================================================================*/ void LCD_draw_picture(unsigned char start_x, unsigned char start_y, unsigned char *map, unsigned char line, unsigned row) { unsigned char *p; unsigned i,j; p= map; for(i=0;i<line;i++) { LCD_set_XY(start_x,start_y+i); for(j=0;j<row;j++) { LCD_write_byte(*p++,1); } } }
/*----------------------------------------------------------------------- LCD_write_chinese_string: 在LCD上显示汉字 输入参数:X、Y :显示汉字的起始X、Y坐标; ch_with :汉字点阵的宽度 num :显示汉字的个数; line :汉字点阵数组中的起始行数 row :汉字显示的行间距 编写日期 :2004-8-11 最后修改日期 :2004-8-12 测试: 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<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_write_byte(write_chinese[line+i][n],1); } i++; LCD_set_XY((X+(ch_with+row)*i),Y); } }
void LCD_write_num(u8 X, u8 Y, int num) { u8 b[6], i; LCD_set_XY(X,Y); for(i = 0; i < 6; i++) { b[5-i] = (num % 10) + '0'; num = num / 10; } for(i = 0; i < 6; i++) { LCD_write_char(b[i]); } }
void LCD4884::LCD_draw_bmp_pixel(byte X, byte Y, const byte *map, byte Pix_x, byte Pix_y) { unsigned int i, n; byte row; if (Pix_y % 8 == 0) row = Pix_y / 8; else row = Pix_y / 8 + 1; for (n = 0; n < row; n++) { LCD_set_XY(X, Y); for (i = 0; i < Pix_x; i++) { LCD_write_byte(map[i + n * Pix_x], 1); } Y++; } }
void LCD4884::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<row; n++) { LCD_set_XY(X, Y); for (i=0; i<Pix_x; i++) { LCD_write_byte(map[i + n*Pix_x], 1); } Y++; } }
/***********显示电源电压*************/ void power_display(void) { u8 a,b,c; a=(u8)((power_get()/100)+48); b=(u8)(((power_get()%100)/10)+48); c=(u8)((power_get()%10)+48); LCD_set_XY(0,0); LCD_write_char('P'); LCD_write_char('O'); LCD_write_char('W'); LCD_write_char('E'); LCD_write_char('R'); LCD_write_char(':'); LCD_write_char(a); LCD_write_char('.'); LCD_write_char(b); LCD_write_char(c); LCD_write_char('V'); }
void LCD4884::LCD_write_digital_chr(byte x, byte y, byte ch, char mode) { int i, j; int ch_dat; if ( ch==':' ) { ch = 10; } else if ( ch=='.' ) { ch = 11; } else if ( ch==' ' ) { ch = 12; } else if ( ch>='0' && ch<='9' ) { ch -= '0'; } else { return; // error character } for (i=0; i<3; i++) { // width = 24 = 3byte LCD_set_XY(x, y + i); for (j = 0; j < 16; j++) { ch_dat = digatalFont[ch][i*16+j]; LCD_write_byte((mode == LCD_NORMAL) ? ch_dat : (ch_dat ^ 0xff), 1); } } }
/* write char in big font */ void LCD4884::LCD_write_char_big(byte X, byte Y, byte ch, char mode) { int i, j; int ch_dat; if (ch == '.') ch = 10; else if (ch == '+') ch = 11; else if (ch == '-') ch = 12; else ch = ch & 0x0f; for (i = 0; i < 3; i++) { LCD_set_XY(X, Y + i); for (j = 0; j < 16; j++) { //ch_dat = pgm_read_byte(pFont+ch*48 + i*16 +j); ch_dat = big_number[ch][i][j]; LCD_write_byte((mode == LCD_NORMAL) ? ch_dat : (ch_dat ^ 0xff), 1); } } }
void KYELCD(void){ static u8 t8rmp0 = 0,t8rmp1 = 0; static u8 AupDown ; u8 AspeedS0, AspeedS1, AspeedS2, AspeedS3; if(key8flg >= 1) { keyflg = 0 ; key8flg -- ; if(AupDown > 0) { AupDown -- ; } } if(key11flg >= 1) { if(AupDown < 5) { AupDown ++ ; } keyflg = 0 ; key11flg -- ; } /********************* 160ms程序执行代码段 *********************/ if(TIME0flag_80ms == 1) { TIME0flag_80ms = 0 ; if(AupDown == 0) { if(key9flg >= 1) { keyflg = 0 ; ASPeed0 += key9flg ; key9flg = 0 ; } if(key10flg >= 1){ keyflg = 0 ; if((ASPeed0-key10flg) < 0) { ASPeed0 = 0 ; key10flg = 0 ; } else { ASPeed0 -= key10flg ; key10flg = 0 ; } } } else if(AupDown == 1) { if(key9flg >= 1) { keyflg = 0 ; ASPeed1 += key9flg ; key9flg = 0 ; } if(key10flg >= 1){ keyflg = 0 ; if((ASPeed1-key10flg) < 0) { ASPeed1 = 0 ; key10flg = 0 ; } else { ASPeed1 -= key10flg ; key10flg = 0 ; } } } else if(AupDown == 2) { if(key9flg >= 1) { keyflg = 0 ; ASPeed2 += key9flg ; key9flg = 0 ; } if(key10flg >= 1){ keyflg = 0 ; if((ASPeed2-key10flg) < 0) { ASPeed2 = 0 ; key10flg = 0 ; } else { ASPeed2 -= key10flg ; key10flg = 0 ; } } } else if(AupDown == 3) { if(key9flg >= 1) { keyflg = 0 ; ASPeed3 += key9flg ; key9flg = 0 ; } if(key10flg >= 1){ keyflg = 0 ; if((ASPeed3-key10flg) < 0) { ASPeed3 = 0 ; key10flg = 0 ; } else { ASPeed3 -= key10flg ; key10flg = 0 ; } } } else if(AupDown == 4) { if(key9flg >= 1) { keyflg = 0 ; ASPeed4 += key9flg ; key9flg = 0 ; } if(key10flg >= 1){ keyflg = 0 ; if((ASPeed4-key10flg) < 0) { ASPeed4 = 0 ; key10flg = 0 ; } else { ASPeed4 -= key10flg ; key10flg = 0 ; } } } else if(AupDown == 5) { if(key9flg >= 1) { keyflg = 0 ; ASPeed5 += key9flg ; key9flg = 0 ; } if(key10flg >= 1){ keyflg = 0 ; if((ASPeed5-key10flg) < 0) { ASPeed5 = 0 ; key10flg = 0 ; } else { ASPeed5 -= key10flg ; key10flg = 0 ; } } } if(t8rmp0 == 1) { t8rmp0 = 0 ; if(AupDown == 0) LCD_set_XY(0, 0) ; else if(AupDown == 1) LCD_set_XY(0, 1) ; else if(AupDown == 2) LCD_set_XY(0, 2) ; else if(AupDown == 3) LCD_set_XY(0, 3) ; else if(AupDown == 4) LCD_set_XY(0, 4) ; else if(AupDown == 5) LCD_set_XY(0, 5) ; for(t8rmp1 = 0 ; t8rmp1 < 83 ;t8rmp1 ++) { LCD_write_byte(0, 1); } } else{ t8rmp0 = 1 ; LCD_set_XY(0, 0) ; LCD_write_char('L'); LCD_write_char('a'); LCD_write_char('n'); LCD_write_char('d'); LCD_write_char('z'); LCD_write_char('o'); /************** 第二行显示内容 ************* */ AspeedS0 = (u8) ((ASPeed1/1000) + 48 ); AspeedS1 = (u8) (((ASPeed1%1000)/100) +48 ) ; AspeedS2 = (u8) (((ASPeed1%100)/10) + 48 ); AspeedS3 = (u8) ((ASPeed1%10) + 48 ); LCD_set_XY(0, 1) ; LCD_write_char('S'); LCD_write_char('p'); LCD_write_char('e'); LCD_write_char('e'); LCD_write_char('d'); LCD_write_char('0'); LCD_write_char(':'); LCD_write_char(AspeedS0); LCD_write_char(AspeedS1); LCD_write_char(AspeedS2); LCD_write_char(AspeedS3); /************** 第三行显示内容 **************/ AspeedS0 = (u8) ((ASPeed2/1000) + 48 ); AspeedS1 = (u8) (((ASPeed2%1000)/100) +48 ) ; AspeedS2 = (u8) (((ASPeed2%100)/10) + 48 ); AspeedS3 = (u8) ((ASPeed2%10) + 48 ); LCD_set_XY(0, 2) ; LCD_write_char('S'); LCD_write_char('p'); LCD_write_char('e'); LCD_write_char('e'); LCD_write_char('d'); LCD_write_char('1'); LCD_write_char(':'); LCD_write_char(AspeedS0); LCD_write_char(AspeedS1); LCD_write_char(AspeedS2); LCD_write_char(AspeedS3); /************** 第四行显示内容 **************/ AspeedS0 = (u8) ((ASPeed3/1000) + 48 ); AspeedS1 = (u8) (((ASPeed3%1000)/100) +48 ) ; AspeedS2 = (u8) (((ASPeed3%100)/10) + 48 ); AspeedS3 = (u8) ((ASPeed3%10) + 48 ); LCD_set_XY(0, 3) ; LCD_write_char('S'); LCD_write_char('p'); LCD_write_char('e'); LCD_write_char('e'); LCD_write_char('d'); LCD_write_char('2'); LCD_write_char(':'); LCD_write_char(AspeedS0); LCD_write_char(AspeedS1); LCD_write_char(AspeedS2); LCD_write_char(AspeedS3); /************** 第五行显示内容 **************/ AspeedS0 = (u8) ((ASPeed4/1000) + 48 ); AspeedS1 = (u8) (((ASPeed4%1000)/100) +48 ) ; AspeedS2 = (u8) (((ASPeed4%100)/10) + 48 ); AspeedS3 = (u8) ((ASPeed4%10) + 48 ); LCD_set_XY(0, 4) ; LCD_write_char('S'); LCD_write_char('p'); LCD_write_char('e'); LCD_write_char('e'); LCD_write_char('d'); LCD_write_char('3'); LCD_write_char(':'); LCD_write_char(AspeedS0); LCD_write_char(AspeedS1); LCD_write_char(AspeedS2); LCD_write_char(AspeedS3); /************** 第六行显示内容 **************/ AspeedS0 = (u8) ((ASPeed5/1000) + 48 ); AspeedS1 = (u8) (((ASPeed5%1000)/100) +48 ) ; AspeedS2 = (u8) (((ASPeed5%100)/10) + 48 ); AspeedS3 = (u8) ((ASPeed5%10) + 48 ); LCD_set_XY(0, 5) ; LCD_write_char('S'); LCD_write_char('p'); LCD_write_char('e'); LCD_write_char('e'); LCD_write_char('d'); LCD_write_char('4'); LCD_write_char(':'); LCD_write_char(AspeedS0); LCD_write_char(AspeedS1); LCD_write_char(AspeedS2); LCD_write_char(AspeedS3); } } }
/*********************************************************** 函数名称:LCDTIME 函数功能:液晶显示和 入口参数:c : 显示的字符 出口参数:无 备 注: ***********************************************************/ void LCDTIME(void){ u8 AspeedS0, AspeedS1, AspeedS2, AspeedS3; LCD_set_XY(0, 0) ; LCD_write_char('L'); LCD_write_char('a'); LCD_write_char('n'); LCD_write_char('d'); LCD_write_char('z'); LCD_write_char('o'); /************** 第二行显示内容 ************* */ AspeedS0 = (u8) ((ASPeed1/1000) + 48 ); AspeedS1 = (u8) (((ASPeed1%1000)/100) +48 ) ; AspeedS2 = (u8) (((ASPeed1%100)/10) + 48 ); AspeedS3 = (u8) ((ASPeed1%10) + 48 ); LCD_set_XY(0, 1) ; LCD_write_char('S'); LCD_write_char('p'); LCD_write_char('e'); LCD_write_char('e'); LCD_write_char('d'); LCD_write_char('0'); LCD_write_char(':'); LCD_write_char(AspeedS0); LCD_write_char(AspeedS1); LCD_write_char(AspeedS2); LCD_write_char(AspeedS3); /************** 第三行显示内容 **************/ AspeedS0 = (u8) ((ASPeed2/1000) + 48 ); AspeedS1 = (u8) (((ASPeed2%1000)/100) +48 ) ; AspeedS2 = (u8) (((ASPeed2%100)/10) + 48 ); AspeedS3 = (u8) ((ASPeed2%10) + 48 ); LCD_set_XY(0, 2) ; LCD_write_char('S'); LCD_write_char('p'); LCD_write_char('e'); LCD_write_char('e'); LCD_write_char('d'); LCD_write_char('1'); LCD_write_char(':'); LCD_write_char(AspeedS0); LCD_write_char(AspeedS1); LCD_write_char(AspeedS2); LCD_write_char(AspeedS3); /************** 第四行显示内容 **************/ AspeedS0 = (u8) ((ASPeed3/1000) + 48 ); AspeedS1 = (u8) (((ASPeed3%1000)/100) +48 ) ; AspeedS2 = (u8) (((ASPeed3%100)/10) + 48 ); AspeedS3 = (u8) ((ASPeed3%10) + 48 ); LCD_set_XY(0, 3) ; LCD_write_char('S'); LCD_write_char('p'); LCD_write_char('e'); LCD_write_char('e'); LCD_write_char('d'); LCD_write_char('2'); LCD_write_char(':'); LCD_write_char(AspeedS0); LCD_write_char(AspeedS1); LCD_write_char(AspeedS2); LCD_write_char(AspeedS3); /************** 第五行显示内容 **************/ AspeedS0 = (u8) ((ASPeed4/1000) + 48 ); AspeedS1 = (u8) (((ASPeed4%1000)/100) +48 ) ; AspeedS2 = (u8) (((ASPeed4%100)/10) + 48 ); AspeedS3 = (u8) ((ASPeed4%10) + 48 ); LCD_set_XY(0, 4) ; LCD_write_char('S'); LCD_write_char('p'); LCD_write_char('e'); LCD_write_char('e'); LCD_write_char('d'); LCD_write_char('3'); LCD_write_char(':'); LCD_write_char(AspeedS0); LCD_write_char(AspeedS1); LCD_write_char(AspeedS2); LCD_write_char(AspeedS3); /************** 第六行显示内容 **************/ AspeedS0 = (u8) ((ASPeed5/1000) + 48 ); AspeedS1 = (u8) (((ASPeed5%1000)/100) +48 ) ; AspeedS2 = (u8) (((ASPeed5%100)/10) + 48 ); AspeedS3 = (u8) ((ASPeed5%10) + 48 ); LCD_set_XY(0, 5) ; LCD_write_char('S'); LCD_write_char('p'); LCD_write_char('e'); LCD_write_char('e'); LCD_write_char('d'); LCD_write_char('4'); LCD_write_char(':'); LCD_write_char(AspeedS0); LCD_write_char(AspeedS1); LCD_write_char(AspeedS2); LCD_write_char(AspeedS3); }