?? avr_xqv12.h
字號:
DDRC=0x00;
PORTD=0xff;
DDRD=0x00;
Un_Led();
Clear_SMG();
}
#if LCD12864==TRUE //條件編譯指令
#pragma data:code //指定存儲位置為Flash
const unsigned char Bitmap[]={/*-- 寬度x高度=128x64圖像 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x01,0xFF,0x00,0x00,0x00,
0x00,0x00,0x0C,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0xFF,0x83,0xFF,0x80,0x00,0x00,
0x00,0x00,0x1E,0x0C,0x0F,0x00,0x00,0x00,0x00,0x01,0xFF,0xC3,0xFF,0x80,0x00,0x00,
0x00,0x00,0x1E,0x1E,0x0F,0x03,0x00,0x0C,0x00,0x01,0xFF,0xC3,0xFF,0x00,0x00,0x00,
0x00,0x00,0x1E,0x1E,0x0F,0x07,0x83,0x3F,0x00,0x01,0xC3,0xC3,0xC0,0x00,0x00,0x00,
0x00,0x00,0x1E,0x1E,0x0F,0x07,0x87,0xFF,0x80,0x03,0xC3,0xC3,0xC0,0x00,0x00,0x00,
0x00,0x00,0x1E,0x1E,0x0F,0x03,0x07,0xFF,0x80,0x03,0xC1,0x83,0xC0,0x00,0x00,0x00,
0x00,0x00,0x1E,0x1E,0x0F,0x00,0x07,0xF3,0xC0,0x03,0xC0,0x03,0xC0,0x00,0x00,0x00,
0x00,0x00,0x1E,0x1E,0x0F,0x03,0x07,0xE3,0xC0,0x03,0xC0,0x03,0xC0,0x00,0x00,0x00,
0x00,0x00,0x1E,0x1E,0x0F,0x07,0x87,0x83,0xC0,0x03,0xC0,0x03,0xFE,0x00,0x00,0x00,
0x00,0x00,0x1E,0x1E,0x0F,0x07,0x87,0x83,0xC0,0x03,0xC0,0x03,0xFF,0x00,0x00,0x00,
0x00,0x00,0x1E,0x1E,0x0F,0x07,0x87,0x83,0xC0,0x03,0xC0,0x03,0xFF,0x00,0x00,0x00,
0x00,0x00,0x1E,0x1E,0x0F,0x07,0x87,0x83,0xC0,0x03,0xC0,0x03,0xFE,0x00,0x00,0x00,
0x00,0x00,0x1E,0x1F,0x0F,0x07,0x87,0x83,0xC0,0x03,0xC0,0x03,0xC0,0x00,0x00,0x00,
0x00,0x00,0x0F,0x3F,0x9F,0x07,0x87,0x83,0xC0,0x03,0xC0,0x03,0xC0,0x00,0x00,0x00,
0x00,0x00,0x07,0xFF,0xFE,0x07,0x87,0x83,0xC0,0x03,0xC1,0x83,0xC0,0x00,0x00,0x00,
0x00,0x00,0x07,0xFB,0xFC,0x07,0x87,0x83,0xC0,0x03,0xC3,0xC3,0xC0,0x00,0x00,0x00,
0x00,0x00,0x03,0xF1,0xF8,0x0F,0xC7,0x83,0xC0,0x03,0xFF,0xC3,0xFF,0x00,0x00,0x00,
0x00,0x00,0x01,0xE0,0xF0,0x0F,0xC7,0x83,0xC0,0x03,0xFF,0xC3,0xFF,0x80,0x00,0x00,
0x00,0x00,0x00,0xC0,0x60,0x07,0x83,0x01,0x80,0x01,0xFF,0x83,0xFF,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x01,0xFF,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
#pragma data:data
/*******************************************************/
/****** 函數(shù)名稱: SendData() ******/
/****** 功 能: 向LCD發(fā)送數(shù)據(jù),串行方式 ******/
/****** 參 數(shù): data--待發(fā)送的數(shù)據(jù) ******/
/****** 返回值 : 無 ******/
/*******************************************************/
void SendData(unsigned char data)
{
unsigned char i;
for(i=0;i<8;i++) //循環(huán)8次
{
ClrSclk; //置低CLK
if(data&0x80) //判斷數(shù)據(jù)極性
SetSid; //如果數(shù)據(jù)為1置高
else
ClrSid; //否則置低
data<<=1; //右移一位
SetSclk; //置高CLK
}
}
/*******************************************************/
/****** 函數(shù)名稱: Wr_Com() ******/
/****** 功 能: 向LCD發(fā)送命令 ******/
/****** 參 數(shù): data--待發(fā)送的命令字 ******/
/****** 返回值 : 無 ******/
/*******************************************************/
void Wr_Com(unsigned char data)
{
SetRs; //片選LCD12864
SendData(0xf8); //命令字:寫命令
SendData(data&0xf0); //寫命令字高4位
SendData(data<<4); //寫命令字低4位
ClrRs; //釋放片選
}
/*******************************************************/
/****** 函數(shù)名稱: Wr_Date() ******/
/****** 功 能: 向LCD發(fā)送數(shù)據(jù) ******/
/****** 參 數(shù): data--待發(fā)送的數(shù)據(jù) ******/
/****** 返回值 : 無 ******/
/*******************************************************/
void Wr_Date(unsigned char data)
{
SetRs; //片選LCD12864
SendData(0xfa); //命令字:寫數(shù)據(jù)
SendData(data&0xf0); //寫數(shù)據(jù)高4位
SendData(data<<4); //寫數(shù)據(jù)低4位
ClrRs; //釋放片選
}
/*******************************************************/
/****** 函數(shù)名稱: Clear_All() ******/
/****** 功 能: 清LCD屏幕 ******/
/****** 參 數(shù): 無 ******/
/****** 返回值 : 無 ******/
/*******************************************************/
void Clear_All(void)
Wr_Com(0x01); //命令字
delay_nms(40);
}
/*******************************************************/
/****** 功 能: 初始化LCD ******/
/****** 參 數(shù): 無 ******/
/****** 返回值 : 無 ******/
/*******************************************************/
void Lcd_Init(void)
{
DDRC=0xc0; //設(shè)置控制管腳方向
DDRD=0x40;
Wr_Com(0x30); //功能設(shè)定:基本指令集
delay_nus(80);
Wr_Com(0x0c); //顯示狀態(tài)打開
delay_nus(80);
Wr_Com(0x01); //清屏
delay_nms(40);
Wr_Com(0x60); //設(shè)定CGRAM地址
delay_nus(80);
}
/*******************************************************/
/****** 函數(shù)名稱: LCD_set_xy() ******/
/****** 功 能: 設(shè)置LCD顯示坐標(biāo) ******/
/****** 參 數(shù): 顯示字符串的位置,X:0-15,Y:0-1*****/
/****** 返回值 : 無 ******/
/*******************************************************/
void LCD_set_xy( unsigned char x, unsigned char y )
{
unsigned char address;
switch(y)
{
case 0:
address = 0x80 + x; //計(jì)算顯示地址
break;
case 1:
address = 0x90 + x; //計(jì)算顯示地址
break;
case 2:
address = 0x88 + x; //計(jì)算顯示地址
break;
case 3:
address = 0x98 + x; //計(jì)算顯示地址
break;
default:address = 0x80 + x;
}
Wr_Com( address); //寫地址命令
}
/*******************************************************/
/****** 函數(shù)名稱: LCD_write_string() ******/
/****** 功 能: 中英文字符串顯示函數(shù) ******/
/****** 參 數(shù): *s--英文字符串指針 ******/
/****** X、Y--顯示字符串的位置 ******/
/****** 返回值 : 無 ******/
/*******************************************************/
void LCD_write_string(unsigned char X,unsigned char Y,unsigned char *s)
{
LCD_set_xy( X, Y ); //寫顯示地址
while (*s) //是否到字符串尾
{
Wr_Date (*s ); //寫顯示數(shù)據(jù)
s ++; //字符串地址加1
}
}
/*******************************************************/
/****** 函數(shù)名稱: ShowBmp() ******/
/****** 功 能: 顯示一幅128*64的BMP位圖 ******/
/****** 參 數(shù): 無 ******/
/****** 返回值 : 無 ******/
/*******************************************************/
void ShowBmp(void)
{
unsigned int i,a,x=0,y=0;
Wr_Com(0x34);
for(a=0;a<32;a++)
{
Wr_Com(0x80+a);
Wr_Com(0x80);
for(i=0;i<8;i++)
{
Wr_Date(Bitmap[y+x]);
Wr_Date(Bitmap[y+x+1]);
x+=2;
}
x=0;
for(i=0;i<8;i++)
{
Wr_Date(Bitmap[512+y+x]);
Wr_Date(Bitmap[512+y+x+1]);
x+=2;
}
x=0;
y+=16;
}
Wr_Com(0x36);
delay_nus(80);
Wr_Com(0x30);
delay_nus(80);
}
#endif //條件編譯結(jié)束
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -