📄 lcdhal.c
字号:
if (( GL_Font == GL_FONT_BIG && (((const uint16_t*)c)[index] & (1 << counter)) == 0x00) ||
( GL_Font == GL_FONT_SMALL && (c[index] & (0x80 >> counter)) == 0x00))
{
LCD_WriteRAM(GL_BackColor);
}
else
{
LCD_WriteRAM(GL_TextColor);
}
}
if ((LCDType == LCD_ILI9320) || (LCDType == LCD_SPFD5408))
{
if ( pLcdHwParam.LCD_Connection_Mode == GL_SPI )
GL_LCD_CtrlLinesWrite(pLcdHwParam.LCD_Ctrl_Port_NCS, pLcdHwParam.LCD_Ctrl_Pin_NCS, GL_HIGH);
}
if (LCD_Direction == _0_degree)
{
Xaddress++;
LCD_SetCursor(Xaddress, Ypos);
}
else if (LCD_Direction == _90_degree)
{
Yaddress++;
LCD_SetCursor(Xpos, Yaddress);
}
else if (LCD_Direction == _180_degree)
{
Xaddress--;
LCD_SetCursor(Xaddress, Ypos);
}
else if (LCD_Direction == _270_degree)
{
Yaddress--;
LCD_SetCursor(Xpos, Yaddress);
}
}
}
/**
* @brief LCD_PrintChar
* @param Line: The X axis position
* @param Column: The Y axis position
* @param Ascii: The Character pointer
* @retval None
*/
void LCD_PrintChar(uint16_t Line, uint16_t Column, uint8_t Ascii)
{
Ascii -= 32;
switch (GL_Font)
{
case GL_FONT_BIG:
LCD_WriteChar( Line, Column, &GL_Font16x24.table[Ascii * GL_FontHeight] );
break;
case GL_FONT_SMALL:
LCD_WriteChar( Line, Column, &GL_Font8x12_bold.table[Ascii * GL_FontHeight] );
break;
default:
break;
}
}
/**
* @brief LCD_PrintStringLine
* @param Line: The X axis position
* @param Column: The Y axis position
* @param *ptr: The String of characters to be printed
* @retval None
*/
void LCD_PrintStringLine(uint16_t Line, uint16_t Column, uint8_t *ptr)
{
uint32_t counter = 0;
uint16_t refcolumn = 0;
uint8_t max_char_line = 0;
static uint16_t line;
line = Line;
if (LCD_Direction == _0_degree)
{
max_char_line = (LCD_Width / GL_FontWidth);
refcolumn = Column;
}
else if (LCD_Direction == _90_degree)
{
max_char_line = (LCD_Height / GL_FontWidth);
refcolumn = Column;
}
else if (LCD_Direction == _180_degree)
{
max_char_line = (LCD_Width / GL_FontWidth);
refcolumn = Column;
line = LCD_Height - Line;
}
else if (LCD_Direction == _270_degree)
{
max_char_line = (LCD_Height / GL_FontWidth);
refcolumn = Column;
line = LCD_Width - Line;
}
/* Send the string character by character on LCD */
while ((*ptr != 0) & (counter < max_char_line))
{
if (LCD_Direction == _0_degree)
{
/* Display one character on LCD */
LCD_PrintChar(line, refcolumn, *ptr);
/* Decrement the column position by 16 */
refcolumn -= GL_FontWidth;
}
else if (LCD_Direction == _90_degree)
{
/* Display one character on LCD */
LCD_PrintChar(refcolumn, line, *ptr);
/* Increment the column position by 16 */
refcolumn += GL_FontWidth;
}
else if (LCD_Direction == _180_degree)
{
/* Display one character on LCD */
LCD_PrintChar(line, refcolumn, *ptr);
/* Decrement the column position by 16 */
refcolumn += GL_FontWidth;
}
else if (LCD_Direction == _270_degree)
{
/* Display one character on LCD */
LCD_PrintChar(refcolumn, line, *ptr);
/* Increment the column position by 16 */
refcolumn -= GL_FontWidth;
}
/* Point on the next character */
ptr++;
/* Increment the character counter */
counter++;
}
}
/**
* @brief LCD_DrawMonoBMP
* @param *Pict: The pointer to the image
* @param Xpos_Init: The X axis position
* @param Ypos_Init: The Y axis position
* @param Height: The Height of the image
* @param Width: The Width of the image
* @retval None
*/
void LCD_DrawMonoBMP(const uint8_t *Pict, uint16_t Xpos_Init, uint16_t Ypos_Init, uint16_t Height, uint16_t Width)
{
int32_t index = 0, counter = 0;
if (LCD_Direction == _0_degree)
{
LCD_SetDisplayWindow(Xpos_Init, Ypos_Init, Height, Width);
/* Set GRAM write direction and BGR = 1 */
/* I/D=00 (Horizontal : decrement, Vertical : decrement) */
/* AM=1 (address is updated in vertical writing direction) */
LCD_WriteReg(R3, 0x1008);
}
else if (LCD_Direction == _90_degree)
{
LCD_SetDisplayWindow(Xpos_Init + Width - 1, Ypos_Init, Width, Height);
/* Set GRAM write direction and BGR = 1 */
/* I/D=01 (Horizontal : increment, Vertical : decrement) */
/* AM=0 (address is updated in horizontal writing direction) */
LCD_WriteReg(R3, 0x1010);
}
else if (LCD_Direction == _180_degree)
{
LCD_SetDisplayWindow(Xpos_Init + Height - 1, Ypos_Init + Width - 1, Height, Width);
/* Set GRAM write direction and BGR = 1 */
/* I/D=11 (Horizontal : increment, Vertical : increment) */
/* AM=1 (address is updated in vertical writing direction) */
LCD_WriteReg(R3, 0x1038);
}
else if (LCD_Direction == _270_degree)
{
LCD_SetDisplayWindow(Xpos_Init, Ypos_Init + Height - 1, Width, Height);
/* Set GRAM write direction and BGR = 1 */
/* I/D=10 (Horizontal : decrement, Vertical : increment) */
/* AM=0 (address is updated in horizontal writing direction) */
LCD_WriteReg(R3, 0x1020);
}
LCD_SetCursor(Xpos_Init, Ypos_Init);
if ((LCDType == LCD_ILI9320) || (LCDType == LCD_SPFD5408))
{
/* Prepare to write GRAM */
LCD_WriteRAM_Prepare();
}
for (index = 0; index < (Height*Width) / 8; index++)
{
for (counter = 7; counter >= 0; counter--)
{
if ((Pict[index] & (1 << counter)) == 0x00)
{
LCD_WriteRAM(GL_BackColor);
}
else
{
LCD_WriteRAM(GL_TextColor);
}
}
}
if ((LCDType == LCD_ILI9320) || (LCDType == LCD_SPFD5408))
{
if ( pLcdHwParam.LCD_Connection_Mode == GL_SPI )
{
GL_LCD_CtrlLinesWrite(pLcdHwParam.LCD_Ctrl_Port_NCS, pLcdHwParam.LCD_Ctrl_Pin_NCS, GL_HIGH);
}
}
LCD_Change_Direction(LCD_Direction);
GL_SetDisplayWindow(LCD_Height - 1, LCD_Width - 1, LCD_Height, LCD_Width);
}
/**
* @brief Fill area with color.
* @param maxX: Maximum X coordinate
* @param minX: Minimum X coordinate
* @param maxY: Maximum Y coordinate
* @param minY: Minimum Y coordinate
* @param ptrBitmap: pointer to the image
* @retval None
*/
void LCD_FillArea(uint16_t Xpos_Init, uint16_t Ypos_Init, uint16_t Height, uint16_t Width, uint16_t color)
{
uint32_t area = 0;
uint32_t index = 0;
area = Width * Height;
if (LCD_Direction == _0_degree)
{
GL_SetDisplayWindow(Xpos_Init, Ypos_Init, Height, Width);
/* Set GRAM write direction and BGR = 1 */
/* I/D=00 (Horizontal : decrement, Vertical : decrement) */
/* AM=1 (address is updated in vertical writing direction) */
LCD_WriteReg(R3, 0x1008);
}
else if (LCD_Direction == _90_degree)
{
GL_SetDisplayWindow(Xpos_Init + Width - 1, Ypos_Init, Width, Height);
/* Set GRAM write direction and BGR = 1 */
/* I/D=01 (Horizontal : increment, Vertical : decrement) */
/* AM=0 (address is updated in horizontal writing direction) */
LCD_WriteReg(R3, 0x1010);
}
else if (LCD_Direction == _180_degree)
{
GL_SetDisplayWindow(Xpos_Init + Height - 1, Ypos_Init + Width - 1, Height, Width);
/* Set GRAM write direction and BGR = 1 */
/* I/D=11 (Horizontal : increment, Vertical : increment) */
/* AM=1 (address is updated in vertical writing direction) */
LCD_WriteReg(R3, 0x1038);
}
else if (LCD_Direction == _270_degree)
{
GL_SetDisplayWindow(Xpos_Init, Ypos_Init + Height - 1, Width, Height);
/* Set GRAM write direction and BGR = 1 */
/* I/D=10 (Horizontal : decrement, Vertical : increment) */
/* AM=0 (address is updated in horizontal writing direction) */
LCD_WriteReg(R3, 0x1020);
}
LCD_SetCursor(Xpos_Init, Ypos_Init);
if ((LCDType == LCD_ILI9320) || (LCDType == LCD_SPFD5408))
{
LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
}
for (index = 0;index < area; index++)
{
LCD_WriteRAM(color);
}
if ((LCDType == LCD_ILI9320) || (LCDType == LCD_SPFD5408))
{
if ( pLcdHwParam.LCD_Connection_Mode == GL_SPI )
{
GL_LCD_CtrlLinesWrite(pLcdHwParam.LCD_Ctrl_Port_NCS, pLcdHwParam.LCD_Ctrl_Pin_NCS, GL_HIGH);
}
}
LCD_Change_Direction(LCD_Direction);
GL_SetDisplayWindow(LCD_Height - 1, LCD_Width - 1, LCD_Height, LCD_Width);
}
/**
* @brief LCD_DrawColorBMP
* @param *ptrBitmap: The pointer to the image
* @param Xpos_Init: The X axis position
* @param Ypos_Init: The Y axis position
* @param Height: The Height of the image
* @param Width: The Width of the image
* @retval None
*/
void LCD_DrawColorBMP(uint8_t* ptrBitmap, uint16_t Xpos_Init, uint16_t Ypos_Init, uint16_t Height, uint16_t Width)
{
uint32_t uDataAddr = 0, uBmpSize = 0;
uint16_t uBmpData = 0;
BmpBuffer32BitRead(&uBmpSize, ptrBitmap + 2);
BmpBuffer32BitRead(&uDataAddr, ptrBitmap + 10);
if (LCD_Direction == _0_degree)
{
GL_SetDisplayWindow(Xpos_Init, Ypos_Init, Height, Width);
/* Set GRAM write direction and BGR = 1 */
/* I/D=00 (Horizontal : decrement, Vertical : decrement) */
/* AM=1 (address is updated in vertical writing direction) */
LCD_WriteReg(R3, 0x1008);
}
else if (LCD_Direction == _90_degree)
{
GL_SetDisplayWindow(Xpos_Init + Width - 1, Ypos_Init, Width, Height);
/* Set GRAM write direction and BGR = 1 */
/* I/D=01 (Horizontal : increment, Vertical : decrement) */
/* AM=0 (address is updated in horizontal writing direction) */
LCD_WriteReg(R3, 0x1010);
}
else if (LCD_Direction == _180_degree)
{
GL_SetDisplayWindow(Xpos_Init + Height - 1, Ypos_Init + Width - 1, Height, Width);
/* Set GRAM write direction and BGR = 1 */
/* I/D=11 (Horizontal : increment, Vertical : increment) */
/* AM=1 (address is updated in vertical writing direction) */
LCD_WriteReg(R3, 0x1038);
}
else if (LCD_Direction == _270_degree)
{
GL_SetDisplayWindow(Xpos_Init, Ypos_Init + Height - 1, Width, Height);
/* Set GRAM write direction and BGR = 1 */
/* I/D=10 (Horizontal : decrement, Vertical : increment) */
/* AM=0 (address is updated in horizontal writing direction) */
LCD_WriteReg(R3, 0x1020);
}
LCD_SetCursor(Xpos_Init, Ypos_Init);
if ((LCDType == LCD_ILI9320) || (LCDType == LCD_SPFD5408))
{
/* Prepare to write GRAM */
LCD_WriteRAM_Prepare();
}
/* Read bitmap data and write them to LCD */
for (; uDataAddr < uBmpSize; uDataAddr += 2)
{
uBmpData = (uint16_t)(*(ptrBitmap + uDataAddr)) + (uint16_t)((*(ptrBitmap + uDataAddr + 1)) << 8);
LCD_WriteRAM( uBmpData );
}
if ((LCDType == LCD_ILI9320) || (LCDType == LCD_SPFD5408))
{
if ( pLcdHwParam.LCD_Connection_Mode == GL_SPI )
{
GL_LCD_CtrlLinesWrite(pLcdHwParam.LCD_Ctrl_Port_NCS, pLcdHwParam.LCD_Ctrl_Pin_NCS, GL_HIGH);
}
}
LCD_Change_Direction(LCD_Direction);
GL_SetDisplayWindow(LCD_Height - 1, LCD_Width - 1, LCD_Height, LCD_Width);
}
/**
* @}
*/
/**
* @}
*/
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -