Board logo

标题: [求助]一个LCD显示问题 [打印本页]

作者: matthewrain    时间: 2008-12-5 09:17     标题: [求助]一个LCD显示问题

目前我遇到一个问题,在LCD显示时会出现的状况

先说下LCD是256?1的,分成了10页,每页Y方向有8个点。

当我显示的起始Y坐标位置不是8的倍数的时候,会调用下面这个函数去做显示。但是,问题是我发觉只要起始坐标位置不是8的倍数,在同一X坐标下(比如X1-X16,16个点那么宽),其他Y方向都会显示出连续的黑色区域,特点是每6个黑点2个白点。

...

...

...

...

...

...

就像这样的一个模式。

而这个黑色区域,我先称之为连续的黑线。黑线从LCD显示的情况来看,是在我要显示的东西如“A”的后面,就是说是先显示了黑线,然后A再显示到黑线上面去的。

另外,我把显示内容比如一个A拆分成两个部分,分别在两个页面中显示,起始坐标选择是Y方向是能正常显示的。

我想麻烦各位达人帮我看下这段程序是否有问题。不胜感谢!!!!!!

这个函数是Y!=8的倍数的

unsigned char ucPLCD_eDisplayArea_Exe(unsigned int uiStartX, unsigned char ucStartY, \
unsigned int uiWidth, unsigned char ucHeight, \
unsigned char const * pucDataStart, unsigned char ucDrawMode)
{
unsigned char const * pucData;
unsigned char * pucBuffer;
unsigned char ucMaxHeight; /*maximum possible height with given ucStartY*/
unsigned char uiEndX;
unsigned char ucXStartOff;
unsigned char ucXPageMaxBits;
unsigned char ucMask;
unsigned char ucHeightTemp;
unsigned char ucXPageRemBits;
unsigned char ucTempData;


if(ucStartY < DucDLCD_eHEIGHTSCREEN)
{
uiEndX = ((uiWidth+uiStartX) - 1);
ucMaxHeight = (DucDLCD_eHEIGHTSCREEN-ucStartY);
pucData = 0;

if(ucHeight > ucMaxHeight)
{
ucHeight = ucMaxHeight;
}
if(uiEndX >= DucDLCD_eWIDTHSCREEN)
{
uiEndX = (DucDLCD_eWIDTHSCREEN-1);
}
ucXStartOff = (ucStartY & 0x07);
while(uiStartX <= uiEndX)
{
ucMask = ucDLCDMask[ucXStartOff];
ucXPageMaxBits = (8-ucXStartOff);
ucHeightTemp = ucHeight;

if(pucDataStart != 0)
{
pucData = pucDataStart++;
}

vDLCD_iReadColumn_Exe(uiStartX, pucDLCD_iRAMBuffer);
pucBuffer = &pucDLCD_iRAMBuffer[ucStartY>>3];

for(;;)
{
if(ucXPageMaxBits >= ucHeightTemp)
{
ucMask = (ucMask+(0xFF << (ucXStartOff+ucHeightTemp)));
ucXPageRemBits = 0;
ucHeightTemp = 0;
}
else
{
ucXPageRemBits = (ucHeightTemp-ucXPageMaxBits);
if(ucXPageRemBits > (8-ucXPageMaxBits))
{
ucXPageRemBits = (8-ucXPageMaxBits);
}
ucHeightTemp -= ucXPageMaxBits;
ucHeightTemp -= ucXPageRemBits;
}
if(pucData != 0)
{
*pucBuffer &= ucMask;
if(ucDrawMode == 0)
{
*pucBuffer |= ((*pucData<<ucXStartOff) & (~ucMask));
}
else
{
*pucBuffer |= (((~*pucData)<<ucXStartOff) & (~ucMask));
}
}
else
{
if(ucDrawMode == DucPLCD_eDispModeReversePlot)
{
*pucBuffer &= ucMask;
}
else if(ucDrawMode == DucPLCD_eDispModeNormalPlot)
{
*pucBuffer |= ~ucMask;
}
else
{
/*
** Request is for Reverse Video..
*/
ucTempData = ((*pucBuffer) & ucMask);
*pucBuffer = (ucTempData | ((~*pucBuffer) & ~ucMask));
}
}
pucBuffer++;

if(ucXPageRemBits != 0)
{
if(pucData != 0)
{
*pucBuffer &= ~ucDLCDMask[ucXPageRemBits];
if(ucDrawMode == 0)
{
*pucBuffer |= (*pucData>>(ucXPageMaxBits));
}
else
{
*pucBuffer |= (((~*pucData)>>ucXPageMaxBits) & ucDLCDMask[ucXPageRemBits]);
}
}
else
{
if(ucDrawMode == DucPLCD_eDispModeReversePlot)
{
//*pucBuffer &= ~ucDLCDMask[ucXPageRemBits];
*pucBuffer &= ~ucMask;
}
else if(ucDrawMode == DucPLCD_eDispModeNormalPlot)
{
//*pucBuffer |= ~ucDLCDMask[ucXPageRemBits];
*pucBuffer |= ucMask;
}
else
{
/*
** Request is for Reverse Video..
*/
ucTempData = ((*pucBuffer) & (~ucDLCDMask[ucXPageRemBits]));
*pucBuffer = (ucTempData | ((~*pucBuffer) & ucDLCDMask[ucXPageRemBits]));
}
}
}
if(ucHeightTemp != 0)
{
if(pucData != 0)
{
pucData = &pucData[uiWidth];
}
}
else
{
break;
}
}
vDLCD_iWriteColumn_Exe(uiStartX, pucDLCD_iRAMBuffer);
uiStartX++;
}
if(uiStartX >= DucDLCD_eWIDTHSCREEN)
{
return(DucDLCD_eWIDTHSCREEN-1);
}
return(uiStartX);
}
return(DucPLCD_OUT_CONDITIONS);
}

当y坐标是8的倍数的时候显示是调用这个函数的

unsigned char ucPLCD_eDisplayAreaAligned_Exe(unsigned int uiStartX, unsigned char ucStartY, \
unsigned int uiWidth, unsigned char ucHeight, \
unsigned char const * pucDataStart, unsigned char ucDrawMode )
{
unsigned int uiNextX;
unsigned int ucNBColoumn;
unsigned char ucMask;

if(ucStartY < DucDLCD_eHEIGHTSCREEN)
{
uiNextX = (uiStartX+uiWidth);
if(uiNextX > DucDLCD_eWIDTHSCREEN)
{
uiNextX = DucDLCD_eWIDTHSCREEN;
uiWidth = (DucDLCD_eWIDTHSCREEN-uiStartX);
}
ucHeight >>= 3;
ucStartY >>= 3;
vDLCD_eSendCommand_Exe(DucDLCD_iStartLineSetCmd);
vDLCD_eSendData_Exe(0x00);

while(ucHeight)
{
vDLCD_eSendCommand_Exe(DucDLCD_iDispDataDirColoumn);
vDLCD_eSendCommand_Exe(DucDLCD_iPageAddrSetCmd);
vDLCD_eSendData_Exe(ucStartY++);
vDLCD_eSendCommand_Exe(DucDLCD_iColmnAddrSetCmd);
vDLCD_eSendData_Exe(uiStartX);
vDLCD_eSendCommand_Exe(DucDLCD_iDisplayDataWrite);
ucNBColoumn = uiWidth;
while(ucNBColoumn)
{
if(ucDrawMode == DucPLCD_eDispModeNormalPlot)
{
if(pucDataStart != 0)
{
//pucDataStart = pucDataStart&mask;
vDLCD_eSendData_Exe(*pucDataStart);
pucDataStart++;
}
else
{
vDLCD_eSendData_Exe(0xFF);
}
}
else
{
if(pucDataStart != 0)
{
vDLCD_eSendData_Exe(~*pucDataStart);
pucDataStart++;
}
else
{
vDLCD_eSendData_Exe(0x00);
}
}
ucNBColoumn--;
}
ucHeight--;
}
if(uiNextX >= DucDLCD_eWIDTHSCREEN)
{
return(DucDLCD_eWIDTHSCREEN-1);
}
return(uiNextX);
}
return(DucPLCD_OUT_CONDITIONS);
}






欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0