STM8L探索套件學習筆記-LCD液晶顯示(三)
我們先分析下官方給的范例關于LCD的驅動函數(shù)
void LCD_GLASS_Init(void)//使能LCD時鐘,并設置相應參數(shù)
void LCD_contrast()//通過按鍵調(diào)節(jié)對比度
void LCD_bar()//將bar值寫道LCD緩存中
static void LCD_Conv_Char_Seg(uint8_t* c,bool point,bool column, uint8_t* digit)//將ASCII碼轉換為LCD顯示,第一個參數(shù)是要顯示的字符比如‘c’,第二個參數(shù)是設置POINT是否顯示,第三個參數(shù)是設置COLUMN是否顯示,第四個參數(shù)不是很懂
void LCD_GLASS_WriteChar(uint8_t* ch, bool point, bool column, uint8_t position)//將字符寫入LCD緩存,和上面參數(shù)大體一致
void LCD_GLASS_DisplayString(uint8_t* ptr)//顯示字符串,最大只能顯示7個,范例:LCD_GLASS_DisplayString("Error");
void LCD_GLASS_DisplayStrDeci(uint16_t* ptr)//能夠顯示有小數(shù)點的字符串
void LCD_GLASS_Clear(void)//清除LCD緩沖區(qū)
void LCD_GLASS_ScrollSentence(uint8_t* ptr, uint16_t nScroll, uint16_t ScrollSpeed)//字符串句子移動模式顯示,使用前需要清除LCD緩沖區(qū),第一個參數(shù)是顯示的字符串,第二個參數(shù)是顯示幾次,第三個是速度,單位是毫秒,范例:LCD_GLASS_ScrollSentence("** STM8L-DISCOVERY **",1,SCROLL_SPEED);
還有一些常用字符聲明,比如A-Z,0-9,一些其他特殊字符比如:
/* code for ? character */
#define C_UMAP 0x6081
/* code for m character */
#define C_mMap 0xb210
/* code for n character */
#define C_nMap 0x2210
/* constant code for * character */
#define star 0xA0D7
/* constant code for - character */
#define C_minus 0xA000
#define DOT 0x8000 /* for add decimal point in string */也就是小數(shù)點.
#define DOUBLE_DOT 0x4000 /* for add decimal point in string */冒號
/* Macros used for set/reset bar LCD bar */四個BAR宏定義
#define BAR0_ONt_bar[0] |= 0x80
#define BAR0_OFF t_bar[0] &= ~0x80
#define BAR1_ONt_bar[1] |= 0x08
#define BAR1_OFF t_bar[1] &= ~0x08
#define BAR2_ONt_bar[0] |= 0x20
#define BAR2_OFF t_bar[0] &= ~0x20
#define BAR3_ON t_bar[1] |= 0x02
#define BAR3_OFF t_bar[1] &= ~0x02
我們編寫下面一個LCD測試函數(shù)
void main(void)
{
uint16_t tab1[3],tab2[5];
/*初始化*/
LCD_GLASS_Init();
//滾動顯示字符串
LCD_GLASS_ScrollSentence("**STM8L LCD TEST** EEFOCUS",1,100);
//顯示小數(shù)
delay_ms(0XFFF);
//LCD_GLASS_Clear();
BAR0_ON;
tab1[0]=1;
tab1[0] |= DOT;
tab1[1]=2;
tab1[2]=V;
LCD_GLASS_DisplayStrDeci(tab1);
//顯示:
delay_ms(0XFFFF);
//LCD_GLASS_Clear();
BAR1_ON;
tab2[0]=1;
tab2[1]=7;
tab2[1] |= DOUBLE_DOT;
tab2[2]=0;
tab2[3]=2;
tab2[4]= ;
LCD_GLASS_DisplayStrDeci(tab2);
while (1)
{
}
}
評論