3953|1

16

帖子

0

TA的资源

一粒金砂(初级)

楼主
 

F7评测⑥——LCD驱动学习 [复制链接]

首先,打开LCD的驱动文件, ,先对这个进行简单的翻译,
* @brief   This file includes the driver for Liquid Crystal Display (LCD) module
  *          mounted on STM32F769I-DISCOVERY board.
这个文件包含了安装在STM32F769I探索板上的LCD模块的驱动
  User NOTES
1. How To use this driver:
--------------------------
   - This driver is used to drive directly in video mode a LCD TFT using the DSI interface.
     The following IPs are implied : DSI Host IP block working
     in conjunction to the LTDC controller.
   - This driver is linked by construction to LCD KoD mounted on board MB1166.
1.如何使用这个驱动:
     这个驱动使用DSI接口直接在LCD TFT屏上进入视频模式
    下面的IP被隐藏了:DSI HOST IP块工作
    连接到LTDC控制器
    这个驱动通过构建连接到到安装在板子MB1166上的LCD KoD。

2. Driver description:
---------------------
  + Initialization steps:
     o Initialize the LCD using the BSP_LCD_Init() function.
     o Select the LCD layer to be used using the BSP_LCD_SelectLayer() function.
     o Enable the LCD display using the BSP_LCD_DisplayOn() function.
2.驱动描述  
   初始化步骤:
   通过使用BSP_LCD_Init()函数初始化
   使用 BSP_LCD_SelectLayer()函数 选择LCD层
   使用BSP_LCD_DisplayOn()函数来使能LCD的显示

  + Options
     o Configure and enable the color keying functionality using the
       BSP_LCD_SetColorKeying() function.
     o Modify in the fly the transparency and/or the frame buffer address
       using the following functions:
       - BSP_LCD_SetTransparency()
       - BSP_LCD_SetLayerAddress()
选择:
    使用 BSP_LCD_SetColorKeying() 函数来配置和使能颜色功能
    使用以下的函数  
     - BSP_LCD_SetTransparency()
     - BSP_LCD_SetLayerAddress()
    来修改屏幕的透明度或是创建地址缓存

  + Display on LCD
     o Clear the whole LCD using BSP_LCD_Clear() function or only one specified string
       line using the BSP_LCD_ClearStringLine() function.
     o Display a character on the specified line and column using the BSP_LCD_DisplayChar()
       function or a complete string line using the BSP_LCD_DisplayStringAtLine() function.
     o Display a string line on the specified position (x,y in pixel) and align mode
       using the BSP_LCD_DisplayStringAtLine() function.
     o Draw and fill a basic shapes (dot, line, rectangle, circle, ellipse, .. bitmap)
       on LCD using the available set of functions.
在LCD上显示
   使用 BSP_LCD_Clear() 函数清除整个LCD屏幕或是使用 BSP_LCD_ClearStringLine()函数只显示一条特定的字符行
   使用BSP_LCD_DisplayChar()函数来显示一个字符在特定行和列或是使用BSP_LCD_DisplayStringAtLine() 函数显示一个完整的字符
   使用BSP_LCD_DisplayStringAtLine() 函数在特定的X,Y坐标上显示一个字符和配置对齐模式
   通过可使用的设置函数,画或是以一个固定形状填充在LCD上(如 点 线 矩形 圆 椭圆 。。BMP图片)


初始化函数不多说了,使用前调用
复位函数,连接的复位引脚是J15,拉低引脚20ms完成复位工作
void BSP_LCD_Reset(void)
{
  GPIO_InitTypeDef  gpio_init_structure;

  __HAL_RCC_GPIOJ_CLK_ENABLE();

    /* Configure the GPIO on PJ15 */
    gpio_init_structure.Pin   = GPIO_PIN_15;
    gpio_init_structure.Mode  = GPIO_MODE_OUTPUT_PP;
    gpio_init_structure.Pull  = GPIO_PULLUP;
    gpio_init_structure.Speed = GPIO_SPEED_HIGH;

    HAL_GPIO_Init(GPIOJ, &gpio_init_structure);

    /* Activate XRES active low */
    HAL_GPIO_WritePin(GPIOJ, GPIO_PIN_15, GPIO_PIN_RESET);

    HAL_Delay(20); /* wait 20 ms */

    /* Desactivate XRES */
    HAL_GPIO_WritePin(GPIOJ, GPIO_PIN_15, GPIO_PIN_SET);
   
    /* Wait for 10ms after releasing XRES before sending commands */
    HAL_Delay(10);
}
下面是
uint32_t BSP_LCD_GetXSize(void);
uint32_t BSP_LCD_GetYSize(void);获取LCD的X Y尺寸
一个480 一个800
/* Width and Height in Portrait mode */
#define  OTM8009A_480X800_WIDTH             ((uint16_t)480)     /* LCD PIXEL WIDTH   */
#define  OTM8009A_480X800_HEIGHT            ((uint16_t)800)     /* LCD PIXEL HEIGHT  */
驱动和官方写的800*472的屏幕分辨率不吻合,至今不知谁对谁错?
下面的函数就不一一介绍了,都有详尽的注释。

显示ASCII:

LCD_Config();
BSP_LCD_SetBackColor(LCD_COLOR_RED);
  BSP_LCD_DisplayChar(100,200,0x30);
    BSP_LCD_SetBackColor(LCD_COLOR_ORANGE);
  BSP_LCD_DisplayChar(124,200,0x31);
    BSP_LCD_SetBackColor(LCD_COLOR_YELLOW);
  BSP_LCD_DisplayChar(148,200,0x32);
    BSP_LCD_SetBackColor(LCD_COLOR_MAGENTA);
  BSP_LCD_DisplayChar(172,200,0x33);
    BSP_LCD_SetBackColor(LCD_COLOR_GREEN);
  BSP_LCD_DisplayChar(196,200,0x34);
    BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
  BSP_LCD_DisplayChar(220,200,0x35);
    BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
  BSP_LCD_DisplayChar(244,200,0x36);






显示英文和字符:
LCD_Config();
BSP_LCD_SetFont(&Font24);
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
BSP_LCD_SetBackColor(LCD_COLOR_RED);
  BSP_LCD_DisplayStringAtLine(5,"test?O(∩_∩)O~");
BSP_LCD_SetTextColor(LCD_COLOR_LIGHTMAGENTA);
   BSP_LCD_SetBackColor(LCD_COLOR_GREEN);
BSP_LCD_DisplayStringAt(0,228,"Test is ok?中文不显示?O(∩_∩)O~",CENTER_MODE);


图形绘制

LCD_Config();

  BSP_LCD_SetBrightness(100);
    BSP_LCD_SetFont(&Font24);
    BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
    BSP_LCD_DrawHLine(50,50,100);
    BSP_LCD_DrawVLine(50,50,100);
    BSP_LCD_DrawRect(100,100,100,100);
    BSP_LCD_DrawLine(0,0,80,80);
    BSP_LCD_DrawCircle(150,150,100);
    BSP_LCD_DrawEllipse(400,150,50,100);   
    BSP_LCD_SetTextColor(LCD_COLOR_MAGENTA);
    BSP_LCD_FillCircle(650,150,100);
  BSP_LCD_SetTextColor(LCD_COLOR_ORANGE);
    BSP_LCD_FillRect(500,300,50,50);
    BSP_LCD_SetTextColor(LCD_COLOR_YELLOW);
  BSP_LCD_FillEllipse(300,300,100,75);   



显示图片

  /*##-2- Link the SD Card disk I/O driver ###################################*/
  if(FATFS_LinkDriver(&SD_Driver, SD_Path) == 0)
  {
    /*##-3- Initialize the Directory Files pointers (heap) ###################*/
    for (counter = 0; counter < MAX_BMP_FILES; counter++)
    {
      pDirectoryFiles[counter] = malloc(MAX_BMP_FILE_NAME);
      if(pDirectoryFiles[counter] == NULL)
      {
        /* Set the Text Color */
        BSP_LCD_SetTextColor(LCD_COLOR_RED);

        BSP_LCD_DisplayStringAtLine(8, (uint8_t*)"  Cannot allocate memory ");
        while(1) { ; }
      }
    }

    /* Get the BMP file names on root directory */
    ubNumberOfFiles = Storage_GetDirectoryBitmapFiles("/Media", pDirectoryFiles);

    if (ubNumberOfFiles == 0)
    {
      for (counter = 0; counter < MAX_BMP_FILES; counter++)
      {
        free(pDirectoryFiles[counter]);
      }
      BSP_LCD_DisplayStringAtLine(8, (uint8_t*)"  No Bitmap files...      ");
      while(1) { ; }
    }
  }
  else
  {
    /* FatFs Initialization Error */
    Error_Handler();
  }
counter = 0;

    while ((counter) < ubNumberOfFiles)
    {
      /* Step1 : Display on Foreground layer -------------------------------*/
      /* Format the string */
      sprintf ((char*)str, "Media/%-11.11s", pDirectoryFiles[counter]);

      if (Storage_CheckBitmapFile((const char*)str, &uwBmplen) == 0)
      {
        /* Format the string */
        sprintf ((char*)str, "Media/%-11.11s", pDirectoryFiles[counter]);

        /* Set LCD foreground Layer */
        BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER_FOREGROUND);

        /* Open a file and copy its content to an internal buffer */
        Storage_OpenReadFile(uwInternalBuffer, (const char*)str);

        /* Write bmp file on LCD frame buffer */
        BSP_LCD_DrawBitmap(0, 0, uwInternalBuffer);

        /* Configure the transparency for background layer : Increase the transparency */
        for (transparency = 0; transparency < 255; (transparency++))
        {
          BSP_LCD_SetTransparency(LTDC_ACTIVE_LAYER_FOREGROUND, transparency);

          /* Insert a delay of display */
          HAL_Delay(10);
        }

        /* Configure the transparency for foreground layer : decrease the transparency */
        for (transparency = 255; transparency > 0; transparency--)
        {
          BSP_LCD_SetTransparency(LTDC_ACTIVE_LAYER_FOREGROUND, transparency);

          /* Insert a delay of display */
          HAL_Delay(10);
        }}}




点击此处,查看STM32F769I开发板官方资源。
此帖出自stm32/stm8论坛

最新回复

真不错,学习学习。  详情 回复 发表于 2016-12-17 09:27
点赞 关注(2)
 

回复
举报

4

帖子

0

TA的资源

一粒金砂(初级)

沙发
 
真不错,学习学习。
此帖出自stm32/stm8论坛
 
 

回复
您需要登录后才可以回帖 登录 | 注册

查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/6 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表