📄 display.c
字号:
/*********************************************************************************
* *
* FileName: Display.c *
* Function: monitor controller *
* SystemName: NDS18000-BSC *
* CPU: ATMEL AT89C52 *
* Startup: 14/Oct/2002 *
* Author: XuYiBo *
* *
*********************************************************************************/
#include <AT89X52.H>
#include "NDSBSCUI.H"
#include "display.h"
#include "General.h"
//unsigned char data ucDisBuffer[40]; //display buffer
//unsigned char data ucCursorType; //Cursor Type:0=turn off,1=turn on,2=blink,others no define
//unsigned char data ucCursorPos; //Cursor Position:range 0-40
unsigned char xdata ucDisplayDat _at_ 0x4000;
unsigned char xdata ucDisplayCom _at_ 0x4001;
extern UIMemory xdata UIDataArea; //define in NDSBSCUI.C
/////////////////////////////////////////////////////////////////////////////////////////////////
/***********************************************************
* *
* Initialize display parameter *
* *
***********************************************************/
void InitDisplay(void)
{
// ucCursorType= 0;
// ucCursorPos = 40;
ResetLCD();
}
/***********************************************************
* *
* write display buffer(code area to data area) *
* *
***********************************************************/
/*
void WriteDisBuf_c(unsigned char code *pStr_Sour)
{
unsigned char data *pstr_Tmp;
pstr_Tmp = ucDisBuffer;
while( pstr_Tmp != ucDisBuffer+40)
{
*(pstr_Tmp++) = *(pStr_Sour++);
}
}
*/
/***********************************************************
* *
* write display buffer(xdata area to data area) *
* *
***********************************************************/
/*
void WriteDisBuf_x(void)
{
unsigned char data *pstr_Des;
unsigned char xdata *pstr_Sour;
pstr_Des = ucDisBuffer;
pstr_Sour= UIDataArea.DisBuffer.DisplayBuffer;
while( pstr_Des != ucDisBuffer+40)
{
*(pstr_Des++) = *(pstr_Sour++);
}
ucCursorType= UIDataArea.DisBuffer.CursorType;
ucCursorPos = UIDataArea.DisBuffer.CursorPos;
}
*/
/***********************************************************
* *
* Initialize the LCD panel *
* *
***********************************************************/
void ResetLCD(void)
{
ucDisplayCom = 0x01; //Clear Display
DelayTime(0x02);
ucDisplayCom = 0x38; //8Bit BUS/2Line display mode/5*11 dots
DelayCycle(0x16);
ucDisplayCom = 0x0c; //Display on/Cursor off/Cursor blink off
DelayCycle(0x16);
ucDisplayCom = 0x06; //
DelayCycle(0x16);
}
/***********************************************************
* *
* 将DisBuffer中40Bytes送显示屏,设置光标位置、类型等 *
* *
***********************************************************/
/*
void Display(void)
{
unsigned char data *pstr_Tmp;
ucDisplayCom = 0x80;
DelayCycle(0x08);
pstr_Tmp = ucDisBuffer;
while( pstr_Tmp != ucDisBuffer+20)
{
ucDisplayDat = *(pstr_Tmp++);
DelayCycle(0x08);
}
ucDisplayCom = 0xc0; //Second line
DelayCycle(0x08);
while( pstr_Tmp != ucDisBuffer+40)
{
ucDisplayDat = *(pstr_Tmp++);
DelayCycle(0x08);
}
if( ucCursorPos >= 20 ) //Set cursor position
{
ucDisplayCom = (ucCursorPos+44) | 0x80;
}
else
{
ucDisplayCom = ucCursorPos | 0x80;
}
DelayCycle(0x08);
if( ucCursorType == 0x00) //Cursor type
{
ucDisplayCom = 0x0c; //turn off the cursor
}
else if( ucCursorType == 0x01)
{
ucDisplayCom = 0x0e; //turn on the cursor
}
else if( ucCursorType == 0x02)
{
ucDisplayCom = 0x0f; //blink
}
DelayCycle(0x08);
}
*/
/***************************************************************
* *
* 将双口RAM中显示缓冲区的内容送显示屏,设置光标位置、类型等 *
* *
***************************************************************/
void DisplayEx(void)
{
unsigned char xdata *pstr_Tmp;
unsigned char ucTmp;
ucDisplayCom = 0x80; //first line
DelayCycle(0x08);
pstr_Tmp = UIDataArea.DisBuffer.DisplayBuffer;
ucTmp = 20;
while( ucTmp-- )
{
ucDisplayDat = *(pstr_Tmp++);
DelayCycle(0x06);
}
ucDisplayCom = 0xc0; //Second line
DelayCycle(0x08);
ucTmp = 20;
while( ucTmp-- )
{
ucDisplayDat = *(pstr_Tmp++);
DelayCycle(0x06);
}
if( UIDataArea.DisBuffer.CursorPos >= 20 ) //Set cursor position
{
ucDisplayCom = (UIDataArea.DisBuffer.CursorPos+44) | 0x80;
}
else
{
ucDisplayCom = UIDataArea.DisBuffer.CursorPos | 0x80;
}
DelayCycle(0x08);
if( UIDataArea.DisBuffer.CursorType == 0x00) //Cursor type
{
ucDisplayCom = 0x0c; //turn off the cursor
}
else if( UIDataArea.DisBuffer.CursorType == 0x01)
{
ucDisplayCom = 0x0e; //turn on the cursor
}
else if( UIDataArea.DisBuffer.CursorType == 0x02)
{
ucDisplayCom = 0x0f; //blink
}
DelayCycle(0x08);
}
/***************************************************************
* *
* 将指定的ROM区的内容送显示屏 *
* *
***************************************************************/
void DisplayRom(unsigned char code *pstr_Tmp)
{
unsigned char ucTmp;
ucDisplayCom = 0x80; //first line
DelayCycle(0x08);
ucTmp = 20;
while( ucTmp-- )
{
ucDisplayDat = *(pstr_Tmp++);
DelayCycle(0x06);
}
ucDisplayCom = 0xc0; //Second line
DelayCycle(0x08);
ucTmp = 20;
while( ucTmp-- )
{
ucDisplayDat = *(pstr_Tmp++);
DelayCycle(0x06);
}
}
/***********************************************************
* *
* set type of the cursor: *
* 0=turn off *
* 1=turn on,not blink *
* 2=turn on,blink *
* *
***********************************************************/
/*void SetCursorType(unsigned char ucType)
{
if( ucType == 0x00) //Cursor type
{
ucDisplayCom = 0x0c; //turn off
}
else if( ucType == 0x01)
{
ucDisplayCom = 0x0e; //turn on,not blink
}
else if( ucType == 0x02)
{
ucDisplayCom = 0x0f; //blink
}
DelayCycle(0x08);
}
*/
/***********************************************************
* *
* set position of the cursor *
* *
***********************************************************/
void SetCursorPos(unsigned char ucPos)
{
if( ucPos >= 20 )
{//first line
ucDisplayCom = (ucPos+44) | 0x80;
}
else
{//second line
ucDisplayCom = ucPos | 0x80;
}
DelayCycle(0x08);
}
/***********************************************************
* *
* display a char at current position *
* *
***********************************************************/
void DisplayChar(unsigned char ucDisByte)
{
ucDisplayDat = ucDisByte;
DelayCycle(0x08);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -