資源簡(jiǎn)介
這個(gè)程序是用于stm32F407 驅(qū)動(dòng) 12864 LCD使用的,lcd是帶有中文字庫(kù)版本的lcd。 關(guān)于這份代碼 請(qǐng)參考我的csdn博客 https://jeason.blog.csdn.net/article/details/99691445 有問(wèn)題您可以在博客下留言,我會(huì)盡快回復(fù)您的

代碼片段和文件信息
#include?“LCD12864.h“
#include?“delay.h“
#define??LCD_12864_RS??PCout(0)
#define??LCD_12864_RW??PCout(1)
#define??LCD_12864_EN??PCout(2)
void?LCD_12864_show_string(u8?x?u8?yu8?*str)
{
LCD_12864_pos(xy);
while(*str?!=?0)
{
LCD_12864_write_data(*str);
str?++;
}
}
void?LCD_12864_show_int(u8?xu8?yint?numu8?len)
{
u32?temp=1;
u8?i=0;
LCD_12864_pos(xy);
if(num?<0)?
{
LCD_12864_write_data(‘-‘);?//顯示符號(hào)
num?*=-1;
}
for(i=0;i temp?*=10;
for(i=0;i {
if(num?==?0)
break;
LCD_12864_write_data((num/temp)+‘0‘);
num%=temp;
temp/=10;
}
}
void?LCD_12864_show_float(u8?x?u8?y?float?num?u8?len1?u8?len2)
{
int?num_int=0;
float?num_decimal;
u32?temp=1;
u8?icnt?=0enshow?=?0;
u8?show_str[20];
show_str[len1?+len2+1]?=0;?//?結(jié)束符
num_int?=?(int)num;
if(num?0)?show_str[cnt++]?=?‘-‘;//?顯示正負(fù)號(hào)
num?*=-1;
for(i=0;i for(i=0;i {
if(enshow?==?0?&&?(num_int/temp?!=?0)?)?//?從第一個(gè)不等于0的數(shù)字開(kāi)始
enshow=1;
if(enshow)
{
show_str[cnt++]?=?num_int/temp?+‘0‘;
}else?
{
show_str[cnt++]?=?‘?‘;?//?填充空格
}
num_int?%=?temp;
temp?/=10;
}
num_decimal?=?num-num_int;??//?取出小數(shù)部分
if(show_str[cnt-1]?==?‘?‘)show_str[cnt-1]?=‘0‘;
show_str[cnt++]?=?‘.‘;?//?填充小數(shù)點(diǎn)
temp?=?1;
for(i=0;i num_decimal?*=?temp;
num_int?=?(int)num_decimal;
for(i=0;i {
show_str[cnt++]?=?num_int/temp?+‘0‘;
num_int?%=?temp;
temp?/=10;
}
LCD_12864_show_string(xyshow_str);
}
void?LCD_12864_show_HEX(u8?x?u8?y?u32?num?u8?len);
void?LCD_12864_show_bin(u8?x?u8?y?u32?num?u8?len);
/*LCD_12864_pos
設(shè)置?顯示的位置?
*/
void?LCD_12864_pos(u8?X?u8?Y)
{
u8?pos;?
if?(Y==0)
?????{Y=0x80;}
???else?if?(Y==1)
?????{Y=0x90;}
???else?if?(Y==2)
?????{Y=0x88;}
???else?if?(Y==3)
?????{Y=0x98;}
???pos?=?X+Y?;??
???LCD_12864_write_command(pos);//?顯示地址
}
/*LCD_12864_write_command
向12864?寫(xiě)指令
*/
void?LCD_12864_write_command(u8?cmd)
{
LCD_12864_check_busy();
LCD_12864_RS?=?0;
LCD_12864_RW?=?0;
delay_us(500);
LCD_DB_OUT(cmd);
LCD_12864_EN?=?1;
delay_us(500);
LCD_12864_EN?=?0;
}
/*LCD_12864_write_data
?向?12864?寫(xiě)數(shù)據(jù)
*/
void?LCD_12864_write_data(u8?data)
{
LCD_12864_check_busy();
LCD_12864_RS?=?1;
LCD_12864_RW?=?0;
delay_us(500);
LCD_DB_OUT(data);
LCD_12864_EN?=?1;
delay_us(500);
LCD_12864_EN?=?0;
}
/*LCD_12864_clean_screen
清屏
*/
void?LCD_12864_clean_screen(void)
{
LCD_12864_write_command(0x01);
delay_us(500);
}
/*LCD_12864_clean_gdram
?清除?GDRAM緩存
*/
void?LCD_12864_clean_gdram(void)
{
?unsigned?char?xy?;
????for(y=0;y<64;y++)
????for(x=0;x<16;x++)
????{
????????LCD_12864_write_command(0x34);
????????LCD_12864_write_command(y+0x80);
//?行地址
????????LCD_12864_write_command(x+0x80);
????????//?列地址
????????LCD_12864_write_command(0x30);
????????LCD_12864_write_data
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-08-17?17:51??LCD12864\
?????文件????????5150??2019-08-17?15:04??LCD12864\LCD12864.c
?????文件????????3016??2019-08-17?13:11??LCD12864\LCD12864.c.baiduyun.uploading.cfg
?????文件?????????690??2019-08-17?12:38??LCD12864\LCD12864.h
評(píng)論
共有 條評(píng)論