当前位置:网站首页>Introduction to ucgui
Introduction to ucgui
2020-11-07 23:08:00 【shzwork】
uC/GUI yes Micrium General embedded user image interface software developed by the company . He gives any image to use LCD Applications that are processor independent and LCD Effective graphs outside the controller
Form user interface . Can be applied to a single task , It can also be used in multitasking environments .uC/GUI Can be applied to any LCD Controller and CPU Any size of the physical display or analog display .
uC/GUI The features are as follows :
- Apply to any 8 position /16 position /32 position CPU, May be allowed to support ANSI C Any compiler for
- Apply to any controller to drive any LCD( monochrome , Grayscale , Or color )
- By configuring the macro , Can support any interface
- Configurable display size
- Can be found in LCD Display characters and draw bitmaps at any point of the
- Provides optimization process for display size and speed , The compilation time depends on the optimization process used
- Support virtual display , The size of the virtual display is larger than the actual display .
4.2 uC/GUI Document organization
uC/GUI The document under the directory has the configuration document directory Config,GUI Library function Directory , Together with for GUI Directory of applications written . The following is a brief introduction to the functions in the corresponding directory , For more detailed documentation, please refer to my uC/GUI Migrated source code .
- uC/GUI\Config\ Catalog :
GUICONF.h: To configure GUI Options for porting to different operating systems . In this paper, the configuration is transplanted to uC/OSII in , Allow multitasking calls uC/GUI function .
GUITouchConf.h: Configure the options for the touch screen along with writing the driver for the touch screen . This article transplants uC/GUI What is used LCD Screen does not support touch screen , So this document is empty .
LCD_Init.C: LCD Initialization document of the controller .
LCD_Conf.h: LCD Options document for the display screen , Include bpp, Debug board mode , level 、 Vertical resolution and so on . - uC/GUI\GUI\AntiAlias\ Catalog :
This catalog contains 9 A document , Blur the edge of the display , It's anti aliasing and optimization LCD sawtooth . The diagonal lines on the LCD screen often have serrations , So by optimizing Algorithm Beautify . - uC/GUI\GUI\ConvertColor\ Catalog :
This catalog contains 14 individual .C file , It's about palette mode .uC\GUI The palette mode supports 111 Pattern ,222 Pattern ,223,323,332,444,555,
565,8666 And so on . What I use in my paper is LCD screen , It's monochrome 16 Gray level screen , Therefore, these patterns are not involved . But in order to keep UC\GUI Integrity of documents , The catalogue, together with the heading
Record 14 A document , Still saved in the migration document . - uC/GUI\GUI\ConvertMono\ Catalog :
The documents in this directory describe the different modes of monochrome display , contain 4 A document . - uC/GUI\GUI\Core
This directory contains 129 A document , yes uC/GUI The core of . Include GUI Header document ,GUI Show all kinds of text , Binary system , Decimal system , Hexadecimal , Character text , character string , In different
Position display binary , Decimal system , Hexadecimal , Character text , String, etc. ;GUI Configure various Fonts ;GUI Of 2-D Image library ,GUI Plot function , Draw dots in various places , Line , Bitmap ,
polygon , Rectangle , Circle and so on ;GUI Get function , Get the current point , Line , Bitmap , polygon , Rectangle , round , The current font , Current binary , Decimal system , Hexadecimal , Character text , String and so on
Count ; To configure GUI Brush function ;GUI Supported mouse functions ;GUI Supported keyboard functions ,GUI Supported touch screen functions ;GUI To configure LCD Function, etc. . These functions , stay uC/GUI system
All of them are necessary functions . It's a combination of these functions , bring uC/GUI With complex and complete image user interface . and , A combination of these functions , bring uC/GUI Can be used alone , also
Through the configuration document , Porting to various operating systems . - uC/GUI\GUI\Font
This directory contains uC/GUI Supported Fonts . - uC/GUI\GUI\LCDDriver
LCD API Catalog . This directory contains a lot of complete LCD The driver of the controller is connected with API function . - uC/GUI\GUI\MemDev
MemDev Catalog .
MemDev It is mainly used to prevent the jitter when drawing overlapping graphs .
uC/GUI Function drawing does not use MemDev when , The drawing operation is written directly to the terminal for display , Refresh the screen when overlapping drawing is executed , There will be jitters when you refresh many times . for example , To draw in the background color , And
Write transparent text in the foreground , The implementation step is to draw a picture first , And then write words , Then the result will be a text jitter . If you use MemDev, Then any execution is in
MemDev In the implementation of , When everything is done , The final result will be displayed on the screen , Therefore, it can avoid multiple refreshes , To avoid shaking .
This directory contains this MemDev Any function of , Including the creation of MemDev function , Activate MemDev, Perform the drawing operation , Display to the terminal , Delete MemDev Function, etc. . - uC/GUI\GUI\Touch
Touch screen driver function directory .uC/GUI Only analog touch screens are supported . So this directory contains only analog touch screens . - uC/GUI\GUI\Widget
This directory contains window control functions , in total 46 A function .UC/GUI In the window control mechanism uC/GUI Implementation difficulties of , It's also a difficult application . Using window management and callback mechanism , Use window control function
Count , Be able to do whatever you want in LCD On screen implementation is similar to windows The interface of , Such a complete function has far-reaching and positive significance in industrial automation control and touch screen application .The functions in this directory mainly include uC/GUI Window controls for , Button like BUTTON, Check window CHECKBOX, Editing area EDIT, Window frame FRAMEWIN, list
LISTBOX, Progress bar PROGBAR, Audio button RADIOBUTTON, Scroll bar SCROLLERBAR, Change the value of the gray bar SLIDER, With the text box
TEXT All kinds of related functions . - uC/GUI\GUI\WM
This directory includes window management functions , in total 52 A function .UC/GUI in , Message passing mechanism and callback mechanism in window management , It's also uC/GUI The implementation difficulties and application difficulties of .4.3 These two points will be introduced in detail in the section .
The functions in this directory mainly include configuration 、 return 、 Create a background window 、 The parent window 、 Each seed window with corresponding size 、 Window handle , The starting point x,y coordinate , Window width , Height , Location, etc , It also includes changing the size of the window , Along with the most critical window's callback function , Window redraw functions and so on .
4.3 uC/GUI Window management of
4.3.1 brief introduction
uC/GUI Windows management is a separate software , No uC/GUI Basic components of . For detailed code, see \uCGUI\GUI\WM.
When using uC/GUI Window management , Any content that can be displayed on the display terminal is contained in a window , This window is LCD An area on the screen that draws a picture or shows a target to the user . Windows can be of any size , Be able to display multiple windows on the screen at once , You can also display windows in or before other windows .
Several terms for window management :
- Active window :
The window currently being used for drawing or displaying operations . - Callback function
Callback functions are user-defined , When a particular event occurs , A function that instructs the image system to call a specific function . Usually when the content of a window changes , They
To automatically redraw the window . for example , A bitmap is displayed in the window , When the window moves , The bitmap doesn't move automatically , here , You need to call the callback function to redraw the window , namely , From the perspective of the audience , Moving windows
Mouth and window content . - Son / The parent window
A child window is a window defined relative to the parent window . No matter when , As long as the parent window moves , Then the child windows have to move accordingly . The child window is completely contained by the parent window . Children with the same parent window are called brothers . - Customer area
The client area of the window is the available area of the window . If the window contains a box or a title bar , The customer area is the internal area of the box or title bar . - Handle
When a new window is created ,WM Assign a unique identifier , Called handle . The handle is used in any subsequent function that operates on the window , The handle can be used to uniquely identify the window . - Effective window / Invalid window
The valid window is a fully updated , Windows without redrawing . Whether it's a full redraw or a partial redraw . When the contents of the window change ,WM The ID window is invalid . After the next redraw ( Call callback function ), The window becomes active again .
4.3.2 Callback mechanism
uC/GUI Behind the callback mechanism provided to windows and window controls , It's one
Event driven flags . In most window systems , Flow control is not only from user programs to image systems , And it has to be able to go from user programs to image systems , And through the callback function provided by the user program , return
Back to the user program . This mechanism , It's called a callback mechanism . stay uC/GUI in , The return mechanism is used to control the redraw operation of the control window in window management , This makes the effectiveness of window management possible .
4.3.3 The use of callback functions
When you create a window with a callback function , There must be a callback function . The callback function used must have the following prototype :
void callback (WM_MESSAGE *pMsg). among pMsg Is a pointer to the message .
The function performed by the callback function depends on the message received . The above prototypes are usually followed by switch expression , Expressions define different case Under the expression, different information corresponds to different behavior , There has to be at least one redraw function :WM_PAINT(). Such as program list 4.1, Create a callback function that automatically updates the window
Program list 4.1 Create a callback function that automatically updates the window
void WinHandler (WM_MESSAGE * pMsg)
{
switch (pMsg->MsgId)
{
case: WM_PAINT GUI_SetBkColor(0xff00);
GUI_Clear();
GUI_DispStringAt(“hello world”,0,0);
Break;
}
}
VC & Delphi , A more detailed example is the program list 4.2 Shown :
Program list 4.2 Callback function
#include "GUI.H"
/* Background window callback function */
static void cbBackgroundWin(WM_MESSAGE* pMsg)
{
switch (pMsg->MsgId)
{
case WM_PAINT: GUI_Clear();
default: WM_DefaultProc(pMsg);
}
}
/* The callback function of foreground window */
static void cbForegroundWin(WM_MESSAGE* pMsg)
{
switch (pMsg->MsgId)
{
case WM_PAINT: GUI_SetBkColor(GUI_GREEN);
GUI_Clear();
GUI_DispString("Foreground window");
default: WM_DefaultProc(pMsg);
}
}
/* Callback mechanism */
static void DemoRedraw(void)
{
GUI_HWIN hWnd;
while(1)
{
/* Create a foreground window */
hWnd = WM_CreateWindow(10, 10, 100, 100, WM_CF_SHOW, cbForegroundWin, 0);
/* Show foreground window */
GUI_Delay(1000);
/* Delete foreground window */
WM_DeleteWindow(hWnd);
GUI_DispStringAt("Background of window has not been redrawn", 10, 10);
/* wait for , The display does not redraw */
GUI_Delay(1000);
GUI_Clear();
/* Configure the callback function of background window */
WM_SetCallback(WM_HBKWIN, cbBackgroundWin);
/* Create a foreground window */
hWnd = WM_CreateWindow(10, 10, 100, 100,WM_CF_SHOW, cbForegroundWin, 0);
/* Show foreground window */
GUI_Delay(1000);
/* Delete foreground window */
WM_DeleteWindow(hWnd);
/* wait for , The display will redraw */
GUI_Delay(1000);
/* Delete callback function */
WM_SetCallback(WM_HBKWIN, 0);
}
}
void main(void)
{
GUI_Init();
DemoRedraw();
}
4.3.4 Message passing mechanism
Program list 4.2 in , The function performed by the callback function depends on the message received .Switch According to the type of message , Perform different functions separately .
WM_MESSAGE The members of :
MsgId: Message type
HWin: The destination window
HWinSrc: Source window
Data.p : Data pointer
Data.v: Data values
among MsgId Of the following types :
WM_PAINT: Window redraw
WM_CREATE: Send as soon as the window is set up
WM_DELETE: Send as soon as the window is deleted
WM_SIZE : Send when the window size changes
WM_MOVE : Send when the window moves
WM_SHOW : Received show The order is sent
WM_HIDE : Received hide The order is sent
WM_TOUCH: Touch screen information
The application can also define additional messages for itself . To make sure they don't have to uC/GUI The news of ID, User defined messages from WM_USER It starts later , Such as :
#define MY_MESSAGE_AAA WM_USER +0
#define MY_MESSAGE_BBB WM_USER +
版权声明
本文为[shzwork]所创,转载请带上原文链接,感谢
边栏推荐
- Speed up your website with jsdelivr
- Problems of Android 9.0/p WebView multi process usage
- Qt混合Python开发技术:Python介绍、混合过程和Demo
- 洞察——风格注意力网络(SANet)在任意风格迁移中的应用
- A compilation bug brought by vs2015 Update1 update [existing solutions]
- 构造请求日志分析系统
- [C + + learning notes] how about the simple use of the C + + standard library STD:: thread?
- 面部识别:攻击类型和反欺骗技术
- 爆一个VS2015 Update1更新带来的编译BUG【已有解决方案】
- use Xunit.DependencyInjection Transformation test project
猜你喜欢
More than 50 object detection datasets from different industries
Get tree menu list
These core technology of object-oriented, after you master it, you can have a good interview
云计算之路-出海记:整一台 aws 免费云服务器
Data structure and sorting algorithm
一万四千字分布式事务原理解析,全部掌握你还怕面试被问?
delphi10的rest.json与system.json的踩坑
洞察——风格注意力网络(SANet)在任意风格迁移中的应用
Problems of Android 9.0/p WebView multi process usage
手撕算法-手写单例模式
随机推荐
Wanxin Finance
一次公交卡被“盗刷”事件带来的思考
0.计算机简史
Do not understand the underlying principle of database index? That's because you don't have a B tree in your heart
On the concurrency of update operation
Web安全(四)---XSS攻击
C / C + + Programming Notes: what are the advantages of C compared with other programming languages?
IDEA-项目未自动生成 .iml 文件
Sentry installation
密码学-尚硅谷
Python 图片识别 OCR
Implementation of Caesar cipher
16. File transfer protocol, vsftpd service
使用jsDelivr加速你的网站
尾-递
WPF personal summary on drawing
Awk implements SQL like join operation
Cpp(三) 什么是CMake
Go sending pin and email
Privacy violation and null dereference of fortify vulnerability