FA95 UDC Library Reference Guide Em Win Start N9H26 Series
User Manual:
Open the PDF directly: View PDF .
Page Count: 20
![](asset-1.png)
GUI emWin
Start Guide
V1.00.007
Publication Release Date: Dec. 2018
Support Chips:
Support Platforms:
N9H26 Series
Non-OS
![](asset-2.png)
GUI emWin Start Guide
V1.00.007
- 2 -
The information in this document is subject to change without notice.
The Nuvoton Technology Corp. shall not be liable for technical or editorial errors or omissions
contained herein; nor for incidental or consequential damages resulting from the furnishing,
performance, or use of this material.
This documentation may not, in whole or in part, be copied, photocopied, reproduced,
translated, or reduced to any electronic medium or machine readable form without prior consent,
in writing, from the Nuvoton Technology Corp.
Nuvoton Technology Corp. All rights reserved.
![](asset-3.png)
GUI emWin Start Guide
V1.00.007
- 3 -
Table of Contents
1. Introduction ............................................................................................................. 4
1.1. Introduction ............................................................................................................................ 4
1.2. emWin Folder structure .......................................................................................................... 5
1.3. Resource link .......................................................................................................................... 6
1.4. How to update application binary ........................................................................................... 7
2. Start emWin ............................................................................................................ 8
2.1. Step 1: Open project ............................................................................................................... 8
2.2. Step 2: BSP Initialization ....................................................................................................... 9
2.3. Step 3: emWin Initialization ................................................................................................. 10
2.4. Step 4: Build ......................................................................................................................... 11
2.5. Before download and run ..................................................................................................... 12
2.6. Step 5: Download and run .................................................................................................... 13
2.7. Touch screen ......................................................................................................................... 14
3. Start emWin GUIBuilder ..................................................................................... 15
3.1. Step 1: Create widget ............................................................................................................ 15
3.2. Step 2: Handle widget event ................................................................................................. 16
4. How to change display panel ............................................................................... 17
4.1. Step 1: emWin display .......................................................................................................... 17
4.2. Step 2: BSP display .............................................................................................................. 18
5. Revision History .................................................................................................... 19
![](asset-4.png)
GUI emWin Start Guide
V1.00.007
- 4 -
1. Introduction
1.1. Introduction
emWin is a graphic library with graphical user interface (GUI). It is designed to provide an efficient,
processor- and display controller-independent graphical user interface (GUI) for any application that
operates with a graphical display.
Figure 1.1-1 emWin runs on N9H26.
N9H26 BSP includes emWin related materials, e. g., sample codes, library, documents and tools. We
can develop emWin applications on Keil MDK incudes IDE, compiler and debugger (embedded
development tools for Arm) to build, modify and debug. We’ll introduce the basic operations on
section 2.4.
![](asset-5.png)
GUI emWin Start Guide
V1.00.007
- 5 -
1.2. emWin Folder structure
N9H26 BSP contains emWin related materials and the folder structure is shown below:
Directory Name
Content
SampleCode \ emWin
Two emWin samples:
1. GUIDemo
2. SimpleDemo
ThirdParty \ emWin \ Config
emWin configuration files
ThirdParty \ emWin \ Doc
Two emWin official documents:
1. AN03002_Custom_Widget_Type.pdf
2. UM03001_emWin5.pdf
ThirdParty \ emWin \ Include
emWin include files
ThirdParty \ emWin \ Lib
emWin library: NUemWin_ARM9_Keil.lib
ThirdParty \ emWin \ Tool
emWin tools
![](asset-6.png)
GUI emWin Start Guide
V1.00.007
- 6 -
1.3. Resource link
We can utilize official websites for further assistance, here is the reouce link table:
Topic
Resource link
SEGGER
Forum
SEGGER emWin official forum link:
https://forum.segger.com/index.php/Board/12-emWin-related/
Nuvoton
Forum
Nuvoton HMI/GUI official forum link:
http://forum.nuvoton.com/viewforum.php?f=31&sid=94265886594b34c7cd812d3f74c
44fec
http://nuvoton-mcu.com/forum.php?mod=forumdisplay&fid=86
Nuvoton
Website
Nuvoton official website entrance link:
https://www.nuvoton.com/
Nuvoton
BSP
The latest N9H26 BSP GitHub link:
https://github.com/OpenNuvoton/N9H26_emWin_NonOS
Data Sheet
Parts information list and pin configuration link:
http://www.nuvoton.com/hq/products/application-specific-socs/hmi-emwin-
mpus/Data-Sheet/?__locale=en&resourcePage=Y
PCB
Development
Tool
PCB schematic link:
http://www.nuvoton.com/hq/products/application-specific-socs/hmi-emwin-
mpus/Development-Tool/?__locale=en&resourcePage=Y
Online
Training
Video for creating control interface:
http://www.nuvoton.com/hq/products/application-specific-socs/hmi-emwin-
mpus/Online-Training/?__locale=en&resourcePage=Y
Software
BSP in zipped format:
http://www.nuvoton.com/hq/products/application-specific-socs/hmi-emwin-
mpus/Software/?__locale=en&resourcePage=Y
User Manual
Demo board user manual:
http://www.nuvoton.com/hq/products/application-specific-socs/hmi-emwin-
mpus/User-Manual/?__locale=en&resourcePage=Y
![](asset-7.png)
GUI emWin Start Guide
V1.00.007
- 7 -
1.4. How to update application binary
We can update application binary through USB cable to device and here are the steps:
1. Power off device.
2. Plug in USB cable to PC/NB.
3. Keep pressing “Up” and “Down” button.
4. Power on device.
5. After 5 seconds, then release “Up” and “Down” button.
6. Rename application binary to “conprog.bin”.
7. Copy and replace “conprog.bin” to “SD1-1”.
8. Remove USB device safely.
9. Plug out USB cable from PC/NB.
10. Reset device.
Here are the pre-built application binaries for SimpleDemo and GUIDemo:
SimpleDemo application binary:
The path is in “BSP\SampleCode\emWin\SimpleDemo\Bin\”
Sample Target
Pre-built Application Binary
Simple_N9H26K5_SD_800x480
For 800 x 480 LCD with microSD card:
SimpleDemo_N9H26K5_SD_800x480.bin
GUIDemo application binary:
The path is in “BSP\SampleCode\emWin\GUIDemo\Bin\”
Sample Target
Pre-built Application Binary
GUI_N9H26K5_SD_800x480
For 800 x 480 LCD with microSD card:
GUIDemo_N9H26K5_SD_800x480.bin
Please note that we need to rename application binary to “conprog.bin” before copy to “SD1-1”.
![](asset-8.png)
GUI emWin Start Guide
V1.00.007
- 8 -
2. Start emWin
2.1. Step 1: Open project
Double click “SimpleDemo.uvproj” (the path is in “SampleCode\emWin\SimpleDemo\KEIL”) to open
project.
Figure 2.1-1 “SimpleDemo” project file.
“SimpleDemo” is a sample code to utilize emWin library to demonstrate interactive feature. It contains
a frame window, four buttons, a text and a text editor. We can touch the GUI button and check the
result that shown on the text editor.
The path of “SimpleDemo” is in “SampleCode\emWin”.
Figure 2.1-2 “SimpleDemo” sample folder is in “SampleCode\emWin”.
The structure of “SimpleDemo”:
- Blue part is related with BSP.
- Red part is related with emWin.
Figure 2.1-3 “SimpleDemo” project structure.
![](asset-9.png)
GUI emWin Start Guide
V1.00.007
- 9 -
2.2. Step 2: BSP Initialization
In “main.c”, it contains the N9H26 start up flow, e.g., clock setting, timer, uart debug port, display
output panel, vendor filesystem and resistor-type touch screen.
The path of “main.c” is in “SampleCode\emWin\SimpleDemo”:
Figure 2.2-1 “main.c” contains N9H26 start up flow.
int main(void)
{
...
/* N9H26 start up here */
...
/* emWin start up here */
MainTask();
return 0;
}
![](asset-a.png)
GUI emWin Start Guide
V1.00.007
- 10 -
2.3. Step 3: emWin Initialization
In “main.c”, called “MainTask()” to start up emWin GUI system.
“MainTask()” is in “SampleCode\emWin\SimpleDemo\main.c”:
void MainTask(void)
{
GUI_Init();
CreateFramewin();
while (1)
{
GUI_Delay(500);
}
}
![](asset-b.png)
GUI emWin Start Guide
V1.00.007
- 11 -
2.4. Step 4: Build
Please note that we suggest to utilize Keil MDK version 5 or above with professional or plus license.
To download and run the application, first, we need to utilize Keil to rebuild the application project.
Press “[F7]” to rebuild the application project or click “Rebuild”.
Figure 2.4-1 Rebuild application project.
![](asset-c.png)
GUI emWin Start Guide
V1.00.007
- 12 -
2.5. Before download and run
IMPORTANT!!! We need to configurate ICE setting to download and run.
Press “[Alt + F7]” for project options.
Figure 2.5-1 Options for target.
Choose “Debug” page and select properly ICE, e. g., J-LINK, then press “Settings”.
Figure 2.5-2 Select ICE to debug.
Set “Speed” (Auto or lower speed), disable “Debug Cache”, then select “Reset Strategy as Hardware, halt
after reset (normal)”, finally, click “OK”.
Figure 2.5-3 ICE environment setting.
![](asset-d.png)
GUI emWin Start Guide
V1.00.007
- 13 -
2.6. Step 5: Download and run
Press “CTRL + [F5]” to download the application and run debug session. After downloaded, it will halt
at main() and we should see the similar screenshow below.
Figure 2.6-1 Download and run application.
Figure 2.6-2 Debug session.
![](asset-e.png)
GUI emWin Start Guide
V1.00.007
- 14 -
2.7. Touch screen
To control touch panel, we utilize N9H26 ADC library and open source library “tslib”. The touch
calibration results store to a single file called “ts_calib”.
The path of “tslib” is in “SampleCode\emWin\SimpleDemo”:
Figure 2.7-1 tslib structure.
![](asset-f.png)
GUI emWin Start Guide
V1.00.007
- 15 -
3. Start emWin GUIBuilder
3.1. Step 1: Create widget
To create widget, we can utilize emWin “GUIBuilder” to arrange GUI layout and generate source file.
The path of “GUIBuilder” is in “ThirdParty\emWin\Tool”:
Figure 3.1-1 emWin GUIBuilder.
After finish GUI layout, then execute “File” “Save…”, we can get the source file called
“FramewinDLG.c”.
Figure 3.1-2 emWin GUIBuilder can arrange GUI layout and generate source file.
![](asset-10.png)
GUI emWin Start Guide
V1.00.007
- 16 -
3.2. Step 2: Handle widget event
In “FramewinDLG.c”, we can handle widget event, e. g., button clicked, released or others and update
text editor’s content when button released.
The path of “FramewinDLG.c” is in “SampleCode\emWin\SimpleDemo\Application”:
Figure 3.2-1 emWin GUI application source file.
...
switch(Id)
{
case ID_BUTTON_0: // Notifications sent by '+ 1'
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
value += 1;
sprintf(sBuf,"%d ", value);
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
EDIT_SetText(hItem, sBuf);
// USER END
break;
// USER START (Optionally insert additional code for further notification
handling)
// USER END
}
break;
...
![](asset-11.png)
GUI emWin Start Guide
V1.00.007
- 17 -
4. How to change display panel
4.1. Step 1: emWin display
“LCDConf.c” defines emWin display configurations.
The path of “LCDConf.c” is in “ThirdParty\emWin\Config”:
Figure 4.1-1 emWin display configurations.
- Display panel resolution:
In “N9H26TouchPanel.h”, we can modify the “XSIZE_PHYS” and “YSIZE_PHYS” for display
panel width and height respectively. Please note that “XSIZE_PHYS” and YSIZE_PHYS” are
defined in “SampleCode\emWin\SimpleDemo\tslib\N9H26TouchPanel.h”.
...
#define XSIZE_PHYS 320
#define YSIZE_PHYS 240
...
- Display buffer address:
In “LCDConf.c”, we can assign display buffer address to emWin. Here, we utilize a “Sync-type
LCD 320x240”, the display buffer size in RGB565 is 320-width x 240-height x 2-byte-per-pixel =
153600Bytes = 150KB.
void LCD_X_Config(void)
{
...
/* assign display buffer address to emWin */
LCD_SetVRAMAddrEx(0, (void *)u8FrameBufPtr);
...
}
![](asset-12.png)
GUI emWin Start Guide
V1.00.007
- 18 -
4.2. Step 2: BSP display
N9H26 can utilize VPOST library to output display data to “Sync-type LCD”. N9H26 BSP contains the
default display library for 320 x 240 at 16-bit depth RGB565.
The path of the default display library is in “Library\IPLib\N9H26_GIANTPLUS_GPM1006D.lib“.
Figure 4.2-1 BSP default display library.
void LCD_X_Config(void)
{
...
/* assign display buffer address to emWin */
LCD_SetVRAMAddrEx(0, (void *)u8FrameBufPtr);
...
}
![](asset-13.png)
GUI emWin Start Guide
V1.00.007
- 19 -
5. Revision History
Version
Date
Description
V1.00.007
Dec. 28, 2018
- Update
- Update pre-built path to “Bin”
V1.00.006
Dec. 25, 2018
- Update footer version
- Update Nuvoton HMI/GUI forum link
V1.00.005
Dec. 25, 2018
- Add official SEGGER emWin forum link
- Add Nuvoton resource link
- Add how to update application
V1.00.004
Oct. 11, 2018
- Update N9H26 PCB picture
V1.00.003
Sep. 13, 2018
- Update source path and description
V1.00.002
Aug. 17, 2018
- Update introduction for Keil MDK
V1.00.001
Mar. 30, 2018
- Created
![](asset-14.png)
GUI emWin Start Guide
V1.00.007
- 20 -
Important Notice
Nuvoton products are not designed, intended, authorized or warranted for use as components in
equipment or systems intended for surgical implantation, atomic energy control instruments,
aircraft or spacecraft instruments, transportation instruments, traffic signal instruments,
combustion control instruments, or for any other applications intended to support or sustain life.
Furthermore, Nuvoton products are not intended for applications whereby failure could result or
lead to personal injury, death or severe property or environmental damage.
Nuvoton customers using or selling these products for such applications do so at their own risk
and agree to fully indemnify Nuvoton for any damages resulting from their improper use or
sales.