?? lcd.c
字號:
//LCD.c
#include <reg51.h>
#include "time.h"
#include "LCD.h"
#include "serial.h"
/******************************************************************************
函數:LCD_SendData()
功能:主機通過串行總線向LCD發送一個字節的數據
參數:
uchValue:要發送的數據
返回:
******************************************************************************/
void LCD_SendData(unsigned char uchValue)
{
LCD_CS = 1;
Ser_SendByte(0xFA);//11111,01,0 RW=0,RS=1
Ser_SendByte(uchValue & 0xF0);//高四位
Ser_SendByte((uchValue & 0x0F)<<4);//低四位
LCD_CS = 0;
}
/******************************************************************************
函數:LCD_SendCommand()
功能:主機通過串行總線向LCD發送一個字節的控制命令
參數:
uchCmd:要發送的控制命令
返回:
******************************************************************************/
void LCD_SendComand(unsigned char uchCmd)
{
LCD_CS = 1;
Ser_SendByte(0xF8);//11111,00,0 RW=0,RS=0 同步標志
Ser_SendByte(uchCmd & 0xF0);//高四位
Ser_SendByte((uchCmd & 0x0F)<<4);//低四位
LCD_CS = 0;
}
/******************************************************************************
函數:LCD_Init()
功能:LCD初始化:上電、開背光、初始配置
參數:
返回:
******************************************************************************/
void LCD_Init()
{
LCD_CS = 0;
Delay_ms(1); //啟動等待,等LCM講入工作狀態
LCD_CS = 1;
LCD_BACKLIGHT = 0;
LCD_SendComand(0x30);//功能設置,一次送8位數據,基本指令集
LCD_SendComand(0x0C);//0000,1100 整體顯示,游標off,游標位置off
LCD_SendComand(0x01);//0000,0001 清DDRAM
LCD_SendComand(0x02);//0000,0010 DDRAM地址歸位
LCD_SendComand(0x80);//1000,0000 設定DDRAM 7位地址000,0000到地址計數器AC
}
/******************************************************************************
函數:LCD_Display()
功能:控制LCD在指定位置顯示指定內容
參數:
uchX_Add:指定位置
uchValue1、uchValue2:顯示內容的碼
返回:
******************************************************************************/
void LCD_Display(unsigned char uchX_Add,unsigned int uiValue)
{
unsigned char uchValue1,uchValue2;
uchValue1 = (uiValue >> 8) & 0x00ff;
uchValue2 = uiValue & 0x00ff;
LCD_SendComand(uchX_Add);
LCD_SendData(uchValue1);
LCD_SendData(uchValue2);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -