




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、#include lcd.h#include fonts.hstatic vu16 TextColor = 0 x0000, BackColor = 0 xFFFF;* Function Name* Description* Input* Output* Return: Delay_LCD: Inserts a delay time.: nCount: specifies the delay time length. : None: None*/void Delay_LCD(u16 n) u16 i,j; for (i = 0;in;+i) for(j=0;j3000;+j);/* Funct
2、ion Name* Description* Input* Output* Return: STM3210B_LCD_Init : Initializes the LCD.: None: None: None*/void STM3210B_LCD_Init(void) vu16 dummy = 0;/总线配置 LCD_CtrlLinesConfig();LCD_WriteReg(0 x0000,0 x0001);Delay_LCD(1000);LCD_WriteReg(0 x0001,0 x0000);LCD_WriteReg(0 x0010,0 x1790);LCD_WriteReg(0 x
3、0060,0 x2700);LCD_WriteReg(0 x0061,0 x0001);LCD_WriteReg(0 x0046,0 x0002);LCD_WriteReg(0 x0013,0 x8010);LCD_WriteReg(0 x0012,0 x80fe);LCD_WriteReg(0 x0002,0 x0500);LCD_WriteReg(0 x0003,0 x1030);LCD_WriteReg(0 x0030,0 x0303);LCD_WriteReg(0 x0031,0 x0303);LCD_WriteReg(0 x0032,0 x0303);LCD_WriteReg(0 x
4、0033,0 x0300);LCD_WriteReg(0 x0034,0 x0003);LCD_WriteReg(0 x0035,0 x0303);LCD_WriteReg(0 x0036,0 x0014);LCD_WriteReg(0 x0037,0 x0303);LCD_WriteReg(0 x0038,0 x0303);LCD_WriteReg(0 x0039,0 x0303);LCD_WriteReg(0 x003a,0 x0300);LCD_WriteReg(0 x003b,0 x0003);LCD_WriteReg(0 x003c,0 x0303);LCD_WriteReg(0 x
5、003d,0 x1400);LCD_WriteReg(0 x0092,0 x0200);LCD_WriteReg(0 x0093,0 x0303);LCD_WriteReg(0 x0090,0 x080d);LCD_WriteReg(0 x0003,0 x1018);LCD_WriteReg(0 x0007,0 x0173);dummy = LCD_ReadReg(0);/* Function Name : LCD_SetTextColor* Description : Sets the Text color.* Input: - Color: specifies the Text color
6、 code RGB(5-6-5).* Output: - TextColor: Text color global variable used by LCD_DrawChar* and LCD_DrawPicture functions.* Return : None*/void LCD_SetTextColor(vu16 Color)TextColor = Color;/* Function Name : LCD_SetBackColor* Description : Sets the Background color.* Description* Input* Output* Return
7、* Input* Output*: - Color: specifies the Background color code RGB(5-6-5). : - BackColor: Background color global variable used by LCD_DrawChar and LCD_DrawPicture functions.* Return : None*void LCD_SetBackColor(vu16 Color)BackColor = Color;/* Function Name : LCD_ClearLine* Description : Clears the
8、selected line.* Input : - Line: the Line to be cleared.*This parameter can be one of the following values:*- Linex: where x can be 0.9* Output: None* Return: None*/void LCD_ClearLine(u8 Line)LCD_DisplayStringLine(Line, );/* Function Name: LCD_SetCursorDescriptionInput: Sets the cursor position.: - X
9、pos: specifies the X position.* Output* Return- Ypos: specifies the Y position. : None: None*/void LCD_SetCursor(u8 Xpos, u16 Ypos)LCD_WriteReg(R32, Xpos);LCD_WriteReg(R33, Ypos);* Function Name* Description* Input: LCD_DrawChar: Draws a character on LCD.: - Xpos: the Line where to display the chara
10、cter shape.This parameter can be one of the following values:- Linex: where x can be 0.9- Ypos: start column address.- c: pointer to the character data.* Output* Return: None: None*/void LCD_DrawChar(u8 Xpos, u16 Ypos, uc16 *c)u32 index = 0, i = 0; u8 Xaddress = 0;Xaddress = Xpos;LCD_SetCursor(Xaddr
11、ess, Ypos);for(index = 0; index 24; index+)LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ for(i = 0; i 16; i+) if(cindex & (1 i) = 0 x00) LCD_WriteRAM(BackColor); elseLCD_WriteRAM(TextColor);Xaddress+;LCD_SetCursor(Xaddress, Ypos);/* Function Name : LCD_DisplayChar* Description : Displays one c
12、haracter (16dots width, 24dots height).* Input: - Line: the Line where to display the character shape .*This parameter can be one of the following values:*- Linex: where x can be 0.9*- Column: start column address.*- Ascii: character ascii code, must be between 0 x20 and 0 x7E.* Output: None* Return
13、: None*/void LCD_DisplayChar(u8 Line, u16 Column, u8 Ascii)Ascii -= 32;LCD_DrawChar(Line, Column, &ASCII_TableAscii * 24);/* Function Name : LCD_DisplayStringLine* Description: Displays a maximum of 20 char on the LCD.* Input: - Line: the Line where to display the character shape .*This parameter ca
14、n be one of the following values:*- Linex: where x can be 0.9*- *ptr: pointer to string to display on LCD.* Output: None* Return: None*/void LCD_DisplayStringLine(u8 Line, u8 *ptr)u32 i = 0;u16 refcolumn = 319;/319;while (*ptr != 0) & (i = Height)LCD_WriteReg(R80, (Xpos - Height + 1);elseLCD_WriteRe
15、g(R80, 0);LCD_WriteReg(R81, Xpos);if(Ypos = Width)LCD_WriteReg(R82, (Ypos - Width + 1);elseLCD_WriteReg(R82, 0);/* Vertical GRAM End Address */ LCD_WriteReg(R83, Ypos); LCD_SetCursor(Xpos, Ypos);* Function Name* Description* Input*: LCD_SetDisplayWindow: Sets a display window: - Xpos: specifies the
16、X buttom left position.- Ypos: specifies the Y buttom left position.*- Height: display window height.*Input* Output: None: NoneDescription: NoneFunction Name : LCD_WindowModeDisable: Disables LCD Window mode.* Return*/void LCD_WindowModeDisable(void)LCD_SetDisplayWindow(239, 0 x13F, 240, 320);LCD_Wr
17、iteReg(R3, 0 x1018);/* Function Name : LCD_DrawLine* Description: Displays a line.* Input: - Xpos: specifies the X position.*- Ypos: specifies the Y position.*- Length: line length.*- Direction: line direction.*This parameter can be one of the following values: Vertical* or Horizontal.* Output : Non
18、e * Return : None*/void LCD_DrawLine(u8 Xpos, u16 Ypos, u16 Length, u8 Direction) u32 i = 0;LCD_SetCursor(Xpos, Ypos); if(Direction = Horizontal) LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ for(i = 0; i Length; i+) LCD_WriteRAM(TextColor); else for(i = 0; i Length; i+) LCD_WriteRAM_Prepare()
19、; /* Prepare to write GRAM */ LCD_WriteRAM(TextColor);Xpos+;LCD_SetCursor(Xpos, Ypos);/* Function Name* Description* Input*: LCD_DrawRect: Displays a rectangle.: - Xpos: specifies the X position.- Ypos: specifies the Y position.*- Height: display rectangle height.*- Width: display rectangle width.*
20、Output* Return: None: None*void LCD_DrawRect(u8 Xpos, u16 Ypos, u8 Height, u16 Width) LCD_DrawLine(Xpos, Ypos, Width, Horizontal); LCD_DrawLine(Xpos + Height), Ypos, Width, Horizontal);LCD_DrawLine(Xpos, Ypos, Height, V ertical);LCD_DrawLine(Xpos, (Ypos - Width + 1), Height, Vertical);/* Function Na
21、me* Description* Input*: LCD_DrawCircle: Displays a circle.: - Xpos: specifies the X position.- Ypos: specifies the Y position.*- Height: display rectangle height.*- Width: display rectangle width.* Output* Return: None: None*/void LCD_DrawCircle(u8 Xpos, u16 Ypos, u16 Radius)s32 D; u32 CurX;u32 Cur
22、Y;D = 3 - (Radius 1);CurX = 0;CurY = Radius;while (CurX = CurY)LCD_SetCursor(Xpos + CurX, Ypos + CurY);LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ LCD_WriteRAM(TextColor);LCD_SetCursor(Xpos + CurX, Ypos - CurY);LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ LCD_WriteRAM(TextColor);LCD_S
23、etCursor(Xpos - CurX, Ypos + CurY);LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ LCD_WriteRAM(TextColor);LCD_SetCursor(Xpos - CurX, Ypos - CurY);LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ LCD_WriteRAM(TextColor);LCD_SetCursor(Xpos + CurY , Ypos + CurX);LCD_WriteRAM_Prepare(); /* Prepa
24、re to write GRAM */ LCD_WriteRAM(TextColor);LCD_SetCursor(Xpos + CurY , Ypos - CurX);LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ LCD_WriteRAM(TextColor);LCD_SetCursor(Xpos - CurY , Ypos + CurX);LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ LCD_WriteRAM(TextColor);LCD_SetCursor(Xpos - C
25、urY , Ypos - CurX);LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ LCD_WriteRAM(TextColor);if (D 0)D += (CurX 2) + 6;elseD += (CurX - CurY) 2) + 10;CurY-;CurX+;/* Function Name : LCD_DrawMonoPict* Description: Displays a monocolor picture.* Input* Output* Return: - Pict: pointer to the picture a
26、rray. : None: None*/void LCD_DrawMonoPict(uc32 *Pict)u32 index = 0, i = 0;LCD_SetCursor(0, 319);LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */ for(index = 0; index 2400; index+)for(i = 0; i 32; i+)if(Pictindex & (1 i) = 0 x00)LCD_WriteRAM(BackColor);elseLCD_WriteRAM(TextColor); /* Function Name
27、 : LCD_WriteBMP* Description : Displays a bitmap picture loaded in the internal Flash.* Input : - BmpAddress: Bmp picture address in the internal Flash.Function NameDescriptionInput* Output* Return* Output: None* Return: None*/ void LCD_WriteBMP(u32 BmpAddress)u32 index = 0, size = 0;size = *(vu16 *
28、) (BmpAddress + 2);size |= (*(vu16 *) (BmpAddress + 4) 16;index = *(vu16 *) (BmpAddress + 10);index |= (*(vu16 *) (BmpAddress + 12) 16; size = (size - index)/2;BmpAddress += index;LCD_WriteReg(R3, 0 x1008); LCD_WriteRAM_Prepare(); for(index = 0; index BRR = 0 x0200;/LCD_NCS_LOW();GPIOB-BRR = 0 x0100
29、;/LCD_RS_LOW();GPIOB-BSRR = 0 x0020; /LCD_NWR_HIGH();GPIOC-ODR = LCD_Reg; /GPIO_Write(LCD_DataPort,LCD_Reg);GPIOB-BRR = 0 x0020; /LCD_NWR_LOW();GPIOB-BSRR = 0 x0020; /LCD_NWR_HIGH();GPIOB-BSRR = 0 x0100; /LCD_RS_HIGH();GPIOC-ODR = LCD_RegValue; GPIOB-BRR = 0 x0020; GPIOB-BSRR = 0 x0020; GPIOB-BSRR =
30、 0 x0100;/*/GPIO_Write(LCD_DataPort,LCD_RegValue);/LCD_NWR_LOW();/LCD_NWR_HIGH();/LCD_RS_HIGH();Function Name Description Input* Output* Return: LCD_ReadReg: Reads the selected LCD Register.: None: None: LCD Register Value.*u16 LCD_ReadReg(u8 LCD_Reg) u16 temp;GPIOB-BRR = 0 x0200;GPIOB-BRR = 0 x0100
31、;GPIOB-BSRR = 0 x0020;/LCD_NCS_LOW();/LCD_RS_LOW();/LCD_NWR_HIGH();GPIOC-ODR = LCD_Reg;/GPIO_Write(LCD_DataPort,LCD_Reg);GPIOB-BRR = 0 x0020; /LCD_NWR_LOW();GPIOB-BSRR = 0 x0020;GPIOB-BSRR = 0 x0100;/LCD_NWR_HIGH();/LCD_RS_HIGH();LCD_BusIn();GPIOB-BRR = 0 x0400;/LCD_NRD_LOW();temp = GPIOC-IDR;/temp=
32、GPIO_ReadInputData(LCD_DataPort);GPIOB-BSRR = 0 x0400; /LCD_NRD_HIGH();LCD_BusOut();GPIOB-BSRR = 0 x0200;/LCD_NCS_HIGH();return temp;/* Function Name : LCD_WriteRAM_Prepare* Description: Prepare to write to the LCD RAM.* Input : None* Output: None* Return: None*/void LCD_WriteRAM_Prepare(void)GPIOB-
33、BRR = 0 x0200;GPIOB-BRR = 0 x0100;GPIOB-BSRR = 0 x0020;/LCD_NCS_LOW();/LCD_RS_LOW();/LCD_NWR_HIGH();*GPIOC-ODR = R34; GPIOB-BRR = 0 x0020; GPIOB-BSRR = 0 x0020; GPIOB-BSRR = 0 x0100;/GPIO_Write(LCD_DataPort,R34);/LCD_NWR_LOW();/LCD_NWR_HIGH();/LCD_RS_HIGH();GPIOB-BSRR = 0 x0200; /LCD_NCS_HIGH();*Fun
34、ction Name : LCD_WriteRAMDescriptionInput* Output* Return: Writes to the LCD RAM.: - RGB_Code: the pixel color in RGB mode (5-6-5). : None: None*void LCD_WriteRAM(u16 RGB_Code)GPIOB-BRR = 0 x0200; /LCD_NCS_LOW();GPIOB-BSRR = 0 x0100; /LCD_RS_HIGH();GPIOB-BSRR = 0 x0020; /LCD_NWR_HIGH();GPIOC-ODR = R
35、GB_Code; /GPIO_Write(LCD_DataPort,RGB_Code); GPIOB-BRR = 0 x0020;/LCD_NWR_LOW();GPIOB-BSRR = 0 x0020;GPIOB-BSRR = 0 x0100;/LCD_NWR_HIGH();/LCD_RS_HIGH();GPIOB-BSRR = 0 x0200;/LCD_NCS_HIGH();/* Function Name : LCD_ReadRAM* Description : Reads the LCD RAM.* Input : None* Output: None* Return: LCD RAM
36、Value.*/u16 LCD_ReadRAM(void)u16 temp;GPIOB-BRR = 0 x0200;/LCD_NCS_LOW();GPIOB-BRR = 0 x0100;/LCD_RS_LOW();GPIOB-BSRR= 0 x0020;/LCD_NWR_HIGH();GPIOC-ODR = R34;/GPIO_Write(LCD_DataPort,R34);GPIOB-BRR = 0 x0020;/LCD_NWR_LOW();GPIOB-BSRR= 0 x0020;/LCD_NWR_HIGH();GPIOB-BSRR= 0 x0100;/LCD_RS_HIGH();LCD_B
37、usIn();GPIOB-BRR = 0 x0400;/LCD_NRD_LOW();temp = GPIOC-IDR;/temp=GPIO_ReadInputData(LCD_DataPort);GPIOB-BSRR= 0 x0400;/LCD_NRD_HIGH();LCD_BusOut();GPIOB-BSRR= 0 x0200;/LCD_NCS_HIGH();return temp;/* Function Name : LCD_PowerOn* Description : Power on the LCD.* Input : None* Output: None* Return: None
38、*/void LCD_PowerOn(void)LCD_WriteReg(R16, 0 x0000);LCD_WriteReg(R17, 0 x0000);LCD_WriteReg(R18, 0 x0000);LCD_WriteReg(R19, 0 x0000);Delay_LCD(20);LCD_WriteReg(R16, 0 x17B0);Function NameDescriptionInput* Output* Return: None: None: None*LCD_WriteReg(R17, 0 x0137);Delay_LCD(5);LCD_WriteReg(R18, 0 x01
39、39);Delay_LCD(5);LCD_WriteReg(R19, 0 x1d00);LCD_WriteReg(R41, 0 x0013);Delay_LCD(5);LCD_WriteReg(R7, 0 x0173);/* Function Name : LCD_DisplayOn* Description : Enables the Display.* Input : None* Output: None* Return: None* /void LCD_DisplayOn(void)LCD_WriteReg(R7, 0 x0173);/* Function Name : LCD_Disp
40、layOff* Description : Disables the Display.* Input: None* Output: None* Return: None*/void LCD_DisplayOff(void)LCD_WriteReg(R7, 0 x0);/*: LCD_CtrlLinesConfig: Configures LCD Control lines.Push-Pull mode./void LCD_CtrlLinesConfig(void)GPIO_InitTypeDef GPIO_InitStructure;RCC_APB2PeriphClockCmd(RCC_APB
41、2Periph_GPIOB | RCC_APB2Periph_GPIOC ENABLE);GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_5 | GPIO_Pin_8 | GPIO_Pin_10;GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;GPIO_Init(GPIOB, &GPIO_InitStructure);LCD_BusOut();GPIOB-BSRR |= 0 x0620;/* Function Name :
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 河南省安阳市文源高级中学2024-2025学年高二下学期开学调研质量检测考试数学试卷
- 2025年高考历史风标训练卷1(含解析)
- 交通工程设施施工方案
- 2025年二手烟试题及答案
- 电影布景设计施工方案
- 2025年jvm面试题库及答案
- 2025年三基护理院感试题及答案
- 回廊屋面施工方案范本
- 等比数列与夹逼定理
- 高空栈道施工方案
- 2025年医保知识考试题库及答案-医保定点医疗机构管理流程详解试题
- 2025年铁岭卫生职业学院单招职业倾向性测试题库学生专用
- 竣工结算审计服务投标方案(2024修订版)(技术方案)
- 物流无人机垂直起降场选址与建设规范
- 耳鼻咽喉头颈外科学第篇 鼻科学
- 沃尔玛全国的分布
- 电子营业执照下载确认书(外籍法定代表人)
- 钢结构厂房工程施工组织设计方案(85页)
- T∕CGCC 17-2018 商业信誉评价体系
- 数独6×6初级打印版
- 九种常规曲线测井方法
评论
0/150
提交评论