⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stm3210c_eval_lcd.c

📁 LWIP在STM32裸机上的移植
💻 C
📖 第 1 页 / 共 4 页
字号:
		 LCD_WriteReg(0x07,0x0033);
	}
	else if(DeviceIdCode==0x1505)
	{
        // second release on 3/5  ,luminance is acceptable,water wave appear during camera preview
        LCD_WriteReg(0x0007,0x0000);
        delay(2);
        LCD_WriteReg(0x0012,0x011C);//0x011A   why need to set several times?
        LCD_WriteReg(0x00A4,0x0001);//NVM
        LCD_WriteReg(0x0008,0x000F);
        LCD_WriteReg(0x000A,0x0008);
        LCD_WriteReg(0x000D,0x0008);
       
        //GAMMA CONTROL/
        LCD_WriteReg(0x0030,0x0707);
        LCD_WriteReg(0x0031,0x0007); //0x0707
        LCD_WriteReg(0x0032,0x0603); 
        LCD_WriteReg(0x0033,0x0700); 
        LCD_WriteReg(0x0034,0x0202); 
        LCD_WriteReg(0x0035,0x0002); //?0x0606
        LCD_WriteReg(0x0036,0x1F0F);
        LCD_WriteReg(0x0037,0x0707); //0x0f0f  0x0105
        LCD_WriteReg(0x0038,0x0000); 
        LCD_WriteReg(0x0039,0x0000); 
        LCD_WriteReg(0x003A,0x0707); 
        LCD_WriteReg(0x003B,0x0000); //0x0303
        LCD_WriteReg(0x003C,0x0007); //?0x0707
        LCD_WriteReg(0x003D,0x0000); //0x1313//0x1f08
        delay(2);
        LCD_WriteReg(0x0007,0x0001);
        LCD_WriteReg(0x0017,0x0001);   //Power supply startup enable
        delay(2);
  
        //power control//
        LCD_WriteReg(0x0010,0x17A0); 
        LCD_WriteReg(0x0011,0x0217); //reference voltage VC[2:0]   Vciout = 1.00*Vcivl
        LCD_WriteReg(0x0012,0x011E);//0x011c  //Vreg1out = Vcilvl*1.80   is it the same as Vgama1out ?
        LCD_WriteReg(0x0013,0x0F00); //VDV[4:0]-->VCOM Amplitude VcomL = VcomH - Vcom Ampl
        LCD_WriteReg(0x002A,0x0000);  
        LCD_WriteReg(0x0029,0x000A); //0x0001F  Vcomh = VCM1[4:0]*Vreg1out    gate source voltage??
        LCD_WriteReg(0x0012,0x013E); // 0x013C  power supply on
           //Coordinates Control//
        LCD_WriteReg(0x0050,0x0000);//0x0e00
        LCD_WriteReg(0x0051,0x00EF); 
        LCD_WriteReg(0x0052,0x0000); 
        LCD_WriteReg(0x0053,0x013F); 
        //Pannel Image Control//
        LCD_WriteReg(0x0060,0x2700); 
        LCD_WriteReg(0x0061,0x0001); 
        LCD_WriteReg(0x006A,0x0000); 
        LCD_WriteReg(0x0080,0x0000); 
        //Partial Image Control//
        LCD_WriteReg(0x0081,0x0000); 
        LCD_WriteReg(0x0082,0x0000); 
        LCD_WriteReg(0x0083,0x0000); 
        LCD_WriteReg(0x0084,0x0000); 
        LCD_WriteReg(0x0085,0x0000); 
        //Panel Interface Control//
        LCD_WriteReg(0x0090,0x0013); //0x0010 frenqucy
        LCD_WriteReg(0x0092,0x0300); 
        LCD_WriteReg(0x0093,0x0005); 
        LCD_WriteReg(0x0095,0x0000); 
        LCD_WriteReg(0x0097,0x0000); 
        LCD_WriteReg(0x0098,0x0000); 
  
        LCD_WriteReg(0x0001,0x0100); 
        LCD_WriteReg(0x0002,0x0700); 
        LCD_WriteReg(0x0003,0x1018); //        LCD_WriteReg(0x0003,0x1030); 
        LCD_WriteReg(0x0004,0x0000); 
        LCD_WriteReg(0x000C,0x0000); 
        LCD_WriteReg(0x000F,0x0000); 
        LCD_WriteReg(0x0020,0x0000); 
        LCD_WriteReg(0x0021,0x0000); 
        LCD_WriteReg(0x0007,0x0021); 
        delay(2);
        LCD_WriteReg(0x0007,0x0061); 
        delay(2);
        LCD_WriteReg(0x0007,0x0173); 
        delay(2);
	}							 
	else if(DeviceIdCode==0x8989)
	{
	    LCD_WriteReg(0x0000,0x0001);		//打开晶振
	    LCD_WriteReg(0x0003,0xA8A4);		//0xA8A4
	    LCD_WriteReg(0x000C,0x0000);        
	    LCD_WriteReg(0x000D,0x080C);        
	    LCD_WriteReg(0x000E,0x2B00);        
	    LCD_WriteReg(0x001E,0x00B0);        
	    LCD_WriteReg(0x0001,0x293F);		//驱动输出控制320*240  0x693F  0x2B3F 0x293F
	    LCD_WriteReg(0x0002,0x0600);     	//LCD Driving Waveform control
	    LCD_WriteReg(0x0010,0x0000);     
	    LCD_WriteReg(0x0011,0x6078);		//0x4030	//定义数据格式  16位色 0x6070	横屏 0x6058
	    LCD_WriteReg(0x0005,0x0000);     
	    LCD_WriteReg(0x0006,0x0000);     
	    LCD_WriteReg(0x0016,0xEF1C);     
	    LCD_WriteReg(0x0017,0x0003);     
	    LCD_WriteReg(0x0007,0x0233);		//0x0233       
	    LCD_WriteReg(0x000B,0x0000);     
	    LCD_WriteReg(0x000F,0x0000);		//扫描开始地址
	    LCD_WriteReg(0x0041,0x0000);     
	    LCD_WriteReg(0x0042,0x0000);     
	    LCD_WriteReg(0x0048,0x0000);     
	    LCD_WriteReg(0x0049,0x013F);     
	    LCD_WriteReg(0x004A,0x0000);     
	    LCD_WriteReg(0x004B,0x0000);     
	    LCD_WriteReg(0x0044,0xEF00);     
	    LCD_WriteReg(0x0045,0x0000);     
	    LCD_WriteReg(0x0046,0x013F);     
	    LCD_WriteReg(0x0030,0x0707);     
	    LCD_WriteReg(0x0031,0x0204);     
	    LCD_WriteReg(0x0032,0x0204);     
	    LCD_WriteReg(0x0033,0x0502);     
	    LCD_WriteReg(0x0034,0x0507);     
	    LCD_WriteReg(0x0035,0x0204);     
	    LCD_WriteReg(0x0036,0x0204);     
	    LCD_WriteReg(0x0037,0x0502);     
	    LCD_WriteReg(0x003A,0x0302);     
	    LCD_WriteReg(0x003B,0x0302);     
	    LCD_WriteReg(0x0023,0x0000);     
	    LCD_WriteReg(0x0024,0x0000);     
	    LCD_WriteReg(0x0025,0x8000);     
	    LCD_WriteReg(0x004e,0);        //列(X)首址0
	    LCD_WriteReg(0x004f,0);        //行(Y)首址0
	}
    else
    {
       printf("\n\r ###### Err: Unknow DeviceIdCode 0x%x ###### ", DeviceIdCode);
    }

    delay(1);

    LCD_Clear(LCD_COLOR_GREEN);

    LCD_SetTextColor(LCD_COLOR_YELLOW);
    LCD_SetBackColor(LCD_COLOR_RED);
    
    LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *)str);          // www.shuangln.com
    LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)Devicestr);    //LCD Driver ID:9320
    LCD_DisplayWelcomeStr(LCD_LINE_2);
/*
    for (i=0;i<len;i++)
    {
        LCD_DisplayChar(LCD_LINE_1, 100,str[i]);
    }
*/
    delay(80);
   // LCD_Clear(LCD_COLOR_BLACK);
}


/**
  * @brief  Initializes the LCD.
  * @param  None
  * @retval None
  */
void STM3210C_LCD_Init(void)
{
  LCD_SetFont(&LCD_DEFAULT_FONT);
  /* Setups the LCD */
  LCD_Setup();
}

/**
  * @brief  Sets the LCD Text and Background colors.
  * @param  _TextColor: specifies the Text Color.
  * @param  _BackColor: specifies the Background Color.
  * @retval None
  */
void LCD_SetColors(__IO uint16_t _TextColor, __IO uint16_t _BackColor)
{
  TextColor = _TextColor; 
  BackColor = _BackColor;
}

/**
  * @brief  Gets the LCD Text and Background colors.
  * @param  _TextColor: pointer to the variable that will contain the Text 
            Color.
  * @param  _BackColor: pointer to the variable that will contain the Background 
            Color.
  * @retval None
  */
void LCD_GetColors(__IO uint16_t *_TextColor, __IO uint16_t *_BackColor)
{
  *_TextColor = TextColor; *_BackColor = BackColor;
}

/**
  * @brief  Sets the Text color.
  * @param  Color: specifies the Text color code RGB(5-6-5).
  * @retval None
  */
void LCD_SetTextColor(__IO uint16_t Color)
{
  TextColor = Color;
}


/**
  * @brief  Sets the Background color.
  * @param  Color: specifies the Background color code RGB(5-6-5).
  * @retval None
  */
void LCD_SetBackColor(__IO uint16_t Color)
{
  BackColor = Color;
}

/**
  * @brief  Sets the Text Font.
  * @param  fonts: specifies the font to be used.
  * @retval None
  */
void LCD_SetFont(sFONT *fonts)
{
  LCD_Currentfonts = fonts;
}

/**
  * @brief  Gets the Text Font.
  * @param  None.
  * @retval the used font.
  */
sFONT *LCD_GetFont(void)
{
  return LCD_Currentfonts;
}

/**
  * @brief  Clears the selected line.
  * @param  Line: the Line to be cleared.
  *   This parameter can be one of the following values:
  *     @arg Linex: where x can be 0..n
  * @retval None
  */
void LCD_ClearLine(uint8_t Line)
{
  uint16_t refcolumn = LCD_PIXEL_WIDTH - 1;
  /* Send the string character by character on lCD */
  while (((refcolumn + 1)& 0xFFFF) >= LCD_Currentfonts->Width)
  {
    /* Display one character on LCD */
    LCD_DisplayChar(Line, refcolumn, ' ');
    /* Decrement the column position by 16 */
    refcolumn -= LCD_Currentfonts->Width;
  }
}


/**
  * @brief  Clears the hole LCD.
  * @param  Color: the color of the background.
  * @retval None
  */
void LCD_Clear(uint16_t Color)
{
  uint32_t index = 0;

  LCD_SetCursor(0,0); 
  LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */

  // 视频加速 www.armjishu.com
  ClrCs
  SetRs
  for(index=0;index<76800;index++)
   {
      ClrWr
      LCD_WriteRAM(Color);
      SetWr
   }
  SetCs
}


/**
  * @brief  Sets the cursor position.
  * @param  Xpos: specifies the X position.
  * @param  Ypos: specifies the Y position. 
  * @retval None
  */
void LCD_SetCursor(uint8_t Xpos, uint16_t Ypos)
{
	if(DeviceIdCode==0x8989)
	{
	 	LCD_WriteReg(0x004e,Xpos);        //行
    	LCD_WriteReg(0x004f,Ypos);  //列
	}
	else if((DeviceIdCode==0x9320))
	{
  		LCD_WriteReg(0x0020,Xpos); // 行
  		LCD_WriteReg(0x0021,0x13f-Ypos); // 列
	}
	else if((DeviceIdCode==0x9919))
	{
		LCD_WriteReg(0x004e,Xpos); // 行
  		LCD_WriteReg(0x004f,Ypos); // 列	
	}
	else if((DeviceIdCode==0x1505)) //lihao
	{
		LCD_WriteReg(0x0020,Xpos); // 行
  		LCD_WriteReg(0x0021,0x13f-Ypos); // 列	
	}
	else
	{
  		LCD_WriteReg(0x0020,Ypos); // 行
  		LCD_WriteReg(0x0021,0x13f-Xpos); // 列
	}
}

#if 0
/****************************************************************************
* 名    称:void ili9320_PutChar(u16 x,u16 y,u8 c,u16 charColor,u16 bkColor)
* 功    能:在指定座标显示一个8x16点阵的ascii字符
* 入口参数:x          行座标
*           y          列座标
*           charColor  字符的颜色
*           bkColor    字符背景颜色
* 出口参数:无
* 说    明:显示范围限定为可显示的ascii码
* 调用方法:ili9320_PutChar(10,10,'a',0x0000,0xffff);
****************************************************************************/
void ili9320_PutChar_16x24(u16 x,u16 y,u8 c,u16 charColor,u16 bkColor)
{

  u16 i=0;
  u16 j=0;
  
  u16 tmp_char=0;

  if(HyalineBackColor == bkColor)
  {
    for (i=0;i<24;i++)
    {
      tmp_char=ASCII_Table_16x24[((c-0x20)*24)+i];
      for (j=0;j<16;j++)
      {
        if ( (tmp_char >> j) & 0x01 == 0x01)
          {
            ili9320_SetPoint(x+j,y+i,charColor); // 字符颜色
          }
          else
          {
              // do nothing // 透明背景
          }
      }
    }
  }
  else
  {
    for (i=0;i<24;i++)
    {
      tmp_char=ASCII_Table_16x24[((c-0x20)*24)+i];
      for (j=0;j<16;j++)
      {
        if ( (tmp_char >> j) & 0x01 == 0x01)
          {
            ili9320_SetPoint(x+j,y+i,charColor); // 字符颜色
          }
          else
          {
            ili9320_SetPoint(x+j,y+i,bkColor); // 背景颜色
          }
      }
    }
  }
}
#endif

/**
  * @brief  Draws a character on LCD.
  * @param  Xpos: the Line where to display the character shape.
  * @param  Ypos: start column address.
  * @param  c: pointer to the character data.
  * @retval None
  */
void LCD_DrawChar(uint8_t Xpos, uint16_t Ypos, const uint16_t *c)
{
  uint32_t index = 0, i = 0;
  uint8_t Xaddress = 0;
   
  Xaddress = Xpos;
  
  LCD_SetCursor(Xaddress, Ypos);

  
  for(index = 0; index < LCD_Currentfonts->Height; index++)
  {
    LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
    for(i = 0; i < LCD_Currentfonts->Width; i++)
    {
#if  (Font16x24 == LCD_DEFAULT_FONT)
      if((c[index] & (0x1 << i)) == 0x00)
#else
      if((((c[index] & ((0x80 << ((LCD_Currentfonts->Width / 12 ) * 8 ) ) >> i)) == 0x00) &&(LCD_Currentfonts->Width <= 12))||
        (((c[index] & (0x1 << i)) == 0x00)&&(LCD_Currentfonts->Width > 12 )))
#endif
      {
          LCD_WriteRAM(BackColor);
      }
      else
      {
        LCD_WriteRAM(TextColor);
      }
    }   
    SetCs
    Xaddress++;
    LCD_SetCursor(Xaddress, Ypos);
  }
}


/**
  * @brief  Draws a chinacharacter on LCD.
  * @param  Xpos: the Line where to display the character shape.
  * @param  Ypos: start column address.
  * @param  c: pointer to the character data.
  * @retval None
  */
void LCD_DrawChinaChar(uint8_t Xpos, uint16_t Ypos, const uint8_t *c)
{
  uint32_t index = 0, i = 0, j = 0;
  uint8_t Xaddress = 0;
   
  Xaddress = Xpos;
  
  LCD_SetCursor(Xaddress, Ypos);

  for(index = 0; index < 24; index++)
  {
    LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
    for(j = 0; j < 3; j++)
    {
        for(i = 0; i < 8; i++)
        {
          if((c[3*index + j] & (0x80 >> i)) == 0x00)
          {
              LCD_WriteRAM(BackColor);
          }
          else
          {
            LCD_WriteRAM(TextColor);
          }
        }   
     }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -