stemwin graphical library

36
© BME-MIT 2018 Budapest University of Technology and Economics Department of Measurement and Information Systems ARM Cortex core microcontrollers STemWin Graphical Library Balázs Scherer

Upload: others

Post on 17-Feb-2022

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: STemWin Graphical Library

© BME-MIT 2018Budapest University of Technology and EconomicsDepartment of Measurement and Information Systems

ARM Cortex core microcontrollers

STemWin Graphical Library

Balázs Scherer

Page 2: STemWin Graphical Library

© BME-MIT 2018 2.

LCD display drivers

Page 3: STemWin Graphical Library

© BME-MIT 2018 3.

LCD display drivers

LCD with integrated controller and pixel memory

o Typicaly programmable through SPI

o Pixels are mapped to memory values

LCD without an integrated controller

o Complicated, requires high speed interfacing and huge amount of pixel memory

o Cannot be done without hardware peripheral support

Page 4: STemWin Graphical Library

© BME-MIT 2018 4.

LCD controller

TFT LCD controller

Page 5: STemWin Graphical Library

© BME-MIT 2018 5.

LCD controller

Page 6: STemWin Graphical Library

© BME-MIT 2018 6.

Memory requirement of LCD controllers

Usually single buffer is not enough. For multi layer graphical display multiple of the amount in the table is needed.

Page 7: STemWin Graphical Library

© BME-MIT 2018 7.

Graphical controller support of STM32f429

Page 8: STemWin Graphical Library

© BME-MIT 2018 8.

Graphical controller support of STM32f429

Uses 3 different clockso memória interface, regiszter, LCD control

Programable LCD timing: V, H sync

Up to 24 bit RBG color

Maximum 800x600 pixels

Support for multi layers: 2 + background

Ditherelés 2 bit / color

Page 9: STemWin Graphical Library

© BME-MIT 2018 9.

Chrom-ART Accelerator (DMA2D)

CPU can do other jobs: o Copying pictures, creating layered display

Page 10: STemWin Graphical Library

© BME-MIT 2018 10.

STM32 FMC controller: external memory

interface

External memory interfacing:o SDRAM, SRAM, Flash

o Max. 90 MHz, max. 32bit

SDRAM handling:o Periodic refresh is needed

o Low power modes are present

Page 11: STemWin Graphical Library

© BME-MIT 2018 11.

The emWIN Graphical library

Page 12: STemWin Graphical Library

© BME-MIT 2018 12.

Segger emWin Graphical Library

Portable graphical library

For 8,16, 32-bit microcontrollers

Optional RTOS support

Minimum configuration ~20kbyte Flash ~1k RAM

Not a free software library

o Many manufacturer made it free for their chipsets

Page 13: STemWin Graphical Library

© BME-MIT 2018 13.

Basic 2D library

Basic shapes and text datao Lines, squares, Circuits, triangles

o JPEG, PNG and bitmap displaying

o Shapes are drown with the front color, which is setable

GUI_SetColor(GUI_RED);

Page 14: STemWin Graphical Library

© BME-MIT 2018 14.

Example for using the 2D library I.

Page 15: STemWin Graphical Library

© BME-MIT 2018 15.

Example for using the 2D library II.

Page 16: STemWin Graphical Library

© BME-MIT 2018 16.

Example for using the 2D library III.

Page 17: STemWin Graphical Library

© BME-MIT 2018 17.

Example for using the 2D library IV.

Bárhova a képernyőn, akár saját betűtípusokkal

Szövegdobozok és létrehozhatók

Page 18: STemWin Graphical Library

© BME-MIT 2018 18.

Text displaying

With an external program user can create own character set.

Page 19: STemWin Graphical Library

© BME-MIT 2018 19.

Displaying pictures

Using an external program to create const data from the pictureo BmpCvt.exe: from bitmap

o Bin2c.exe: from other binary data

Page 20: STemWin Graphical Library

© BME-MIT 2018 20.

Human interface

Typically there are keyboard, key or cursor data

There are interface functions to handle these data

o GUI_StoreKeyMsg(): handling keyboard incoming data

o GUI_PID_StoreState(): Pointer Input Device event

o GUI_TOUCH_StoreState(): Touch screenevent

Page 21: STemWin Graphical Library

© BME-MIT 2018 21.

Windows system in emWin

Hierarchical windowed system

Using callbacks to handle data

Widget are used for user interface

Can work with RTOS, or without it.

Page 22: STemWin Graphical Library

© BME-MIT 2018 22.

Working without an RTOS

GUI_Exec() function should be called periodicaly

Need to use the interface functions of the human interface devices too.

Page 23: STemWin Graphical Library

© BME-MIT 2018 23.

With RTOS

A dedicated thread is needed. Functions to call:GUI_Exec(), GUI_Delay()

Need to configure in a header file (GUIConf.h)

Page 24: STemWin Graphical Library

© BME-MIT 2018 24.

Widget: Window + Gadget

Typically used embedded user interfaces

Page 25: STemWin Graphical Library

© BME-MIT 2018 25.

Creating a widget

Directly

o All widget has a handler and a dedicated function to create

o <WIDGET>_CreateEx() // Creation without user data.

o <WIDGET>_CreateUser() // Creation with user data

Indirectly

o Embedded to a dialog

o Dialog will contain the creation table

o <WIDGET>_CreateIndirect()

Page 26: STemWin Graphical Library

© BME-MIT 2018 26.

GUI builder

Windows based program to create a UI

Page 27: STemWin Graphical Library

© BME-MIT 2018 27.

Using STemWin

Page 28: STemWin Graphical Library

© BME-MIT 2018 28.

Creating a simple example

Currently no support for graphical library in CubeMx to the AtollicTruestudio

Download the example project from the home page

o STemwin_01.zip

o Unzip it into the Workspace

o Import / existing project into the workspace

Page 29: STemWin Graphical Library

© BME-MIT 2018 29.

Checking the project setups

Project uses external libraries and files from the Cube software library, The paths to these include folders and libraries should be given precisely and should be modified in different environment

o Project expect the Cube Repository under C:\Users\first_user\STM32Cube\

o And the STemWinC:\Users\first_user\STM32Cube\Repository\STM32Cube_FW_F4_V1.21.0\Middlewares\ST\STemWin

o Properties / C/C++ General / Paths and Symbols

Include

Libraries

Library paths

Page 30: STemWin Graphical Library

© BME-MIT 2018 30.

Includes

Page 31: STemWin Graphical Library

© BME-MIT 2018 31.

Libraries

Page 32: STemWin Graphical Library

© BME-MIT 2018 32.

Library path

Page 33: STemWin Graphical Library

© BME-MIT 2018 33.

Architecture of the demo project

Main function:

o Development board and, LCD inicialisation

o Starting the Demo

o Touch screen interrupt handling, timing handling

Basic_HelloWorld:

o Gui clear

o Setting character set

o Displaying a text

Page 34: STemWin Graphical Library

© BME-MIT 2018 34.

2D graphic example

void MainTask(void) {GUI_SetBkColor(GUI_WHITE);GUI_Clear();GUI_SetColor(GUI_RED);GUI_FillCircle(120, 120, 80);GUI_SetColor(GUI_BLUE);GUI_FillCircle(140, 140, 80);GUI_SetFont(&GUI_Font20_1);GUI_DispStringAt("Hello world!", (LCD_GetXSize()-

100)/2, (LCD_GetYSize()-20)/2);while(1);

}

Page 35: STemWin Graphical Library

© BME-MIT 2018 35.

Creating Widgets

Use Gui builder

Copy the generated file into the project

Call the Window inicialisation function (Create…)

Modify bahaviour

Call the GUI_Exec() periodically

Page 36: STemWin Graphical Library

© BME-MIT 2018 36.

GUI builder

void MainTask(void) {GUI_Clear();CreateAblak();while(1){GUI_Exec();}

}