大学生
最后登录1970-1-1
在线时间 小时
注册时间2014-3-31
|
为什么我用stm32f103驱动ILI9320的时候液晶显示倾斜的?
由于代码较长 附上代码文件 高手路过麻烦看下指点一二 谢谢 不胜感激
//=============================================================
//============================Fonts============================
static sFONT *ILI9320_Currentfonts = &sFont8x16; //ó¢ÎÄ×Öìå
static uint16_t CurrentTextColor = RED;//Ç°¾°é«
static uint16_t CurrentBackColor = BLACK;//±3¾°é«
uint16_t LCD_X_LENGTH = ILI9320_LESS_PIXEL;
uint16_t LCD_Y_LENGTH = ILI9320_MORE_PIXEL;
void Bsp_Ili9320_SetFont(sFONT * font)
{
ILI9320_Currentfonts = font;
}
sFONT *Bsp_Ili9320_GetFont(void)
{
return ILI9320_Currentfonts;
}
void Bsp_Ili9320_SetColors(uint16_t TextColor, uint16_t BackColor)
{
CurrentTextColor = TextColor;
CurrentBackColor = BackColor;
}
void Bsp_Ili9320_GetColors(uint16_t *TextColor, uint16_t *BackColor)
{
*TextColor = CurrentTextColor;
*BackColor = CurrentBackColor;
}
void Bsp_Ili9320_SetBackColor(uint16_t Color)
{
CurrentBackColor = Color;
}
//void Bsp_Ili9320_ClearLine(uint16_t Line)
//{
// ILI9320_Clear(0,Line,LCD_X_LENGTH,((sFONT *)LCD_GetFont())->Height); /* ÇåÆᣬÏÔê¾è«oú */
//}
void Bsp_Ili9320_SetTextColor(uint16_t Color)
{
CurrentTextColor = Color;
}
void Bsp_Ili9320_DispChar_EN(uint16_t usSX, uint16_t usSY, const char cChar)
{
uint8_t byteCount, bitCount, fontLength;
uint16_t ucRelativePosition;
uint8_t *Pfont;
//¶ÔasciiÂë±íÆ«òÆ£¨×ÖÄ£±í2»°üo¬ASCII±íμÄÇ°32¸ö·Çí¼DηûoÅ£©
ucRelativePosition = cChar - ' ';
//ÿ¸ö×ÖÄ£μÄ×Ö½úêy
fontLength = (ILI9320_Currentfonts->Witdth*ILI9320_Currentfonts->Height)/8;
/*asciiÂë±íÆ«òÆÖμ3ËòÔÿ¸ö×ÖÄ£μÄ×Ö½úêy£¬Çó3ö×ÖÄ£μÄÆ«òÆλÖÃ*/
Pfont = (uint8_t *)&ILI9320_Currentfonts->table[ucRelativePosition*fontLength];
Bsp_Ili9320_OpenWindow(usSX, usSY, ILI9320_Currentfonts->Witdth, ILI9320_Currentfonts->Height);
ILI9320_Write_Cmd(WRITE_DATA_TO_GRAM);
for(byteCount = 0; byteCount < fontLength; byteCount++)
{
for(bitCount = 0; bitCount < 8; bitCount++)
{
if(Pfont[byteCount] & (0x80>>bitCount))
ILI9320_Write_Data(CurrentTextColor);
else
ILI9320_Write_Data(CurrentBackColor);
}
}
}
void Bsp_Ili9320_DispStringLine_EN(uint16_t line, char * pStr)
{
uint16_t usX = 0;
while ( * pStr != '\0' )
{
if ( ( usX - ILI9320_DispWindow_X_Star + ILI9320_Currentfonts->Witdth ) > LCD_X_LENGTH )
{
usX = ILI9320_DispWindow_X_Star;
line += ILI9320_Currentfonts->Height;
}
if ( ( line - ILI9320_DispWindow_Y_Star + ILI9320_Currentfonts->Height ) > LCD_Y_LENGTH )
{
usX = ILI9320_DispWindow_X_Star;
line = ILI9320_DispWindow_Y_Star;
}
Bsp_Ili9320_DispChar_EN ( usX, line, * pStr);
pStr ++;
usX += ILI9320_Currentfonts->Witdth;
}
}
void Bsp_Ili9320_DispString_EN(uint16_t usX ,uint16_t usY, char * pStr)
{
while ( * pStr != '\0' )
{
if ( ( usX - ILI9320_DispWindow_X_Star + ILI9320_Currentfonts->Witdth ) > LCD_X_LENGTH )
{
usX = ILI9320_DispWindow_X_Star;
usY += ILI9320_Currentfonts->Height;
}
if ( ( usY - ILI9320_DispWindow_Y_Star + ILI9320_Currentfonts->Height ) > LCD_Y_LENGTH )
{
usX = ILI9320_DispWindow_X_Star;
usY = ILI9320_DispWindow_Y_Star;
}
Bsp_Ili9320_DispChar_EN ( usX, usY, * pStr);
pStr ++;
usX += ILI9320_Currentfonts->Witdth;
}
}
//============================Fonts============================
//=============================================================
//=============================================================module_test===========================================================
void Bsp_Ili9320_FontTest(void)
{
static uint8_t testCNT = 0;
testCNT++;
Bsp_LCD_BackLightCtrl(ENABLE);
Bsp_Ili9320_Init();
Bsp_Ili9320_RegDataRead();
Bsp_Ili9320_GramDirScan(6);
Bsp_Ili9320_Screen_Clear(BLACK);
Bsp_Ili9320_DispChar_EN(0,0,'A');
Bsp_Ili9320_DispChar_EN(16,0,'B');
Bsp_Ili9320_DispChar_EN(32,0,'C');
// Bsp_Ili9320_DispString_EN(0,0,"shao");
// Bsp_Ili9320_DispStringLine_EN(LINE(0),"BH 3.2 inch LCD para:");
// Bsp_Ili9320_DispStringLine_EN(LINE(1),"Image resolution:240x320 px");
// Bsp_Ili9320_DispStringLine_EN(LINE(2),"ILI9341 LCD driver");
Bsp_Ili9320_DispStringLine_EN(LINE(3),"XPT2046 Touch Pad driver");
// sprintf(dispBuff,"Count : %d ",testCNT);
// ILI9341_DispStringLine_EN(LINE(4),dispBuff);
// Bsp_Ili9320_DispString_EN();
}
这部分是显示字符串部分的代码
|
|