移植StemWin到STM32F103VET6开发板,使用0.96寸IIC屏幕
本帖最后由 在水一方00 于 2022-6-30 18:31 编辑【参考资料】
开发板:野火F103VET6指南者开发板,裸机不带操作系统。
emWin5.12中文手册,野火家资料中有。
使用0.96寸IIC屏幕,就是某宝上最常见的那种。
首先使用硬件IIc驱动屏幕显示。
cubeMX配置如下:
大佬写的文章:https://blog.csdn.net/z961968549/article/details/105243723/
【bilibili视频资料】:https://www.bilibili.com/video/BV16t4y117rN?p=7
OLED驱动底层函数,问同事要了正点原子的驱动,然后把这个函数替换一下,就可以实现简单的显示功能,最重要的是再某个位置显示一个点的函数。 然后移植STemWin,STemWin的版本可以在cubeMX存放包的地方找到,
复制需要的文件到工程中:
lib中文件的选择看上面的图片 ,不同的文件适应不同的平台。至于每个文件夹中文件的作用:
Config中主要是配置文件,修改以适应屏幕。
inc文件夹中是一些控件什么的。
lib中是封装好的源文件。
OS中看是否带系统来选择。 Config配置:
【GUIConf.c文件】
#include "GUI.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
//
// Define the available number of bytes available for the GUI
//
#define GUI_NUMBYTES(30*1024)//==============修改使用内存大小
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUI_X_Config
*
* Purpose:
* Called during the initialization process in order to set up the
* available memory for the GUI.
*/
void GUI_X_Config(void) {
//
// 32 bit aligned memory area
//
static U32 aMemory;
//
// Assign memory to emWin
//
GUI_ALLOC_AssignMemory(aMemory, GUI_NUMBYTES);
//
// Set default font
//
GUI_SetDefaultFont(GUI_FONT_6X8);
}
/*************************** End of file ****************************/
【GUIConf.h】
#ifndef GUICONF_H
#define GUICONF_H
/*********************************************************************
*
* Multi layer/display support
*/
#define GUI_NUM_LAYERS 1 // Maximum number of available layers
/*********************************************************************
*
* Multi tasking support
*/
#ifdef OS_SUPPORT
#define GUI_OS (1)// Compile with multitasking support
#else
#define GUI_OS (0)
#endif
/*********************************************************************
*
* Configuration of touch support
*/
#ifndef GUI_SUPPORT_TOUCH
#define GUI_SUPPORT_TOUCH (0)// Support touchscreen
#endif
/*********************************************************************
*
* Default font
*/
#define GUI_DEFAULT_FONT &GUI_Font6x8
/*********************************************************************
*
* Configuration of available packages
*/
#define GUI_SUPPORT_MOUSE (0) /* Support a mouse */
#define GUI_WINSUPPORT (1) /* Use window manager */
#define GUI_SUPPORT_MEMDEV (0) /* Memory device package available */
#define GUI_SUPPORT_DEVICES (1) /* Enable use of device pointers */
#endif/* Avoid multiple inclusion */
【GUIDRV_Template.h】:对接屏幕硬件,GUI驱动,这里只将基础的画点以及读点的函数对接进去。还有其他的函数也可以对接。 这里查询像素坐标点的函数要自己实现以下,能够查到当前点的像素状态。【这里通过设置的函数数组记录,然后查询的时候从数组往外拿】 【GUIDRV_Template.h】、
【LCDConf_FlexColor_Template.h】设置XY像素