91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2.53KB
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2024-06-14
  • 語言: C/C++
  • 標(biāo)簽: LCD9648??顯示??文字??

資源簡介

LCD9648顯示文字

資源截圖

代碼片段和文件信息

#include
#include“charcode.h“

sbit?CS0??=?P0^0; //片選
sbit?RST??=?P0^1; //復(fù)位
sbit?RS???=?P2^7;? //數(shù)據(jù)命令選擇端
sbit?SCL??=?P2^6; //SPI時(shí)鐘端
sbit?SDA??=?P2^5; //SPI數(shù)據(jù)端

void?Delay10ms(unsigned?int?c)???//誤差?0us
{
????unsigned?char?ab;
????for(;c>0;c--)
????????for(b=38;b>0;b--)
????????????for(a=130;a>0;a--);
}


void??SendDataSPI(unsigned?char?dat)
{??
???unsigned?char?i;
???
???for(i=0;?i<8;?i++)
???{??
??????if(?(dat&0x80)!=0?)?SDA?=?1;
????????else?SDA?=?0;

??????dat?<<=?1;

??SCL?=?0;
??????SCL?=?1;
???}
}

void?WriteComm(unsigned?int?i)
{

????CS0?=?0;
RS??=?0;

SendDataSPI(i);

CS0?=?1;

}
void?WriteData(unsigned?int?i)
{
????CS0?=?0;
RS??=?1;

SendDataSPI(i);

CS0?=?1;
}

void?LCD_Init(void)
{
unsigned?int?i;
//CS0=0;

RST=1;??
for(i?=?0;?i?
RST=0;
for(i?=?0;?i?
RST=1;
for(i?=?0;?i?
????WriteComm(0xe2); ??//軟件復(fù)位
WriteComm(0xc8); ??//0xC8普通方向選擇選擇反向,0xC0為正常方向
WriteComm(0xa0); ??//0xA0段方向選擇正常方向(0xA1為反方向
WriteComm(0x2f);
WriteComm(0x26);
WriteComm(0x81); ??//背景光對(duì)比度
WriteComm(0x10);
WriteComm(0xaf); ??//開啟顯示

}


void?Clear()
{
unsigned?char?ij;

for(i=0;?i? {
WriteComm(0x40);
WriteComm(0xb0+i);
WriteComm(0x10);
WriteComm(0x00);

for(j?=?0;?j? {
WriteData(0x00);
}
}
}


unsigned?char?LCD12864_Write16CnCHAR(unsigned?char??x?unsigned?char?y?unsigned?char?*cn)
{
unsigned?char?j?x1?x2?wordNum;

//--Y的坐標(biāo)只能從0到7,大于則直接返回--//
if(y?>?7)
{
return?0;
}

//--X的坐標(biāo)只能從0到96,大于則直接返回--//
if(x?>?96)
{
return?0;
}
y?+=?0xB0; ???//求取Y坐標(biāo)的值
//--設(shè)置Y坐標(biāo)--//
WriteComm(y);
while?(?*cn?!=?‘\0‘) ?//在C語言中字符串結(jié)束以‘\0’結(jié)尾
{

//--設(shè)置Y坐標(biāo)--//
WriteComm(y);

x1?=?(x?>>?4)?&?0x0F;???//由于X坐標(biāo)要兩句命令,分高低4位,所以這里先取出高4位
x2?=?x?&?0x0F;??????????//去低四位
//--設(shè)置X坐標(biāo)--//
WriteComm(0x10?+?x1);???//高4位
WriteComm(0x00?+?x2); //低4位
for?(wordNum=0;?wordNum<30;?wordNum++)
{
????//--查詢要寫的字在字庫中的位置--//
if?((CN16CHAR[wordNum].Index[0]?==?*cn)
?????&&(CN16CHAR[wordNum].Index[1]?==?*(cn+1)))
{
for?(j=0;?j<32;?j++)?//寫一個(gè)字
{
if?(j?==?16) ?//由于16X16用到兩個(gè)Y坐標(biāo),當(dāng)大于等于16時(shí),切換坐標(biāo)
{
//--設(shè)置Y坐標(biāo)--//
??? WriteComm(y?+?1);

//--設(shè)置X坐標(biāo)--//
WriteComm(0x10?+?x1);???//高4位
WriteComm(0x00?+?x2); //低4位
}
WriteData(CN16CHAR[wordNum].Msk[j]);
}
x?+=?16;
}//if查到字結(jié)束
}?//for查字結(jié)束
cn?+=?2;

} //while結(jié)束
return?1;
}


void?main()
{
unsigned?char?i;
LCD_Init();
Clear();
LCD12864_Write16CnCHAR(150“普中科技“);
while(1)
{
for(i?=?0;?i? {
LCD12864_Write16CnCHAR(15i“有限公司“);
//LCD12864_Write16CnCHAR(15i“別有用心“);??//只有“有”字能顯示,別的因?yàn)闆]有點(diǎn)陣所以無顯示
Delay10ms(100);
Clear();
}
}
}

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件???????3137??2021-03-24?21:33??LCD9648顯示文字.c

?????文件???????4539??2014-10-29?10:20??charcode.h

-----------?---------??----------?-----??----

?????????????????7676????????????????????2


評(píng)論

共有 條評(píng)論