?? lcd_12864.c
字號:
#include "..\delay_function.h"
#include "LCD_12864_Interface.h"
#include "LCD_12864.h"
//#include "bmp1_12864.h"
//#include "Charactor_Generation.h"
//往LCD12864寫一字節數據
void LCD12864_write_byte(unsigned char cmd, unsigned char Data)
{
unsigned char i;
unsigned int tmp;
tmp = ( ((int)Data<<8|Data<<4) & 0xF0F0);
LCD12864_Clk_cls;
LCD12864_Do;
LCD12864_CS_stb;
delay_1us();
for (i=0;i<8;i++) {
if (cmd & 0x80)
LCD_SID_stb;
else
LCD_SID_cls;
LCD12864_Clk;
cmd = cmd<<1;
}
for (i=0;i<16;i++) {
if (tmp & 0x8000)
LCD_SID_stb;
else
LCD_SID_cls;
LCD12864_Clk;
tmp = tmp<<1;
}
// LCD_SID_stb;
delay_1us();
LCD12864_CS_cls;
}
//設置坐標(X:0-7;Y:0-3)
void LCD_set_XY( unsigned char posx, unsigned char posy )
{
unsigned char temp,temp1;
temp1 = posy & 0x01;
temp = posx;
if ( !temp1 ) temp |= 0x80;
if ( temp1 ) temp |= 0x90;
temp1 = posy & 0x02;
if ( temp1 ) temp += 0x08;
LCD12864_write_byte( LCD_WR_CMD,LCD_DDRAM|temp );
}
//顯示字符串(posx:0-7;posy:0-3)
void LCD_puts(unsigned char posx, unsigned char posy, char *s)
{
LCD_set_XY( posx, posy );
while ( *s )
{
LCD12864_write_byte( LCD_WR_DAT,*s );
delay_nms(50);
s++;
}
}
/**************圖形操作函數*************/
#ifdef _BMP1_12864_H__
//調入圖片
void Lcd_GDrw(const char *ptr)
{
char i,j,tmp;
char XX,YY;
LCD12864_write_byte( LCD_WR_CMD,LCD_FUNCTION|b_DL|b_RE );
XX = LCD_DRAW;
YY = LCD_DRAW;
for (i=0;i<32;i++) {
LCD12864_write_byte( LCD_WR_CMD,YY );
LCD12864_write_byte( LCD_WR_CMD,XX );
for (j=0;j<16;j++) {
tmp = pgm_read_byte(ptr++);
LCD12864_write_byte( LCD_WR_DAT,tmp );
}
YY++;
}
XX = LCD_DRAW|0x08;
YY = LCD_DRAW;
for (i=0;i<32;i++) {
LCD12864_write_byte( LCD_WR_CMD,YY );
LCD12864_write_byte( LCD_WR_CMD,XX );
for (j=0;j<16;j++) {
tmp = pgm_read_byte(ptr++);
LCD12864_write_byte( LCD_WR_DAT,tmp );
}
YY++;
}
LCD12864_write_byte( LCD_WR_CMD,LCD_EFUNCTION|b_DL );
}
//選擇圖片
void LCD_Pic_Sel(unsigned char index)
{
switch (index) {
case 0:
Lcd_GDrw(Graphy1);
break;
case 1:
break;
case 2:
break;
case 3:
break;
default:
break;
}
}
//圖片顯示開關
void LCD_Pic_Show(enum DisplayOnOff onoff)
{
if (Off == onoff) {
LCD12864_write_byte( LCD_WR_CMD,LCD_EFUNCTION|b_DL|b_RE);
}
else {
LCD12864_write_byte( LCD_WR_CMD,LCD_EFUNCTION|b_DL|b_RE|b_G );
}
LCD12864_write_byte( LCD_WR_CMD,LCD_EFUNCTION|b_DL );
}
#endif
/************自定義字型操作***********/
#ifdef __CHARACTOR_GENERATION_H_
//編碼自定義字型(最多4個16*16自定義字型)
void LCD_Char_Gen(const char *ptr, unsigned char num)
{
unsigned char i,j,tmp;
LCD12864_write_byte( LCD_WR_CMD,LCD_CGRAM );
for (i=0;i<num;i++) {
for (j=0;j<32;j++) {
tmp = pgm_read_byte(ptr++);
LCD12864_write_byte( LCD_WR_DAT,tmp );
}
}
}
//顯示自定義字型(posx:0-7;posy:0-3;index:0-3)
void LCD_Char_Show(unsigned char posx, unsigned char posy, enum Char_sel index)
{
LCD_set_XY( posx, posy );
LCD12864_write_byte( LCD_WR_DAT,0x00 );
LCD12864_write_byte( LCD_WR_DAT,index );
}
#endif
//LCD清屏
void LCD_clear(void)
{
LCD12864_write_byte( LCD_WR_CMD,LCD_CLS );
}
//初始化LCD
void Init_LCD12864( void )
{
Init_LCD_Port();
delay_nms(45);
LCD12864_write_byte( LCD_WR_CMD,LCD_FUNCTION|b_DL );
delay_1ms();
LCD12864_write_byte( LCD_WR_CMD,LCD_FUNCTION|b_DL );
delay_1ms();
LCD12864_write_byte( LCD_WR_CMD,LCD_VISIBLE );
delay_1ms();
LCD12864_write_byte( LCD_WR_CMD,LCD_CLS );
delay_nms(10);
LCD12864_write_byte( LCD_WR_CMD,LCD_POINT|b_I_D );
delay_1ms();
LCD12864_write_byte( LCD_WR_CMD,LCD_VISIBLE|b_D );
delay_1ms();
#ifdef __CHARACTOR_GENERATION_H_
LCD_Char_Gen(CharGen,4);
#endif
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -