准备 emWin 软件包
获取方法一官网获取:
SEGGER - The Embedded Experts - Downloads - emWin
选择版本号,下载

获取方法二:


C:\Users\XXXX\AppData\Local\Arm\Packs\Keil\MDK-Middleware\7.13.0\emWin
裁剪emwin
取出最简单的lcd程序
导出文件夹结构树
一、按住shift键,右击你要生成目录的文件夹,选择“在此处打开命令窗口”
二、在命令窗口里输入命令“tree”,按回车。就会显示出目录结构。
文件夹结构
├─Middlewares
│ └─emWin
│ ├─Config (存放 emWin 配置文件)
│ ├─emWin_Demo (存放用户文件)
│ ├─GUI_X (存放 GUI 的配置/系统相关外部设备文件)
│ ├─Include (存放 emWin 函数的头文件)
│ └─Lib (存放 emWin 的函数库文件 )
Config
\emWin\Sample\Config
添加展示
GUI_X
整个文件夹复制就好
Include
整个文件夹复制就好
Lib

添加展示

添加文件
Middlewares/emWin/Config



Middlewares/emWin/GUI_x
裸机选这个

Middlewares/emWin/Lib
按对应内核选择,如果用户的 MCU 为 CM3 内核,则工程使用 GUI_CM3_L.lib 文件。GUI_CM4F_L.lib 文件只能使用在 CM4 以上的 MCU 内核。
添加完成
有钥匙是因为只读改掉可以修改即可
添加路径

程序修改:
报错解决:(修改GUI_X.C)
编译一遍五个报错:

解决后四个:
添加声明即可

/*********************************************************************
*
* Multitasking:
*
* GUI_X_InitOS()
* GUI_X_GetTaskId()
* GUI_X_Lock()
* GUI_X_Unlock()
*
* Note:
* The following routines are required only if emWin is used in a
* true multi task environment, which means you have more than one
* thread using the emWin API.
* In this case the
* #define GUI_OS 1
* needs to be in GUIConf.h
*/
void GUI_X_InitOS(void) { }
void GUI_X_Unlock(void) { }
void GUI_X_Lock(void) { }
U32 GUI_X_GetTaskId(void) { return 1; }
修改 GUIConf.h 文件
根据需要进行宏定义修改
/*********************************************************************
* SEGGER Microcontroller GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996 - 2020 SEGGER Microcontroller GmbH *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
** emWin V6.16 - Graphical user interface for embedded applications **
All Intellectual Property rights in the Software belongs to SEGGER.
emWin is protected by international copyright laws. Knowledge of the
source code may not be used to write a similar product. This file may
only be used in accordance with the following terms:
The software has been licensed to ARM LIMITED whose registered office
is situated at 110 Fulbourn Road, Cambridge CB1 9NJ, England solely
for the purposes of creating libraries for ARM7, ARM9, Cortex-M
series, and Cortex-R4 processor-based devices, sublicensed and
distributed as part of the MDK-ARM Professional under the terms and
conditions of the End User License supplied with the MDK-ARM
Professional.
Full source code is available at: www.segger.com
We appreciate your understanding and fairness.
----------------------------------------------------------------------
Licensing information
Licensor: SEGGER Software GmbH
Licensed to: ARM Ltd, 110 Fulbourn Road, CB1 9NJ Cambridge, UK
Licensed SEGGER software: emWin
License number: GUI-00181
License model: LES-SLA-20007, Agreement, effective since October 1st 2011
Licensed product: MDK-ARM Professional
Licensed platform: ARM7/9, Cortex-M/R4
Licensed number of seats: -
----------------------------------------------------------------------
File : GUIConf.h
Purpose : Configures emWins abilities, fonts etc.
----------------------------------------------------------------------
*/
#ifndef GUICONF_H
#define GUICONF_H
/*********************************************************************
*
* Multi layer/display support
*/
#define GUI_NUM_LAYERS 1 // Maximum number of available layers/* 显示的最大层数 */
/*********************************************************************
*
* Multi tasking support
*/
#define GUI_OS (0) // Compile with multitasking support/* 0:不使用操作系统 */
/*********************************************************************
*
* Configuration of touch support
*/
#define GUI_SUPPORT_TOUCH (0) // Support a touch screen (req. win-manager)/* 0:不支持触摸 */
/*********************************************************************
*
* Default font
*/
#define GUI_DEFAULT_FONT &GUI_Font6x8/* 默认字体 */
/*********************************************************************
*
* Configuration of available packages
*/
#define GUI_SUPPORT_MOUSE 1 // Mouse support/* 支持鼠标 */
#define GUI_WINSUPPORT 1 // Use Window Manager/* 支持窗口管理 */
#define GUI_SUPPORT_MEMDEV 1 // Use Memory Devices/* 支持存储设备 */
#define GUI_SUPPORT_DEVICES 1 // Enable use of device pointers/* 使用设备指针 */
#endif // Avoid multiple inclusion
/*************************** End of file ****************************/
修改 GUIConf.c 文件


函数_SetPixelIndex修改打点

函数_GetPixelIndex修改读点

函数_FillRect修改区域色块填充
函数_DrawBitLine16BPP修改区域色块填充
不修改暂时没遇到问题(不是RGB屏不需要修改)
修改 LCDConf.c文件
函数LCD_X_Config(解决最后一个报错)
void LCD_X_Config(void)
{
/* 创建显示驱动器件 */
GUI_DEVICE_CreateAndLink(&GUIDRV_Template_API, GUICC_M565, 0, 0);
LCD_SetSizeEx(0, lcddev.width, lcddev.height);
LCD_SetVSizeEx(0, lcddev.width, lcddev.height);
}
提供时基
extern __IO int32_t OS_TimeMS;
void 1ms中断函数(void)
{
OS_TimeMS++;
}
测试

GUI_Init(); /* emWin 初始化 */
GUI_SetBkColor(GUI_BLUE); /* 设置背景颜色*/
GUI_SetColor(GUI_YELLOW); /* 设置颜色*/
GUI_Clear(); /* 清屏*/
GUI_SetFont(&GUI_Font24_ASCII); /* 设置字体 */
GUI_DispStringAt("Hello Word!", 0, 0); /* 在指定位置显示字符串 */
参考某点原子,开发板是stm32 mini

931





