ucGUI3.9版本快速移植构建


在之前的博客中移植了STemwin5.32版本的,最近更换了 GD芯片所以STemwin没法用了,只有移植emwin或者是ucGUI所有芯片都可以用了!
之前都是分散修改GUIxxx.c文件或者GUIxxx.h文件,现在打包成一个接口文件和一个库文件,不用再折腾了,累。。。

移植前提条件

参考博客STemwin的移植

涉及文件

  • emwPort.c–修改驱动
  • emwPort.h–修改配置
  • ucGUI3.9.a
  • 一堆ucGUI的头文件,无需改

移植过程

修改绘制驱动文件

ucGUI底层将调用以下绘制函数,必须对画点函数进行填充

/**
 *  @file: emwPort.c
 *
 *  @date: 2020/5/8
 *
 *  @author: aron566
 *
 *  @brief:emwin 移植接口
 *
 *  @version:v1.0
 */
#ifdef __cplusplus ///<use C compiler
extern "C" {
#endif
/** Includes -----------------------------------------------------------------*/
/* Private includes ----------------------------------------------------------*/
#include "emwPort.h"
#include "GUI.h"
/** Private typedef ----------------------------------------------------------*/
/** Private macros -----------------------------------------------------------*/
/** Private constants --------------------------------------------------------*/
/** Public variables ---------------------------------------------------------*/
/** Private variables --------------------------------------------------------*/
/** Private function prototypes ----------------------------------------------*/
/** Private user code --------------------------------------------------------*/

/** Public application code --------------------------------------------------*/
/*******************************************************************************
*
*       Public code
*
********************************************************************************
*/
/******************************************************************
  * @brief   读取个某点的颜色值
  * @param[in]   x,y:坐标
  * @return  此点的颜色
******************************************************************/
uint32_t EMPORT_LCD_ReadPoint(int x, int y)
{
    return *(uint16_t*)((uint32_t)ltdc_layer1[0] + 2 * (EMPORT_LCD_X_PIXEL * y + x));
}
 
 
/******************************************************************
  * @brief   画点
  * @param[in]   x,y:坐标  color:颜色
  * @return None
******************************************************************/
void EMPORT_LCD_DrawPoint(int x ,int y ,uint32_t color)
{
      uint16_t *TargetAddr = (uint16_t*)((uint32_t)ltdc_layer1[0] + 2 * (EMPORT_LCD_X_PIXEL * y + x));
      *TargetAddr = (uint16_t)color;
}
 
/******************************************************************
  * @brief   在指定区域内填充单个颜色
  * @param[in]   (sx,sy),(ex,ey):填充矩形对角坐标,区域大小为:(ex-sx+1)*(ey-sy+1)
  * @param[in]   color:要填充的颜色
  * @return     None
******************************************************************/
void EMPORT_LCD_Fill(int sx ,int sy ,int ex ,int ey ,uint32_t color)
{
      /*NEW Code*/
//      LCD_DrawFullRect(sx ,sy, ex+1, ey+1);
    for (; sy <= ey; sy++) 
    {
        EMPORT_LCD_DrawHLine(sx ,sy ,ex ,color);
    }
}

/**
  ******************************************************************
  * @brief   绘制横线
  * @param[in]   X起点
  * @param[in]   Y起点
  * @param[in]   X长度
  * @param[in]   颜色
  * @retval  None
  * @author  aron566
  * @version v1.0
  * @date    2020/5/9
  ******************************************************************
  */
void EMPORT_LCD_DrawHLine(int x0 ,int y, int x1 ,uint32_t color)
{
    for (; x0 <= x1; x0++) {
      EMPORT_LCD_DrawPoint(x0, y, color);
    }
}

/**
  ******************************************************************
  * @brief   绘制竖线
  * @param[in]   X起点
  * @param[in]   Y起点
  * @param[in]   Y长度
  * @param[in]   颜色
  * @retval  None
  * @author  aron566
  * @version v1.0
  * @date    2020/5/9
  ******************************************************************
  */
void EMPORT_LCD_DrawVLine(int x ,int y0 ,int y1 ,uint32_t color)
{
    for (; y0 <= y1; y0++) {
      EMPORT_LCD_DrawPoint(x, y0, color);
    }
}

/**
  ******************************************************************
  * @brief   GUI触摸接口 ,获取X坐标
  * @param   None
  * @retval  X坐标 
  * @author  aron566
  * @version v1.0
  * @date    2020/5/8
  ******************************************************************
  */
int EMPORT_Touch_GetPhyX(void)
{
    return 0;
}

/**
  ******************************************************************
  * @brief   GUI触摸接口 ,获取Y坐标
  * @param   None
  * @retval  Y坐标 
  * @author  aron566
  * @version v1.0
  * @date    2020/5/8
  ******************************************************************
  */
int EMPORT_Touch_GetPhyY(void)
{
    return 0;
}

/**
  ******************************************************************
  * @brief   GUI时基 放入1ms中断
  * @param   None
  * @retval  None 
  * @author  aron566
  * @version v1.0
  * @date    2020/5/8
  ******************************************************************
  */
void EMPORT_GUI_Inc_Ticks_Port(void)
{
    extern volatile GUI_TIMER_TIME OS_TimeMS;
    OS_TimeMS++;
}
#ifdef __cplusplus ///<end extern c
}
#endif
/******************************** End of file *********************************/

修改配置文件

emwPort.h

/**
 *  @file: emwPort.h
 *
 *  @date: 2020/5/8
 *
 *  @author: aron566
 *
 *  @brief:emwin 移植接口
 *  
 *  @version:v1.0
 */
#ifndef __EMWPORT_H
#define __EMWPORT_H
#ifdef __cplusplus ///<use C compiler
extern "C" {
#endif
/** Includes -----------------------------------------------------------------*/
#include <stdint.h> /**< nedd definition of uint8_t */
#include <stddef.h> /**< need definition of NULL    */
//#include <stdbool.h>/**< need definition of BOOL    */
#include <stdio.h>  /**< if need printf             */
#include <stdlib.h>
#include <string.h>
/** Private includes ---------------------------------------------------------*/
#include "cmsis_os.h"
#include "ipa.h"
/** Private defines ----------------------------------------------------------*/
/**
 * @name EMWIN移植配置
 * @{
 */
#define EMPORT_FRAME_BUFF_ADDR  ((void*)(LCD_FRAME_BUFFER+BUFFER_OFFSET))
#define EMPORT_BUFF_SIZE        (1024*20U)
#define EMPORT_BLOCKSIZE        (0x80)
#define EMPORT_USE_OS           (0)     /**< 启用OS     */
#define EMPORT_XSIZE_PHYS       (480)   /**< 配合显示方向的X像素*/
#define EMPORT_YSIZE_PHYS       (320)   /**< 配合显示方向的Y像素*/
#define EMPORT_LCD_X_PIXEL      (320)   /**< 实际X像素  */
#define EMPORT_LCD_Y_PIXEL      (480)   /**< 实际Y像素  */
#define EMPORT_LCD_BITSPERPIXEL (16)    /**< 像素位大小 */
#define EMPORT_LCD_FIXEDPALETTE (565)   /**< 颜色格式   */
#define EMPORT_LCD_SWAP_RB      (1)     /**< 红蓝交换   */
#define EMPORT_LCD_CONTROLLER   (566)   /**< 控制器名称 */
#define EMPORT_NUM_LAYERS       (1)     /**< 最大层级   */
#define EMPORT_SUPPORT_TOUCH    (0)     /**< 支持触摸   */
#define EMPORT_SUPPORT_UNICODE  (1)     /**< 支持UNICODE*/
#define EMPORT_SUPPORT_MOUSE    (0)     /**< 支持鼠标   */
#define EMPORT_WINSUPPORT       (1)
#define EMPORT_SUPPORT_MEMDEV   (1)
#define EMPORT_SUPPORT_AA       (1)     /**< 支持反锯齿 */
#define EMPORT_SUPPORT_DEVICES  (1)
#define EMPORT_SUPPORT_NOTIFY_VIS_CHANGED    (1)
#define EMPORT_DEFAULT_FONT     (&GUI_FontD24x32)  /**< 默认字体大小*/
#define EMPORT_COLOR_CONVERSION GUICC_M565//GUICC_565//GUICC_888
#define EMPORT_DISPLAY_DRIVER   GUIDRV_WIN32//GUIDRV_TEMPLATE

/**
 * @name EMWIN调整显示方向
 * @{
 */
/* 1 1 0 横竖屏切换 */
#define EMPORT_LCD_SWAP_XY      (1)    
#define EMPORT_LCD_MIRROR_X     (1)
#define EMPORT_LCD_MIRROR_Y     (0)
/** @}*/   
#define EMPORT_TOUCH_SWAP_XY    (1)
#define EMPORT_TOUCH_MIRROR_X   (0)
#define EMPORT_TOUCH_MIRROR_Y   (1)
#define EMPORT_CALIBRATION      (4000)
#define EMPORT_TOUCH_AD_LEFT    (300)
#define EMPORT_TOUCH_AD_RIGHT   (3700)
#define EMPORT_TOUCH_AD_TOP     (300)
#define EMPORT_TOUCH_AD_BOTTOM  (3700)
/** @}*/
/** Exported typedefines -----------------------------------------------------*/

/** Exported constants -------------------------------------------------------*/
/** Exported macros-----------------------------------------------------------*/
/** Exported variables -------------------------------------------------------*/
/** Exported functions prototypes --------------------------------------------*/
uint32_t EMPORT_LCD_ReadPoint(int x ,int y);
void EMPORT_LCD_DrawPoint(int x ,int y ,uint32_t color);
void EMPORT_LCD_Fill(int sx ,int sy ,int ex ,int ey ,uint32_t color);
void EMPORT_LCD_DrawHLine(int x0 ,int y, int x1 ,uint32_t color);
void EMPORT_LCD_DrawVLine(int x ,int y0 ,int y1 ,uint32_t color);
void EMPORT_GUI_Inc_Ticks_Port(void);
int EMPORT_Touch_GetPhyX(void);
int EMPORT_Touch_GetPhyY(void);
#ifdef __cplusplus ///<end extern c
}
#endif
#endif
/******************************** End of file *********************************/

打包进工程

三个文件夹:
INCLUDE ucGUI的一堆头文件
LIB 库文件
PORT ucGUI移植接口
在这里插入图片描述
加入工程,图为IAR工程,两个文件即可,接口文件,库文件,其他的头文件路径包含即可
在这里插入图片描述

涉及的资源获取

前往下载

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

aron566

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值