日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > 單片機(jī) > 單片機(jī)
[導(dǎo)讀]#include#include "lcd12864.h"#include "typedef.h"#define cyCSBIT0//P2.0,片選信號(hào)#define cySIDBIT1//P2.1,串行數(shù)據(jù)#define cyCLKBIT2//P2.2,同步時(shí)鐘#define cyPORTP2OUT#define cyDDRP2DIRvoid Write_8bits

#include
#include "lcd12864.h"
#include "typedef.h"

#define cyCSBIT0//P2.0,片選信號(hào)
#define cySIDBIT1//P2.1,串行數(shù)據(jù)
#define cyCLKBIT2//P2.2,同步時(shí)鐘
#define cyPORTP2OUT
#define cyDDRP2DIR


void Write_8bits(u8 W_bits)
{
u8 i;
cyDDR |= cyCLK + cySID;//設(shè)置輸出方向
for(i = 0; i < 8; i++)
{
if(( W_bits << i )&0x80)
{
cyPORT |= cySID;

}
else
{
cyPORT &= ~cySID;
}
delay_ms(1);
cyPORT |= cyCLK;
delay_ms(1);
delay_ms(1);
cyPORT &= ~cyCLK;
}
}


void w_1byte(u8 RS, u8 w_data)
{
u8 H_Data,L_Data;
u8 tmp_Data = 0xf8;

cyDDR |= cyCS;//設(shè)置CS口為輸出
if(RS == 0) tmp_Data &= ~0x02;
elsetmp_Data |= 0x02;

H_Data = w_data;//高位數(shù)據(jù)
H_Data &= 0xf0;
L_Data = w_data;//低位數(shù)據(jù)
L_Data &= 0x0f;
L_Data <<= 4;

cyPORT |= cyCS;
Write_8bits(tmp_Data);
Write_8bits(H_Data);
Write_8bits(L_Data);
cyPORT &= ~cyCS;
}


void init_Lcd(void)
{
cyDDR |= cyCLK + cySID + cyCS;//相應(yīng)的位端口設(shè)置為輸出
delay_ms(10);//延時(shí)等待液晶完成復(fù)位
w_1byte(0,0x30);
delay_ms(1);
w_1byte(0,0x02);
delay_ms(5);
w_1byte(0,0x0c);
delay_ms(1);
w_1byte(0,0x01);
delay_ms(5);
w_1byte(0,0x06);
delay_ms(1);
}

//清屏
void clear_lcd(void)
{
delay_ms(1);
w_1byte(0,0x01);
delay_ms(5);
}

void lcd_pos(u8 x,u8 y)//定位
{
u8 pos;
switch(x)
{
case 1:pos=0x80;break;
case 2:pos=0x90;break;
case 3:pos=0x88;break;
case 4:pos=0x98;break;
default:pos=0x80;
}
pos += y;
w_1byte(0,pos);
}

//顯示漢字
void Disp_HZ(const u8 * pt,u8 num)
{
u8 i;
for(i = 0;i < num*2;i++)
{
w_1byte(1,*(pt++));
}
}

//顯示字符
void Disp_Ch(const u8 ch)
{
w_1byte(1, ch);
}

//漢字和字符混合顯示
void disp_lcd_str(u8 x, u8 y, const u8 *str, u8 len)
{
u8 i;
lcd_pos(x, y);
for(i = 0;i < len && *str; )
{
if(*(str) >= 0x80)
{
w_1byte(1,*(str++));
w_1byte(1,*(str++));
i++;
i++;
}
else
{
w_1byte(1,*(str++));
i++;
}
}
}


本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時(shí)聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉