?? stm3210c_eval_lcd.c
字號(hào):
{
Ascii -= 32;
LCD_DrawChar(Line, Column, &LCD_Currentfonts->table[Ascii * LCD_Currentfonts->Height]);
}
/**
* @brief Displays a maximum of 20 char on the LCD.
* @param Line: the Line where to display the character shape .
* This parameter can be one of the following values:
* @arg Linex: where x can be 0..9
* @param *ptr: pointer to string to display on LCD.
* @retval None
*/
void LCD_DisplayStringLine(uint8_t Line, uint8_t *ptr)
{
uint16_t refcolumn = 0;
/* Send the string character by character on lCD */
//while ((*ptr != 0) & (((refcolumn + 1) & 0xFFFF) <= LCD_Currentfonts->Width))
while ((*ptr != 0))
{
/* Display one character on LCD */
LCD_DisplayChar(Line, refcolumn, *ptr);
/* Decrement the column position by 16 */
refcolumn += LCD_Currentfonts->Width;
if(refcolumn + LCD_Currentfonts->Width > LCD_PIXEL_WIDTH)
break;
/* Point on the next character */
ptr++;
}
}
void LCD_DisplayWelcomeStr(uint8_t Line)
{
uint16_t num = 0;
/* Send the string character by character on LCD */
for(num=0; num<13; num++)
{
/* Display one China character on LCD */
LCD_DrawChinaChar(Line, num*24+4, (uint8_t *)WelcomeStr[num]);
}
}
/**
* @brief Sets a display window
* @param Xpos: specifies the X buttom left position.
* @param Ypos: specifies the Y buttom left position.
* @param Height: display window height.
* @param Width: display window width.
* @retval None
*/
void LCD_SetDisplayWindow(uint8_t Xpos, uint16_t Ypos, uint8_t Height, uint16_t Width)
{
#if 0
/* Horizontal GRAM Start Address */
if(Xpos >= Height)
{
LCD_WriteReg(LCD_REG_80, (Xpos - Height + 1));
}
else
{
LCD_WriteReg(LCD_REG_80, 0);
}
/* Horizontal GRAM End Address */
LCD_WriteReg(LCD_REG_81, Xpos);
/* Vertical GRAM Start Address */
if(Ypos >= Width)
{
LCD_WriteReg(LCD_REG_82, (Ypos - Width + 1));
}
else
{
LCD_WriteReg(LCD_REG_82, 0);
}
/* Vertical GRAM End Address */
LCD_WriteReg(LCD_REG_83, Ypos);
LCD_SetCursor(Xpos, Ypos);
#endif
}
/**
* @brief Disables LCD Window mode.
* @param None
* @retval None
*/
void LCD_WindowModeDisable(void)
{
#if 0
LCD_SetDisplayWindow(239, 0x13F, 240, 320);
LCD_WriteReg(LCD_REG_3, 0x1018);
#endif
}
/**
* @brief Displays a line.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: line length.
* @param Direction: line direction.
* This parameter can be one of the following values: Vertical or Horizontal.
* @retval None
*/
void LCD_DrawLine(uint8_t Xpos, uint16_t Ypos, uint16_t Length, uint8_t Direction)
{
uint32_t i = 0;
LCD_SetCursor(Xpos, Ypos);
if(Direction == LCD_DIR_HORIZONTAL)
{
LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
for(i = 0; i < Length; i++)
{
LCD_WriteRAM(TextColor);
}
}
else
{
for(i = 0; i < Length; i++)
{
LCD_WriteRAMWord(TextColor);
Xpos++;
LCD_SetCursor(Xpos, Ypos);
}
}
SetCs
}
/**
* @brief Displays a Point.
* @param Color: specifies the Color.
* @retval None
*/
void LCD_SetPoint(uint8_t Xpos, uint16_t Ypos, uint16_t Color)
{
LCD_SetCursor(Xpos, Ypos);
LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
LCD_WriteRAM(Color);
SetCs
}
/**
* @brief Displays a rectangle.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Height: display rectangle height.
* @param Width: display rectangle width.
* @retval None
*/
void LCD_DrawRect(uint8_t Xpos, uint16_t Ypos, uint8_t Height, uint16_t Width)
{
LCD_DrawLine(Xpos, Ypos, Width, LCD_DIR_HORIZONTAL);
LCD_DrawLine((Xpos + Height), Ypos, Width, LCD_DIR_HORIZONTAL);
LCD_DrawLine(Xpos, Ypos, Height, LCD_DIR_VERTICAL);
LCD_DrawLine(Xpos, (Ypos - Width + 1), Height, LCD_DIR_VERTICAL);
}
/**
* @brief Displays a circle.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Radius
* @retval None
*/
void LCD_DrawCircle(uint8_t Xpos, uint16_t Ypos, uint16_t Radius)
{
s32 D;/* Decision Variable */
uint32_t CurX;/* Current X Value */
uint32_t CurY;/* Current Y Value */
D = 3 - (Radius << 1);
CurX = 0;
CurY = Radius;
while (CurX <= CurY)
{
LCD_SetCursor(Xpos + CurX, Ypos + CurY);
LCD_WriteRAMWord(TextColor);
LCD_SetCursor(Xpos + CurX, Ypos - CurY);
LCD_WriteRAMWord(TextColor);
LCD_SetCursor(Xpos - CurX, Ypos + CurY);
LCD_WriteRAMWord(TextColor);
LCD_SetCursor(Xpos - CurX, Ypos - CurY);
LCD_WriteRAMWord(TextColor);
LCD_SetCursor(Xpos + CurY, Ypos + CurX);
LCD_WriteRAMWord(TextColor);
LCD_SetCursor(Xpos + CurY, Ypos - CurX);
LCD_WriteRAMWord(TextColor);
LCD_SetCursor(Xpos - CurY, Ypos + CurX);
LCD_WriteRAMWord(TextColor);
LCD_SetCursor(Xpos - CurY, Ypos - CurX);
LCD_WriteRAMWord(TextColor);
if (D < 0)
{
D += (CurX << 2) + 6;
}
else
{
D += ((CurX - CurY) << 2) + 10;
CurY--;
}
CurX++;
}
}
/**
* @brief Displays a monocolor picture.
* @param Pict: pointer to the picture array.
* @retval None
*/
void LCD_DrawMonoPict(const uint32_t *Pict)
{
uint32_t index = 0, i = 0;
LCD_SetCursor(0, (LCD_PIXEL_WIDTH - 1));
LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
for(index = 0; index < 2400; index++)
{
for(i = 0; i < 32; i++)
{
if((Pict[index] & (1 << i)) == 0x00)
{
LCD_WriteRAM(BackColor);
}
else
{
LCD_WriteRAM(TextColor);
}
}
}
SetCs;
}
#ifdef USE_LCD_DrawBMP
/**
* @brief Displays a bitmap picture loaded in the SPI Flash.
* @param BmpAddress: Bmp picture address in the SPI Flash.
* @retval None
*/
//void LCD_DrawBMP(uint32_t BmpAddress)
//{
// uint32_t i = 0, size = 0;
//
// /* Read bitmap size */
// SPI_FLASH_BufferRead((uint8_t*)&size, BmpAddress + 2, 4);
//
// /* get bitmap data address offset */
// SPI_FLASH_BufferRead((uint8_t*)&i, BmpAddress + 10, 4);
//
// size = (size - i)/2;
//
// SPI_FLASH_StartReadSequence(BmpAddress + i);
//
// /* Disable SPI1 */
// SPI_Cmd(SPI1, DISABLE);
// /* SPI in 16-bit mode */
// SPI_DataSizeConfig(SPI1, SPI_DataSize_16b);
//
// /* Enable SPI1 */
// SPI_Cmd(SPI1, ENABLE);
//
// /* 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(LCD_REG_3, 0x1008);
//
// LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
//
// /* Read bitmap data from SPI Flash and send them to LCD */
// for(i = 0; i < size; i++)
// {
// LCD_WriteRAM(__REV_HalfWord(SPI_FLASH_SendHalfWord(0xA5A5)));
// }
//
// LCD_CtrlLinesWrite(LCD_NCS_GPIO_PORT, LCD_NCS_PIN, Bit_SET);
//
// /* Deselect the FLASH: Chip Select high */
// SPI_FLASH_CS_HIGH();
//
// /* Disable SPI1 */
// SPI_Cmd(SPI1, DISABLE);
// /* SPI in 8-bit mode */
// SPI_DataSizeConfig(SPI1, SPI_DataSize_8b);
//
// /* Enable SPI1 */
// SPI_Cmd(SPI1, ENABLE);
//
// /* Set GRAM write direction and BGR = 1 */
// /* I/D = 01 (Horizontal : increment, Vertical : decrement) */
// /* AM = 1 (address is updated in vertical writing direction) */
// LCD_WriteReg(LCD_REG_3, 0x1018);
//}
/**
* @brief Displays a bitmap picture loaded in the SPI Flash.
* @param BmpAddress: Bmp picture address in the SPI Flash.
* @retval None
*/
void LCD_DrawBMP(const uint16_t *BmpAddress)
{
uint32_t i = 0, size = 0;
/* Read bitmap size */
size = BmpAddress[1] | (BmpAddress[2] << 16);
/* get bitmap data address offset */
i = BmpAddress[5] | (BmpAddress[6] << 16);
size = (size - i)/2;
BmpAddress += i/2;
/* 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(LCD_REG_3, 0x1008);
LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
/* Read bitmap data from SPI Flash and send them to LCD */
for(i = 0; i < size; i++)
{
LCD_WriteRAM(BmpAddress[i]);
}
LCD_CtrlLinesWrite(LCD_NCS_GPIO_PORT, LCD_NCS_PIN, Bit_SET);
/* Set GRAM write direction and BGR = 1 */
/* I/D = 01 (Horizontal : increment, Vertical : decrement) */
/* AM = 1 (address is updated in vertical writing direction) */
LCD_WriteReg(LCD_REG_3, 0x1018);
}
#endif
/**
* @brief Displays a full rectangle.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Height: rectangle height.
* @param Width: rectangle width.
* @retval None
*/
void LCD_DrawFullRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
{
LCD_SetTextColor(TextColor);
LCD_DrawLine(Xpos, Ypos, Width, LCD_DIR_HORIZONTAL);
LCD_DrawLine((Xpos + Height), Ypos, Width, LCD_DIR_HORIZONTAL);
LCD_DrawLine(Xpos, Ypos, Height, LCD_DIR_VERTICAL);
LCD_DrawLine(Xpos, (Ypos - Width + 1), Height, LCD_DIR_VERTICAL);
Width -= 2;
Height--;
Ypos--;
LCD_SetTextColor(BackColor);
while(Height--)
{
LCD_DrawLine(++Xpos, Ypos, Width, LCD_DIR_HORIZONTAL);
}
LCD_SetTextColor(TextColor);
}
/**
* @brief Displays a full circle.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Radius
* @retval None
*/
void LCD_DrawFullCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius)
{
int32_t D; /* Decision Variable */
uint32_t CurX;/* Current X Value */
uint32_t CurY;/* Current Y Value */
D = 3 - (Radius << 1);
CurX = 0;
CurY = Radius;
LCD_SetTextColor(BackColor);
while (CurX <= CurY)
{
if(CurY > 0)
{
LCD_DrawLine(Xpos - CurX, Ypos + CurY, 2*CurY, LCD_DIR_HORIZONTAL);
LCD_DrawLine(Xpos + CurX, Ypos + CurY, 2*CurY, LCD_DIR_HORIZONTAL);
}
if(CurX > 0)
{
LCD_DrawLine(Xpos - CurY, Ypos + CurX, 2*CurX, LCD_DIR_HORIZONTAL);
LCD_DrawLine(Xpos + CurY, Ypos + CurX, 2*CurX, LCD_DIR_HORIZONTAL);
}
if (D < 0)
{
D += (CurX << 2) + 6;
}
else
{
D += ((CurX - CurY) << 2) + 10;
CurY--;
}
CurX++;
}
LCD_SetTextColor(TextColor);
LCD_DrawCircle(Xpos, Ypos, Radius);
}
/**
* @brief Displays an uni line (between two points).
* @param x1: specifies the point 1 x position.
* @param y1: specifies the point 1 y position.
* @param x2: specifies the point 2 x position.
* @param y2: specifies the point 2 y position.
* @retval None
*/
void LCD_DrawUniLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
{
int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0,
yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0,
curpixel = 0;
deltax = ABS(x2 - x1); /* The difference between the x's */
deltay = ABS(y2 - y1); /* The difference between the y's */
x = x1; /* Start x off at the first pixel */
y = y1; /* Start y off at the first pixel */
if (x2 >= x1) /* The x-values are increasing */
{
xinc1 = 1;
xinc2 = 1;
}
else /* The x-values are decreasing */
{
xinc1 = -1;
xinc2 = -1;
}
if (y2 >= y1) /* The y-values are increasing */
{
yinc1 = 1;
yinc2 = 1;
}
else /* The y-values are decreasing */
{
yinc1 = -1;
yinc2 = -1;
}
if (deltax >= deltay) /* There is at least one x-value for every y-value */
{
xinc1 = 0; /* Don't change the x when numerator >= denominator */
yinc2 = 0; /* Don't change the y for every iteration */
den = deltax;
num = deltax / 2;
numadd = deltay;
numpixels = deltax; /* There are more x-values than y-values */
}
else /* There is at least one y-value for every x-value */
{
xinc2 = 0; /* Don't change the x for every iteration */
yinc1 = 0; /* Don't change the y when numerator >= denominator */
den = deltay;
num = deltay / 2;
numadd = deltax;
numpixels = deltay; /* There are more y-values than x-values */
}
for (curpixel = 0; curpixel <= numpixels; curpixel++)
{
PutPixel(x, y); /* Draw the current pixel */
num += numadd; /* Increase the numerator by the top of the fraction */
if (num >= den) /* Check if numerator >= denominator */
{
num -= den; /* Calculate the new numerator value */
x += xinc1; /* Change the x as appropriate */
y += yinc1; /* Change the y as appropriate */
}
x += xinc2; /* Change the x as appropriate */
y += yinc2; /* Change the y as appropriate */
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -