📄 lcd.c
字号:
/* Display 16bits LSB */
var_ptr = var_ptr -1;
var = *var_ptr;
var_ptr = var_ptr +4;
c1 = LCD_HexToAsciiHigh(var);
LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
RefColumn+=7;
c1 = LCD_HexToAsciiLow(var);
LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
RefColumn+=7;
var_ptr = var_ptr -5;
var = *var_ptr;
var_ptr = var_ptr +4;
c1 = LCD_HexToAsciiHigh(var);
LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
RefColumn+=7;
c1 = LCD_HexToAsciiLow(var);
LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
RefColumn+=7;
}
else
{
/* Display '%' character which is followed by (d, x or w) */
ptr--;
c1 = *ptr;
LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
RefColumn+=7;
ptr++;
i++;
if(i==17)
{
/* Add missed columns */
LCD_DisplayChar(RefPage, RefColumn-1, 0x1f, TextMode);
RefColumn = 0;
RefPage+=2;
}
}
}
else
{
/* Display characters different from (\r, \n, %) */
LCD_DisplayChar(RefPage, RefColumn, c1, TextMode);
RefColumn+=7;
ptr++;
i++;
if(i==17)
{
/* Add missed columns */
LCD_DisplayChar(RefPage, RefColumn-1, 0x1f, TextMode);
LCD_ClearLine(Line2);
RefColumn = 0;
RefPage+=2;
}
}
}
}
/* Display spaces if string doesn't reach the max LCD characters size */
while(RefColumn<119)
{
/* Display Spaces */
LCD_DisplayChar(RefPage, RefColumn, 0x20, TextMode);
RefColumn+=7;
/* Add missed columns */
LCD_DisplayChar(RefPage, RefColumn, 0x1f, TextMode);
}
}
/*******************************************************************************
* Function Name : LCD_DrawMasterGraphic
* Description : Draw a Graphic image on master LCD.
* Input : - Bmp: the pointer of the dot matrix data.
* Output : None
* Return : None.
*******************************************************************************/
void LCD_DrawMasterGraphic(u8 *Bmp)
{
u8 j = 0, k = 0, ActPage = 0;
/* Draw graphic on master: 61 Column *4 Pages */
while(j<244)
{
/* Draw on master page by page */
LCD_SetMasterPage(ActPage);
for(k=0; k<61; k++)
{
LCD_SetMasterColumn(k);
LCD_SendMasterData(*Bmp++);
j++;
}
ActPage++;
}
}
/*******************************************************************************
* Function Name : LCD_DrawSlaveGraphic
* Description : Draw a Graphic image on slave LCD.
* Input : - Bmp: the pointer of the dot matrix data.
* Output : None
* Return : None.
*******************************************************************************/
void LCD_DrawSlaveGraphic(u8 *Bmp)
{
u8 j = 0, k = 0, ActPage = 0;
/* Draw graphic on slave: 61 Column *4 Pages */
while(j<244)
{
/* Draw on slave page by page */
LCD_SetSlavePage(ActPage);
for(k=0; k<61; k++)
{
LCD_SetSlaveColumn(k);
LCD_SendSlaveData(*Bmp++);
j++;
}
ActPage++;
}
}
/*******************************************************************************
* Function Name : LCD_DrawGraphic
* Description : Draw a Graphic image on LCD.
* Input : - Bmp: the pointer of the dot matrix data.
* Output : None
* Return : None.
*******************************************************************************/
void LCD_DrawGraphic(u8 *Bmp)
{
u8 Pos = 0, ActPage = 0;
u16 j = 0, k = 0;
/* Draw graphic on LCD: 122 Column *4 Pages */
while(j<488)
{
if(!Pos)
{
/* Draw on master page by page */
LCD_SetMasterPage(ActPage);
for(k=0; k<61; k++)
{
LCD_SetMasterColumn(k);
LCD_SendMasterData(*Bmp++);
j++;
}
Pos=1;
}
else
{
/* Draw on slave page by page */
LCD_SetSlavePage(ActPage);
for(k=0; k<61; k++)
{
LCD_SetSlaveColumn(k);
LCD_SendSlaveData(*Bmp++);
j++;
}
ActPage++;
Pos=0;
}
}
}
/*******************************************************************************
* Function Name : LCD_ScrollGraphic
* Description : Scroll a Graphic image on LCD.
* Input : - Bmp: the pointer of the dot matrix data.
* - nCount: specifies the delay time length.
* Output : None
* Return : None.
*******************************************************************************/
void LCD_ScrollGraphic(u8 *Bmp, u32 nCount)
{
u8 Pos = 0, ActPage = 0;
u16 j = 0, k = 0;
u32 Counter = 0;
/* Draw graphic on LCD: 122 Column *4 Pages */
while(j<488)
{
if(!Pos)
{
/* Draw on master page by page */
LCD_SetMasterPage(ActPage);
for(k=0; k<61; k++)
{
LCD_SetMasterColumn(k);
LCD_SendMasterData(*Bmp++);
Counter = nCount;
/* Set a delay */
for(; Counter != 0; Counter--);
j++;
}
Pos=1;
}
else
{
/* Draw on slave page by page */
LCD_SetSlavePage(ActPage);
for(k=0; k<61; k++)
{
LCD_SetSlaveColumn(k);
Counter = nCount;
/* Set a delay */
for(; Counter != 0; Counter--);
LCD_SendSlaveData(*Bmp++);
j++;
}
ActPage++;
Pos=0;
}
}
}
/*******************************************************************************
* Function Name : LCD_DrawPixel
* Description : Draw a Graphic image on slave LCD.
* Input : - XPos: the dot line number of the pixel.
* - 1->61 : displayed on master LCD
* - 62->122: displayed on slave LCD
* - YPos: column address of the pixel from 1->32.
* - Mode: Dot_On: Pixel turned on (black).
* Dot_Off: Pixel turned off (black).
* Output : None
* Return : None.
*******************************************************************************/
void LCD_DrawPixel(u8 XPos, u8 YPos, DotMode_TypeDef Mode)
{
u8 Page = 0, Position = 0;
u16 Mask = 0;
u32 MasterDataIn = 0, MasterDataOut = 0, SlaveDataIn = 0, SlaveDataOut = 0;
/* Pixel page */
Page = (XPos-1)/8;
/* Pixel column */
Position = (YPos-1)/61; /* 0:Master, 1:Slave */
/* Mask for the pixel */
Mask= 1<<((XPos-1)%8);
/* If Position=0 draw pixel on master LCD */
if(!Position)
{
LCD_SetMasterPage(Page);
LCD_SetMasterColumn(YPos-1);
MasterDataIn = LCD_ReadMasterData();
MasterDataIn = LCD_ReadMasterData();
LCD_SetMasterColumn(YPos-1);
if(Mode==Dot_On)
{
MasterDataOut = MasterDataIn | Mask;
}
else
{
MasterDataOut = MasterDataIn & (~Mask);
}
LCD_SendMasterData(MasterDataOut);
}
/* If Position=1 draw pixel on slave LCD */
else
{
LCD_SetSlavePage(Page);
LCD_SetSlaveColumn(YPos-62);
SlaveDataIn = LCD_ReadSlaveData();
SlaveDataIn = LCD_ReadSlaveData();
LCD_SetSlaveColumn(YPos-62);
if(Mode==Dot_On)
{
SlaveDataOut = SlaveDataIn | Mask;
}
else
{
SlaveDataOut = SlaveDataIn & (~Mask);
}
LCD_SendSlaveData(SlaveDataOut);
}
}
/*******************************************************************************
* Function Name : LCD_DrawLine
* Description : Draw a line on master and slave LCDs.
* Input : - XPos1: the dot line number of the source point .
* - XPos2: the dot line number of the destination point .
* - YPos1: the dot column number of the source point.
* - YPos2: the dot column number of the destination point.
* Output : None
* Return : None.
*******************************************************************************/
void LCD_DrawLine(u8 XPos1, u8 YPos1, u8 XPos2, u8 YPos2)
{
u8 XPos = 0, YPos = 0;
/* Use XPos1, YPos1, XPos2 and YPos2 */
if((XPos2>=XPos1)&(YPos2>=YPos1))
{
for(XPos=XPos1; XPos<=XPos2; XPos++)
{
for(YPos=YPos1; YPos<=YPos2; YPos++)
{
LCD_DrawPixel(XPos, YPos, Dot_On);
}
}
}
else if((XPos2<XPos1)&(YPos2>=YPos1))
{
for(XPos=XPos2; XPos<=XPos1; XPos++)
{
for(YPos=YPos1; YPos<=YPos2; YPos++)
{
LCD_DrawPixel(XPos, YPos, Dot_On);
}
}
}
else if((XPos2>=XPos1)&(YPos2<YPos1))
{
for(XPos=XPos1; XPos<=XPos2; XPos++)
{
for(YPos=YPos2; YPos<=YPos1; YPos++)
{
LCD_DrawPixel(XPos, YPos, Dot_On);
}
}
}
else /*if((XPos2<XPos1)&(YPos2<YPos1))*/
{
for(XPos=XPos2; XPos<=XPos1; XPos++)
{
for(YPos=YPos2; YPos<=YPos1; YPos++)
{
LCD_DrawPixel(XPos, YPos, Dot_On);
}
}
}
}
/*******************************************************************************
* Function Name : LCD_DrawBox
* Description : Draw a Box on master and slave LCDs.
* Input : - XPos: the dot line number of the source point .
* - YPos: the dot column number of the source point.
* - Dx: Box large.
* - Dy: Box width.
* Output : None
* Return : None.
*******************************************************************************/
void LCD_DrawBox(u8 XPos, u8 YPos, u8 Dx, u8 Dy)
{
/* Use XPos, YPos, Dx and Dy */
LCD_DrawLine(XPos, YPos, XPos, YPos+Dy);
LCD_DrawLine(XPos, YPos, XPos+Dx, YPos);
LCD_DrawLine(XPos+Dx, YPos, XPos+Dx, YPos+Dy);
LCD_DrawLine(XPos, YPos+Dy, XPos+Dx, YPos+Dy);
}
/******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE******/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -