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

當前位置:首頁 > 單片機 > 單片機
[導讀]//以下是lcd5110.c#include"lcd5110.h"#include"english_6x8_pixel.h"//中文字庫自己添加,如果沒有請注釋起來#include"write_chinese_string_pixel.h"//lcdgpio初始化函數(shù)//GPIOC.0.9.10.11.12推挽輸出,GPIO口可自

//以下是lcd5110.c


#include"lcd5110.h"

#include"english_6x8_pixel.h"

//中文字庫自己添加,如果沒有請注釋起來#include"write_chinese_string_pixel.h"

//lcdgpio初始化函數(shù)

//GPIOC.0.9.10.11.12推挽輸出,GPIO口可自己設置

voidLCD_GPIO_init(void)

{

GPIO_InitTypeDefGPIO_InitStructure;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);

GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12;

GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;

GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;

GPIO_Init(GPIOC,&GPIO_InitStructure);

}

//初始化函數(shù)

voidLCD_init(void)

{

//產生一個讓lcd復位的低電平脈沖

LCD_RST=0;

delay_us(1);

LCD_RST=1;

//關閉lcd

LCD_CE=0;

delay_us(1);

//使能lcd

LCD_CE=1;

delay_us(1);

LCD_write_byte(0x21,0);

LCD_write_byte(0xc8,0);

LCD_write_byte(0x06,0);

LCD_write_byte(0x13,0);

LCD_write_byte(0x20,0);

LCD_clear();

LCD_write_byte(0x0c,0);

//關閉lcd

LCD_CE=0;

}

//清屏函數(shù)

voidLCD_clear(void)

{

unsignedinti;

LCD_write_byte(0x0c,0);

LCD_write_byte(0x80,0);

for(i=0;i<504;i++)

LCD_write_byte(0,1);

}

//設置lcd坐標函數(shù)

voidLCD_set_XY(unsignedcharX,unsignedcharY)

{

LCD_write_byte(0x40|Y,0);//column

LCD_write_byte(0x80|X,0);//row

}

//顯示英文字符

//輸入?yún)?shù)c為顯示的字符

voidLCD_write_char(unsignedcharc)

{

unsignedcharline;

c-=32;

for(line=0;line<6;line++)

LCD_write_byte(font6x8[c][line],1);

}

//數(shù)字顯示函數(shù)

voidLCD_write_number(unsignedcharX,unsignedcharY,u16num)

{

//如果數(shù)字大于32000則顯示輸入錯誤

if(num>32000)

LCD_write_english_string(X,Y,"ERROR!");

//如果輸入在32000內正常顯示

else

{

unsignedchara,b,c,d,e;//a,b,c,d,e分別代表數(shù)字的萬千百十個位

a=num/10000;

b=(num-a*10000)/1000;

c=(num-a*10000-b*1000)/100;

d=(num-a*10000-b*1000-c*100)/10;

e=num-a*10000-b*1000-c*100-d*10;

a+=48;

b+=48;

c+=48;

d+=48;

e+=48;

LCD_set_XY(X,Y);

LCD_write_char(a);

X++;

LCD_write_char(b);

X++;

LCD_write_char(c);

X++;

LCD_write_char(d);

X++;

LCD_write_char(e);

}

}

//英文字符串顯示函數(shù)

//輸入?yún)?shù)*s為英文字符串指針

//xy為顯示字符串的位置x0-83,y0-5

voidLCD_write_english_string(unsignedcharX,unsignedcharY,charchar*s)

{

LCD_set_XY(X,Y);

while(*s)

{

LCD_write_char(*s);

s++;

}

}

/*

//顯示漢字,此部分自行添加字庫,如果沒有請注釋起來

//輸入?yún)?shù)xy為漢字起始坐標

//ch_with為漢字點陣的寬度

//num為顯示漢字的個數(shù)

//line漢字點陣數(shù)組中的起始行數(shù)

//row為漢字顯示的行間距

voidLCD_write_chinese_string(unsignedcharX,unsignedcharY,

unsignedcharch_with,unsignedcharnum,

unsignedcharline,unsignedcharrow)

{

unsignedchari,n;

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