原创 STM32用I/O模拟,驱动2.8寸TFT屏(有MDK源程序和图)

2008-8-17 01:15 7736 10 14 分类: MCU/ 嵌入式

/*使用液晶:2.8寸 DriverIC HX8347 240*320 65536色16bit-------*/


/*在原ST官方例程基础上,更改出来的例程-------*/



/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "fonts.h"


/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/


#define START_BYTE  0x70
#define SET_INDEX   0x00
#define READ_STATUS 0x01
#define WRITE_REG   0x02
#define READ_REG    0x03



/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
  /* Global variables to set the written text color */
static  vu16 TextColor = 0x0000, BackColor = 0xFFFF;


/* Private function prototypes -----------------------------------------------*/


/*******************************************************************************
* Function Name  : STM3210B_LCD_Init
* Description    : Initializes the LCD.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void STM3210E_LCD_Init(void)
{
  /* Setups the LCD */
 /* Configure the LCD Control pins --------------------------------------------*/
  LCD_CtrlLinesConfig();
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_RST, Bit_RESET);
  Delay(5); /* delay 50 ms */
    LCD_CtrlLinesWrite(GPIOB, CtrlPin_RST, Bit_SET);
  Delay(5); /* delay 50 ms */
/* Start Initial Sequence ----------------------------------------------------*/
    
    // Gamma for CMO 3.2”
    LCD_WriteReg(0x46,0x94);
    LCD_WriteReg(0x47,0x41);
    LCD_WriteReg(0x48,0x00);
    LCD_WriteReg(0x49,0x33);
    LCD_WriteReg(0x4a,0x23);
    LCD_WriteReg(0x4b,0x45);
    LCD_WriteReg(0x4c,0x44);
    LCD_WriteReg(0x4d,0x77);
    LCD_WriteReg(0x4e,0x12);
    LCD_WriteReg(0x4f,0xcc);
    LCD_WriteReg(0x50,0x46);
    LCD_WriteReg(0x51,0x82);
 
    //240x320 window setting
    LCD_WriteReg(0x02,0x00);
 LCD_WriteReg(0x03,0x00);
  LCD_WriteReg(0x04,0x01);
  LCD_WriteReg(0x05,0x3f);
  LCD_WriteReg(0x06,0x00);
  LCD_WriteReg(0x07,0x00);
  LCD_WriteReg(0x08,0x00);
  LCD_WriteReg(0x09,0xef);


 // Display Setting
 LCD_WriteReg(0x01,0x06);
 LCD_WriteReg(0x16,0xA8);
 LCD_WriteReg(0x23,0x95);
 LCD_WriteReg(0x24,0x95);
 LCD_WriteReg(0x25,0xff);


 LCD_WriteReg(0x27,0x02);
 LCD_WriteReg(0x28,0x02);
 LCD_WriteReg(0x29,0x02);
 LCD_WriteReg(0x2a,0x02);
 LCD_WriteReg(0x2c,0x02);
 LCD_WriteReg(0x2d,0x02);      


 LCD_WriteReg(0x3a,0x01);///*******************
 LCD_WriteReg(0x3b,0x01);
 LCD_WriteReg(0x3c,0xf0);
 LCD_WriteReg(0x3d,0x00);


 Delay(2);


 LCD_WriteReg(0x35,0x38);
 LCD_WriteReg(0x36,0x78);


 LCD_WriteReg(0x3e,0x38);


 LCD_WriteReg(0x40,0x0f);
 LCD_WriteReg(0x41,0xf0);
   
 // Power Supply Setting
 LCD_WriteReg(0x19,0x49);//********
 LCD_WriteReg(0x93,0x0f);//*******


 Delay(1);


 LCD_WriteReg(0x20,0x30);
 LCD_WriteReg(0x1d,0x07);
 LCD_WriteReg(0x1e,0x00);
 LCD_WriteReg(0x1f,0x07);


 // VCOM Setting for CMO 3.2” Panel
  LCD_WriteReg(0x44,0x3c);//4d***************4f
    LCD_WriteReg(0x45,0x00);//0x0a);
    Delay(1);
    LCD_WriteReg(0x1c,0x04);
    Delay(2);
    LCD_WriteReg(0x43,0x80);
    Delay(5);
    LCD_WriteReg(0x1b,0x08);
    Delay(4);
    LCD_WriteReg(0x1b,0x10);   
    Delay(4);


    // Display ON Setting
 LCD_WriteReg(0x90,0x7f);
    LCD_WriteReg(0x26,0x04);
    Delay(4);
    LCD_WriteReg(0x26,0x24);
    LCD_WriteReg(0x26,0x2c);
    Delay(4);
    LCD_WriteReg(0x26,0x3c);


    // Set internal VDDD voltage
 LCD_WriteReg(0x57,0x02);
    LCD_WriteReg(0x55,0x00);
    LCD_WriteReg(0x57,0x00);


}


/*******************************************************************************
* Function Name  : LCD_SetTextColor
* Description    : Sets the Text color.
* Input          : - Color: specifies the Text color code RGB(5-6-5).
* Output         : - TextColor: Text color global variable used by LCD_DrawChar
*                  and LCD_DrawPicture functions.
* Return         : None
*******************************************************************************/
void LCD_SetTextColor(vu16 Color)
{
  TextColor = Color;
}


/*******************************************************************************
* Function Name  : LCD_SetBackColor
* Description    : Sets the Background color.
* Input          : - Color: specifies the Background color code RGB(5-6-5).
* Output         : - BackColor: Background color global variable used by
*                  LCD_DrawChar and LCD_DrawPicture functions.
* Return         : None
*******************************************************************************/
void LCD_SetBackColor(vu16 Color)
{
  BackColor = Color;
}


/*******************************************************************************
* Function Name  : LCD_ClearLine
* Description    : Clears the selected line.
* Input          : - Line: the Line to be cleared.
*                    This parameter can be one of the following values:
*                       - Linex: where x can be 0..9
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_ClearLine(u8 Line)
{
  LCD_DisplayStringLine(Line, "                    ");
}


/*******************************************************************************
* Function Name  : LCD_Clear
* Description    : Clears the hole LCD.
* Input          : Color: the color of the background.
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_Clear(u16 Color)
{
 u32 index = 0;
 
  LCD_SetCursor(0x00, 0x000);


  LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */


  for(index = 0; index < 76800; index++)
  {
   LCD_WriteRAM(Color);
  }
}


/*******************************************************************************
* Function Name  : LCD_SetCursor
* Description    : Sets the cursor position.
* Input          : - Xpos: specifies the X position.
*                  - Ypos: specifies the Y position.
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_SetCursor(u8 Xpos, u16 Ypos)
{
  LCD_WriteReg(0x02,(Ypos&0xff00)>>8);
  LCD_WriteReg(0x03,Ypos&0x00ff);
 
   LCD_WriteReg(0x06, (Xpos &0xff00)>>8);
   LCD_WriteReg(0x07, Xpos &0x00ff);
}


/*******************************************************************************
* Function Name  : LCD_DrawChar
* Description    : Draws a character on LCD.
* Input          : - Xpos: the Line where to display the character shape.
*                    This parameter can be one of the following values:
*                       - Linex: where x can be 0..9
*                  - Ypos: start column address.
*                  - c: pointer to the character data.
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_DrawChar(u8 Xpos, u16 Ypos, uc16 *c)
{
    u32 index = 0, i = 0;
  u8 Xaddress = 0;
  
  Xaddress = Xpos;
 
  LCD_SetCursor(Xaddress, Ypos);
 
  for(index = 0; index < 24; index++)
  {
    LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
    for(i = 0; i < 16; i++)
    {
      if((c[index] & (1 << i)) == 0x00)
      {
        LCD_WriteRAM(BackColor);
      }
      else
      {
        LCD_WriteRAM(TextColor);
      }
    }
    Xaddress++;
    LCD_SetCursor(Xaddress, Ypos);
  }
}


/*******************************************************************************
* Function Name  : LCD_DisplayChar
* Description    : Displays one character (16dots width, 24dots height).
* Input          : - Line: the Line where to display the character shape .
*                    This parameter can be one of the following values:
*                       - Linex: where x can be 0..9
*                  - Column: start column address.
*                  - Ascii: character ascii code, must be between 0x20 and 0x7E.
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_DisplayChar(u8 Line, u16 Column, u8 Ascii)
{
  Ascii -= 32;
  LCD_DrawChar(Line, Column, &ASCII_Table[Ascii * 24]);
}


/*******************************************************************************
* Function Name  : LCD_DisplayStringLine
* Description    : Displays a maximum of 20 char on the LCD.
* Input          : - Line: the Line where to display the character shape .
*                    This parameter can be one of the following values:
*                       - Linex: where x can be 0..9
*                  - *ptr: pointer to string to display on LCD.
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_DisplayStringLine(u8 Line, u8 *ptr)
{
  u32 i = 0;
  u16 refcolumn = 0;


  /* Send the string character by character on lCD */
  while ((*ptr != 0) & (i < 20))
  {
    /* Display one character on LCD */
    LCD_DisplayChar(Line, refcolumn, *ptr);
    /* Decrement the column position by 16 */
    refcolumn += 16;
    /* Point on the next character */
    ptr++;
    /* Increment the character counter */
    i++;
  }
}


/*******************************************************************************
* Function Name  : LCD_SetDisplayWindow
* Description    : Sets a display window
* Input          : - Xpos: specifies the X buttom left position.
*                  - Ypos: specifies the Y buttom left position.
*                  - Height: display window height.
*                  - Width: display window width.
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_SetDisplayWindow(u8 Xpos, u16 Ypos, u8 Height, u16 Width)
{
  /* Horizontal GRAM Start Address */
  if(Xpos >= Height)
  {
  LCD_WriteReg(0x02,((Ypos - Height + 1)&0xff00)>>8);
  LCD_WriteReg(0x03,(Ypos - Height + 1)&0x00ff);
  }
  else
  {
   LCD_WriteReg(0x02,0x00);
   LCD_WriteReg(0x03,0x00);
  }
  /* Horizontal GRAM End Address */
  LCD_WriteReg(0x04,(Ypos&0xff00)>>8);
  LCD_WriteReg(0x05,Ypos&0x00ff);
  /* Vertical GRAM Start Address */
  if(Ypos >= Width)
  {
   LCD_WriteReg(0x06, ((Xpos - Width + 1)&0xff00)>>8);
   LCD_WriteReg(0x07, (Xpos - Width + 1)&0x00ff);
  } 
  else
  {
   LCD_WriteReg(0x06, 0x00);
   LCD_WriteReg(0x07, 0x00);
  }
  /* Vertical GRAM End Address */
   LCD_WriteReg(0x08, (Xpos &0xff00)>>8);
   LCD_WriteReg(0x09, Xpos &0x00ff);
}


/*******************************************************************************
* Function Name  : LCD_WindowModeDisable
* Description    : Disables LCD Window mode.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_WindowModeDisable(void)
{
  LCD_SetDisplayWindow(239, 0x13F, 240, 320);
}
/*******************************************************************************
* Function Name  : LCD_DrawLine
* Description    : Displays a line.
* Input          : - Xpos: specifies the X position.
*                  - Ypos: specifies the Y position.
*                  - Length: line length.
*                  - Direction: line direction.
*                    This parameter can be one of the following values: Vertical
*                    or Horizontal.
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_DrawLine(u8 Xpos, u16 Ypos, u16 Length, u8 Direction)
{
  u32 i = 0;
 
  LCD_SetCursor(Xpos, Ypos);


  if(Direction == 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_WriteRAM_Prepare(); /* Prepare to write GRAM */
      LCD_WriteRAM(TextColor);
      Xpos++;
      LCD_SetCursor(Xpos, Ypos);
    }
  }
}


/*******************************************************************************
* Function Name  : LCD_DrawRect
* Description    : Displays a rectangle.
* Input          : - Xpos: specifies the X position.
*                  - Ypos: specifies the Y position.
*                  - Height: display rectangle height.
*                  - Width: display rectangle width.
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_DrawRect(u8 Xpos, u16 Ypos, u8 Height, u16 Width)
{
  LCD_DrawLine(Xpos, Ypos, Width, Horizontal);
  LCD_DrawLine((Xpos + Height), Ypos, Width, Horizontal);
 
  LCD_DrawLine(Xpos, Ypos, Height, Vertical);
  LCD_DrawLine(Xpos, (Ypos + Width -1), Height, Vertical);
}


/*******************************************************************************
* Function Name  : LCD_DrawCircle
* Description    : Displays a circle.
* Input          : - Xpos: specifies the X position.
*                  - Ypos: specifies the Y position.
*                  - Height: display rectangle height.
*                  - Width: display rectangle width.
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_DrawCircle(u8 Xpos, u16 Ypos, u16 Radius)
{
   s32  D;/* Decision Variable */
  u32  CurX;/* Current X Value */
  u32  CurY;/* Current Y Value */
 
  D = 3 - (Radius << 1);
  CurX = 0;
  CurY = Radius;
 
  while (CurX <= CurY)
  {
    LCD_SetCursor(Xpos + CurX, Ypos + CurY);
    LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
    LCD_WriteRAM(TextColor);


    LCD_SetCursor(Xpos + CurX, Ypos - CurY);
    LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
    LCD_WriteRAM(TextColor);


    LCD_SetCursor(Xpos - CurX, Ypos + CurY);
    LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
    LCD_WriteRAM(TextColor);


    LCD_SetCursor(Xpos - CurX, Ypos - CurY);
    LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
    LCD_WriteRAM(TextColor);


    LCD_SetCursor(Xpos + CurY, Ypos + CurX);
    LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
    LCD_WriteRAM(TextColor);


    LCD_SetCursor(Xpos + CurY, Ypos - CurX);
    LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
    LCD_WriteRAM(TextColor);


    LCD_SetCursor(Xpos - CurY, Ypos + CurX);
    LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
    LCD_WriteRAM(TextColor);


    LCD_SetCursor(Xpos - CurY, Ypos - CurX);
    LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
    LCD_WriteRAM(TextColor);


    if (D < 0)
    {
      D += (CurX << 2) + 6;
    }
    else
    {
      D += ((CurX - CurY) << 2) + 10;
      CurY--;
    }
    CurX++;
  }
}


/*******************************************************************************
* Function Name  : LCD_DrawMonoPict
* Description    : Displays a monocolor picture.
* Input          : - Pict: pointer to the picture array.
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_DrawMonoPict(uc32 *Pict)
{
  u32 index = 0, i = 0;


  LCD_SetCursor(0, 319);


  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);
      }
    }
  }
}


/*******************************************************************************
* Function Name  : LCD_DrawBMP
* Description    : Displays a bitmap picture loaded in the SPI Flash.
* Input          : - BmpAddress: Bmp picture address in the SPI Flash.
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_WriteBMP(u32 BmpAddress)
{
   u32 index = 0, size = 0;


  /* Read bitmap size */
  size = *(vu16 *) (BmpAddress + 2);
  size |= (*(vu16 *) (BmpAddress + 4)) << 16;


  /* Get bitmap data address offset */
  index = *(vu16 *) (BmpAddress + 10);
  index |= (*(vu16 *) (BmpAddress + 12)) << 16;


  size = (size - index)/2;


  BmpAddress += index;



  LCD_WriteRAM_Prepare();
 
  for(index = 0; index < size; index++)
  {
    LCD_WriteRAM(*(vu16 *)BmpAddress);
    BmpAddress += 2;
  }
 


}


/*******************************************************************************
* Function Name  : LCD_WriteRegIndex
* Description    : Writes index to select the LCD register.
* Input          : - LCD_Reg: address of the selected register.
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_WriteRegIndex(u8 LCD_reg)
{
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_RS, Bit_RESET);
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NCS, Bit_RESET);
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NWR, Bit_RESET);
  GPIOA->ODR=(u16)LCD_reg;
   LCD_CtrlLinesWrite(GPIOB, CtrlPin_NWR, Bit_SET);
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NCS, Bit_SET);
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_RS, Bit_SET);
}


/*******************************************************************************
* Function Name  : LCD_WriteRAM_Prepare
* Description    : Prepare to write to the LCD RAM.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_WriteRAM_Prepare(void)
{
  LCD_WriteRegIndex(R34); /* Select GRAM Reg */


}


/*******************************************************************************
* Function Name  : LCD_WriteReg
* Description    : Writes to the selected LCD register.
* Input          : - LCD_Reg: address of the selected register.
*                  - LCD_RegValue: value to write to the selected register.
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_WriteReg(u8 LCD_Reg, u16 LCD_RegValue)
{
  LCD_WriteRegIndex(LCD_Reg);
  LCD_WriteRAM(LCD_RegValue);
}



/*******************************************************************************
* Function Name  : LCD_WriteRAM
* Description    : Writes to the LCD RAM.
* Input          : - RGB_Code: the pixel color in RGB mode (5-6-5).
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_WriteRAM(u16 RGB_Code)
{
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NCS, Bit_RESET);
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NWR, Bit_RESET);
  GPIOA->ODR=RGB_Code;
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NWR, Bit_SET);
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NCS, Bit_SET);


}


/*******************************************************************************
* Function Name  : LCD_PowerOn
* Description    : Power on the LCD.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_PowerOn(void)
{
  // Power Supply Setting
 LCD_WriteReg(0x19,0x49);//********
 LCD_WriteReg(0x93,0x0a);//*******


 Delay(1);


 LCD_WriteReg(0x20,0x40);
 LCD_WriteReg(0x1d,0x07);
 LCD_WriteReg(0x1e,0x00);
 LCD_WriteReg(0x1f,0x04);


 // VCOM Setting for CMO 3.2” Panel
  LCD_WriteReg(0x44,0x4d);//4d***************4f
    LCD_WriteReg(0x45,0x11);
    Delay(1);
    LCD_WriteReg(0x1c,0x04);
    Delay(2);
    LCD_WriteReg(0x43,0x80);
    Delay(5);
    LCD_WriteReg(0x1b,0x08);
    Delay(4);
    LCD_WriteReg(0x1b,0x10);
    Delay(4);


    // Display ON Setting
 LCD_WriteReg(0x90,0x7f);
    LCD_WriteReg(0x26,0x04);
    Delay(4);
    LCD_WriteReg(0x26,0x24);
    LCD_WriteReg(0x26,0x2c);
    Delay(4);
    LCD_WriteReg(0x26,0x3c);


    // Set internal VDDD voltage
 LCD_WriteReg(0x57,0x02);
    LCD_WriteReg(0x55,0x00);
    LCD_WriteReg(0x57,0x00);
}


/*******************************************************************************
* Function Name  : LCD_DisplayOn
* Description    : Enables the Display.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_DisplayOn(void)
{
  /* Display On */
  LCD_WriteReg(0x26, 0x3C); /* 262K color and display ON */
}


/*******************************************************************************
* Function Name  : LCD_DisplayOff
* Description    : Disables the Display.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_DisplayOff(void)
{
  /* Display Off */
  LCD_WriteReg(0x26, 0x0);
}



/*******************************************************************************
* Function Name  : LCD_CtrlLinesConfig
* Description    : Configures LCD control lines in Output Push-Pull mode.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_CtrlLinesConfig(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;


 GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);


    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_Init(GPIOA, &GPIO_InitStructure);    // GPIOA LCD Data Port
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6;
 GPIO_Init(GPIOB, &GPIO_InitStructure);


  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NRD, Bit_SET);
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NWR, Bit_SET);
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_RS, Bit_SET);
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_NCS, Bit_SET);
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_IM0, Bit_RESET);
  LCD_CtrlLinesWrite(GPIOB, CtrlPin_IM3, Bit_RESET);
}


/*******************************************************************************
* Function Name  : LCD_CtrlLinesWrite
* Description    : Sets or reset LCD control lines.
* Input          : - GPIOx: where x can be B or D to select the GPIO peripheral.
*                  - CtrlPins: the Control line. This parameter can be:
*                       - CtrlPin_NCS: Chip Select pin (PB.02)
*                       - CtrlPin_NWR: Read/Write Selection pin (PD.15)
*                       - CtrlPin_RS: Register/RAM Selection pin (PD.07)
*                  - BitVal: specifies the value to be written to the selected bit.
*                    This parameter can be:
*                       - Bit_RESET: to clear the port pin
*                       - Bit_SET: to set the port pin
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_CtrlLinesWrite(GPIO_TypeDef* GPIOx, u16 CtrlPins, BitAction BitVal)
{
  /* Set or Reset the control line */
  GPIO_WriteBit(GPIOx, CtrlPins, BitVal);
}


void LCD_DisplyDemo(void)
{
 LCD_SetBackColor(Blue);


    /* Set the LCD Text Color */
    LCD_SetTextColor(White);   
    LCD_DisplayStringLine(Line0, "    Hello Word !    ");
 LCD_DisplayStringLine(Line1, "                    ");
    LCD_DisplayStringLine(Line2, "This's a TFT2.8` LCD");
 LCD_DisplayStringLine(Line3, "demo program with   ");
 LCD_DisplayStringLine(Line4, "MINI-STM32 bord use ");
    LCD_DisplayStringLine(Line5, "STM32F103C8T6 MCU . ");
    LCD_DisplayStringLine(Line6, "                    ");
 LCD_DisplayStringLine(Line7, "Chongqing U_EASYTECH");
    LCD_DisplayStringLine(Line8, "electronic company .");
    LCD_DisplayStringLine(Line9, " www.u-easytech.com ");
   
   
  
 LCD_SetTextColor(Red);
 LCD_DrawCircle(119, 159, 100);
 LCD_SetTextColor(Yellow);
    LCD_DrawLine(19, 159, 100, 1);
 LCD_DrawLine(119, 59, 100, 0);
 LCD_SetTextColor(Green);
 LCD_DrawRect(69, 59, 100, 200);
}


 


点击看大图


 


点击下载文件内包括:STM32用I/O模拟驱动2.8寸TFT屏的MDK 源程序,STM32应用板图,效果图

PARTNER CONTENT

文章评论4条评论)

登录后参与讨论

用户403686 2012-3-18 12:04

我在网上可以找到很多类似的程序,我用ST、NXP、51的芯片各种FSMC、模拟的方式都驱动过,写数据一般没问题,但是,读像素小的颜色值一直读不出来,请问您有什么好方法不???

用户214051 2010-7-27 19:27

看看!!!!

用户783134 2008-10-1 01:16

用I/O模拟 PA\PB

用户1483518 2008-9-24 17:21

与SMT32的接口是如何的?
相关推荐阅读
用户783134 2008-08-24 12:32
如何用ulink调试超过128K flash的STM32(MDK3.22a)
ulink是个好东西,在MDK3.22a中调试128K以内的STM32网上都有很多办法了,但是不知有朋友用来调试C/D/E系列了吗?<?xml:namespace prefix = o ns =...
用户783134 2008-08-21 22:28
STM32的I2C 调试 24C01/2402/240x等EEPROM 经验
各位学习STM32的朋友们,不知你们在调试STM32的 I2C  EEPROM时是否遇到问题,比如:1\写入n字节,再读出n字节,但读出结果发现部分不正确2\不能写了后马上读出来,3\读不出来数据第一...
用户783134 2008-08-17 00:51
STM32用PWM实现DA的电路图
用PWM实现DA功能的原理图。基本原理:运放+RC滤波...
EE直播间
更多
我要评论
4
10
关闭 站长推荐上一条 /3 下一条