Commit 440dd86c authored by sam's avatar sam

add emWin sample code

parent 01130fd6
/*********************************************************************
* SEGGER Software GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996 - 2018 SEGGER Microcontroller GmbH *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
** emWin V5.46 - 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 by SEGGER Software GmbH to Nuvoton Technology Corporation
at the address: No. 4, Creation Rd. III, Hsinchu Science Park, Taiwan
for the purposes of creating libraries for its
Arm Cortex-M and Arm9 32-bit microcontrollers, commercialized and distributed by Nuvoton Technology Corporation
under the terms and conditions of an End User
License Agreement supplied with the libraries.
Full source code is available at: www.segger.com
We appreciate your understanding and fairness.
----------------------------------------------------------------------
Licensing information
Licensor: SEGGER Software GmbH
Licensed to: Nuvoton Technology Corporation, No. 4, Creation Rd. III, Hsinchu Science Park, 30077 Hsinchu City, Taiwan
Licensed SEGGER software: emWin
License number: GUI-00735
License model: emWin License Agreement, signed February 27, 2018
Licensed platform: Cortex-M and ARM9 32-bit series microcontroller designed and manufactured by or for Nuvoton Technology Corporation
----------------------------------------------------------------------
Support and Update Agreement (SUA)
SUA period: 2018-03-26 - 2019-03-27
Contact to extend SUA: sales@segger.com
----------------------------------------------------------------------
File : GUIConf.c
Purpose : Display controller initialization
---------------------------END-OF-HEADER------------------------------
*/
#include "GUI.h"
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
//
// Define the available number of bytes available for the GUI
//
#define GUI_NUMBYTES (6 * 1024 * 1024)
//
// Define the average block size
//
#define GUI_BLOCKSIZE 0x80
/*********************************************************************
*
* 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[GUI_NUMBYTES / 4];
//
// Assign memory to emWin
//
GUI_ALLOC_AssignMemory(aMemory, GUI_NUMBYTES);
GUI_ALLOC_SetAvBlockSize(GUI_BLOCKSIZE);
}
/*************************** End of file ****************************/
This source diff could not be displayed because it is too large. You can view the blob instead.
/*********************************************************************
* SEGGER Software GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996 - 2018 SEGGER Microcontroller GmbH *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
** emWin V5.46 - 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 by SEGGER Software GmbH to Nuvoton Technology Corporation
at the address: No. 4, Creation Rd. III, Hsinchu Science Park, Taiwan
for the purposes of creating libraries for its
Arm Cortex-M and Arm9 32-bit microcontrollers, commercialized and distributed by Nuvoton Technology Corporation
under the terms and conditions of an End User
License Agreement supplied with the libraries.
Full source code is available at: www.segger.com
We appreciate your understanding and fairness.
----------------------------------------------------------------------
Licensing information
Licensor: SEGGER Software GmbH
Licensed to: Nuvoton Technology Corporation, No. 4, Creation Rd. III, Hsinchu Science Park, 30077 Hsinchu City, Taiwan
Licensed SEGGER software: emWin
License number: GUI-00735
License model: emWin License Agreement, signed February 27, 2018
Licensed platform: Cortex-M and ARM9 32-bit series microcontroller designed and manufactured by or for Nuvoton Technology Corporation
----------------------------------------------------------------------
Support and Update Agreement (SUA)
SUA period: 2018-03-26 - 2019-03-27
Contact to extend SUA: sales@segger.com
----------------------------------------------------------------------
File : GUIDEMO_ColorBar.c
Purpose : Draws color bars
----------------------------------------------------------------------
*/
#include "GUIDEMO.h"
#if (SHOW_GUIDEMO_COLORBAR)
/*********************************************************************
*
* Define
*
**********************************************************************
*/
#define TIME_PAUSE 500
#define TIME_STEP 500
#define TIME_RUN ((TIME_PAUSE + TIME_STEP) * 6)
#define NUM_COLORS 8
/*********************************************************************
*
* GUIDEMO_ColorBar
*/
extern U8 g_u8GUIItem;
void GUIDEMO_ColorBar(void) {
GUI_COLOR ColorStartBlack;
GUI_COLOR ColorStartWhite;
char acTitle[] = "Color bar";
char acDesc[] = "emWin features an integrated\ncolor management which automatically finds\nthe best available color for any logical color";
char acText[80] = { 0 };
int BitsPerPixel;
int NumColors;
int TimeStart;
int ScreenX0;
int ScreenY0;
int FontY0;
int Index;
int xSize;
int ySize;
int yStep;
int Time;
int Dir;
xSize = LCD_GetXSize();
ySize = LCD_GetYSize();
ScreenX0 = 60;
ScreenY0 = 60;
yStep = (ySize - ScreenY0 * 2) / (NUM_COLORS * 2);
if (yStep < 10) {
yStep = 10;
}
GUIDEMO_ConfigureDemo(acTitle, acDesc, GUIDEMO_SHOW_CURSOR | GUIDEMO_SHOW_CONTROL);
g_u8GUIItem = 2;
GUIDEMO_DrawBk();
//
// Heading
//
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_FontRounded22);
GUI_DispStringHCenterAt("Color bars", xSize / 2, 12);
GUI_SetFont(&GUI_FontSouvenir18);
//
// Colors
//
FontY0 = ScreenY0 + ((yStep * 2 - GUI_GetFontDistY()) / 2);
GUI_DispStringAt("Red", 1, FontY0);
GUI_DispStringAt("Green", 1, FontY0 + yStep * 2);
GUI_DispStringAt("Blue", 1, FontY0 + yStep * 4);
GUI_DispStringAt("Grey", 1, FontY0 + yStep * 6);
GUI_DispStringAt("Yellow", 1, FontY0 + yStep * 8);
GUI_DispStringAt("Cyan", 1, FontY0 + yStep * 10);
GUI_DispStringAt("Magenta", 1, FontY0 + yStep * 12);
GUI_SetFont(&GUI_Font8_ASCII);
//
// LCD Controller
//
#ifdef LCD_CONTROLLER
GUIDEMO_AddStringToString(acText, "LCD Controller: ");
GUIDEMO_AddStringToString(acText, LCD_CONTROLLER);
GUI_DispStringAt (acText, 12, ySize - 45);
GUIDEMO_ClearText (acText);
#endif
//
// BPP and number of colors
//
BitsPerPixel = LCD_GetBitsPerPixel();
GUIDEMO_AddIntToString (acText, BitsPerPixel);
GUIDEMO_AddStringToString(acText, " bpp");
NumColors = LCD_GetDevCap(LCD_DEVCAP_NUMCOLORS);
if (NumColors) {
GUIDEMO_AddStringToString(acText, ", ");
GUIDEMO_AddIntToString (acText, NumColors);
GUIDEMO_AddStringToString(acText, " colors");
}
GUI_DispStringAt(acText, 12, ySize - 25);
//
// Gradients
//
TimeStart = GUIDEMO_GetTime();
while (((GUIDEMO_GetTime() - TimeStart) < TIME_RUN) && (GUIDEMO_CheckCancel() == 0)) {
Time = (GUIDEMO_GetTime() - TimeStart) % ((TIME_PAUSE + TIME_STEP) << 1);
Dir = Time / (TIME_PAUSE + TIME_STEP);
Time -= Dir * (TIME_PAUSE + TIME_STEP);
GUI_Exec();
if (Time > TIME_PAUSE) {
continue;
}
Index = ((Time * 0xFF) / TIME_STEP) ^ (Dir * 0xFF);
ColorStartBlack = 0x000000 + 0x010101 * Index;
ColorStartWhite = 0xFFFFFF - ColorStartBlack;
GUI_DrawGradientH(ScreenX0, ScreenY0 + yStep * 0, xSize - ScreenX0, (ScreenY0 + yStep * 1) - 1, GUI_RED, ColorStartBlack);
GUI_DrawGradientH(ScreenX0, ScreenY0 + yStep * 1, xSize - ScreenX0, (ScreenY0 + yStep * 2) - 1, GUI_RED, ColorStartWhite);
GUI_DrawGradientH(ScreenX0, ScreenY0 + yStep * 2, xSize - ScreenX0, (ScreenY0 + yStep * 3) - 1, GUI_GREEN, ColorStartBlack);
GUI_DrawGradientH(ScreenX0, ScreenY0 + yStep * 3, xSize - ScreenX0, (ScreenY0 + yStep * 4) - 1, GUI_GREEN, ColorStartWhite);
GUI_DrawGradientH(ScreenX0, ScreenY0 + yStep * 4, xSize - ScreenX0, (ScreenY0 + yStep * 5) - 1, GUI_BLUE, ColorStartBlack);
GUI_DrawGradientH(ScreenX0, ScreenY0 + yStep * 5, xSize - ScreenX0, (ScreenY0 + yStep * 6) - 1, GUI_BLUE, ColorStartWhite);
GUI_DrawGradientH(ScreenX0, ScreenY0 + yStep * 6, xSize - ScreenX0, (ScreenY0 + yStep * 7) - 1, GUI_GRAY, ColorStartBlack);
GUI_DrawGradientH(ScreenX0, ScreenY0 + yStep * 7, xSize - ScreenX0, (ScreenY0 + yStep * 8) - 1, GUI_GRAY, ColorStartWhite);
GUI_DrawGradientH(ScreenX0, ScreenY0 + yStep * 8, xSize - ScreenX0, (ScreenY0 + yStep * 9) - 1, GUI_YELLOW, ColorStartBlack);
GUI_DrawGradientH(ScreenX0, ScreenY0 + yStep * 9, xSize - ScreenX0, (ScreenY0 + yStep * 10) - 1, GUI_YELLOW, ColorStartWhite);
GUI_DrawGradientH(ScreenX0, ScreenY0 + yStep * 10, xSize - ScreenX0, (ScreenY0 + yStep * 11) - 1, GUI_CYAN, ColorStartBlack);
GUI_DrawGradientH(ScreenX0, ScreenY0 + yStep * 11, xSize - ScreenX0, (ScreenY0 + yStep * 12) - 1, GUI_CYAN, ColorStartWhite);
GUI_DrawGradientH(ScreenX0, ScreenY0 + yStep * 12, xSize - ScreenX0, (ScreenY0 + yStep * 13) - 1, GUI_MAGENTA, ColorStartBlack);
GUI_DrawGradientH(ScreenX0, ScreenY0 + yStep * 13, xSize - ScreenX0, (ScreenY0 + yStep * 14) - 1, GUI_MAGENTA, ColorStartWhite);
}
g_u8GUIItem = 0;
}
#else
void GUIDEMO_ColorBar_C(void);
void GUIDEMO_ColorBar_C(void) {}
#endif // SHOW_GUIDEMO_COLORBAR
/*************************** End of file ****************************/
/*********************************************************************
* SEGGER Software GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996 - 2018 SEGGER Microcontroller GmbH *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
** emWin V5.46 - 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 by SEGGER Software GmbH to Nuvoton Technology Corporation
at the address: No. 4, Creation Rd. III, Hsinchu Science Park, Taiwan
for the purposes of creating libraries for its
Arm Cortex-M and Arm9 32-bit microcontrollers, commercialized and distributed by Nuvoton Technology Corporation
under the terms and conditions of an End User
License Agreement supplied with the libraries.
Full source code is available at: www.segger.com
We appreciate your understanding and fairness.
----------------------------------------------------------------------
Licensing information
Licensor: SEGGER Software GmbH
Licensed to: Nuvoton Technology Corporation, No. 4, Creation Rd. III, Hsinchu Science Park, 30077 Hsinchu City, Taiwan
Licensed SEGGER software: emWin
License number: GUI-00735
License model: emWin License Agreement, signed February 27, 2018
Licensed platform: Cortex-M and ARM9 32-bit series microcontroller designed and manufactured by or for Nuvoton Technology Corporation
----------------------------------------------------------------------
Support and Update Agreement (SUA)
SUA period: 2018-03-26 - 2019-03-27
Contact to extend SUA: sales@segger.com
----------------------------------------------------------------------
File : GUIDEMO_Conf.c
Purpose : Runtime configurability of the GUIDEMO
----------------------------------------------------------------------
*/
/*********************************************************************
*
* Includes
*
**********************************************************************
*/
#include "GUI.h"
#include "GUIDEMO.h"
#if GUIDEMO_USE_VNC
#include "GUI_VNC.h"
#endif
/*********************************************************************
*
* Routine table
*/
static void (* _apfTest[])(void) = {
#if (SHOW_GUIDEMO_SPEEDOMETER && GUI_SUPPORT_MEMDEV)
GUIDEMO_Speedometer, // 1
#endif
#if (SHOW_GUIDEMO_ZOOMANDROTATE && GUI_WINSUPPORT && GUI_SUPPORT_MEMDEV)
GUIDEMO_ZoomAndRotate, // 2
#endif
#if (SHOW_GUIDEMO_RADIALMENU && GUI_WINSUPPORT)
GUIDEMO_RadialMenu, // 3
#endif
#if (SHOW_GUIDEMO_SKINNING && GUI_WINSUPPORT && GUI_SUPPORT_MEMDEV)
GUIDEMO_Skinning, // 4
#endif
#if (SHOW_GUIDEMO_BARGRAPH && GUI_SUPPORT_MEMDEV)
GUIDEMO_BarGraph, // 5
#endif
#if (SHOW_GUIDEMO_FADING && GUI_SUPPORT_MEMDEV)
GUIDEMO_Fading, // 6
#endif
#if SHOW_GUIDEMO_BITMAP
GUIDEMO_Bitmap, // 7
#endif
#if SHOW_GUIDEMO_AATEXT
GUIDEMO_AntialiasedText, // 8
#endif
#if (SHOW_GUIDEMO_TRANSPARENTDIALOG && GUI_WINSUPPORT && GUI_SUPPORT_MEMDEV)
GUIDEMO_TransparentDialog, // 9
#endif
#if (SHOW_GUIDEMO_WASHINGMACHINE && GUI_WINSUPPORT && GUI_SUPPORT_MEMDEV)
GUIDEMO_WashingMachine, // 10
#endif
#if (SHOW_GUIDEMO_ICONVIEW && GUI_WINSUPPORT && GUI_SUPPORT_MEMDEV)
GUIDEMO_IconView, // 11
#endif
#if (SHOW_GUIDEMO_IMAGEFLOW && GUI_WINSUPPORT && GUI_SUPPORT_MEMDEV)
GUIDEMO_ImageFlow, // 12
#endif
#if (SHOW_GUIDEMO_TREEVIEW && GUI_WINSUPPORT)
GUIDEMO_Treeview, // 13
#endif
#if (SHOW_GUIDEMO_LISTVIEW && GUI_WINSUPPORT)
GUIDEMO_Listview, // 14
#endif
#if SHOW_GUIDEMO_VSCREEN
GUIDEMO_VScreen, // 15
#endif
#if (SHOW_GUIDEMO_GRAPH && GUI_WINSUPPORT && GUI_SUPPORT_MEMDEV)
GUIDEMO_Graph, // 16
#endif
#if SHOW_GUIDEMO_SPEED
GUIDEMO_Speed, // 17
#endif
#if (SHOW_GUIDEMO_CURSOR && GUI_SUPPORT_CURSOR)
GUIDEMO_Cursor, // 18
#endif
#if SHOW_GUIDEMO_COLORBAR
GUIDEMO_ColorBar, // 19
#endif
#if (SHOW_GUIDEMO_AUTOMOTIVE && GUI_SUPPORT_MEMDEV)
GUIDEMO_Automotive, // 20
#endif
0
};
/*********************************************************************
*
* GUIDEMO_Config
*/
void GUIDEMO_Config(GUIDEMO_CONFIG * pConfig) {
pConfig->apFunc = _apfTest;
pConfig->NumDemos = GUI_COUNTOF(_apfTest);
pConfig->Flags = GUIDEMO_CF_SHOW_SPRITES | GUIDEMO_CF_USE_VNC | GUIDEMO_CF_USE_AUTO_BK | GUIDEMO_CF_SUPPORT_TOUCH;
#if GUIDEMO_USE_VNC
pConfig->pGUI_VNC_X_StartServer = GUI_VNC_X_StartServer;
#endif
}
/*************************** End of file ****************************/
/*********************************************************************
* SEGGER Software GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996 - 2018 SEGGER Microcontroller GmbH *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
** emWin V5.46 - 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 by SEGGER Software GmbH to Nuvoton Technology Corporation
at the address: No. 4, Creation Rd. III, Hsinchu Science Park, Taiwan
for the purposes of creating libraries for its
Arm Cortex-M and Arm9 32-bit microcontrollers, commercialized and distributed by Nuvoton Technology Corporation
under the terms and conditions of an End User
License Agreement supplied with the libraries.
Full source code is available at: www.segger.com
We appreciate your understanding and fairness.
----------------------------------------------------------------------
Licensing information
Licensor: SEGGER Software GmbH
Licensed to: Nuvoton Technology Corporation, No. 4, Creation Rd. III, Hsinchu Science Park, 30077 Hsinchu City, Taiwan
Licensed SEGGER software: emWin
License number: GUI-00735
License model: emWin License Agreement, signed February 27, 2018
Licensed platform: Cortex-M and ARM9 32-bit series microcontroller designed and manufactured by or for Nuvoton Technology Corporation
----------------------------------------------------------------------
Support and Update Agreement (SUA)
SUA period: 2018-03-26 - 2019-03-27
Contact to extend SUA: sales@segger.com
----------------------------------------------------------------------
File : GUIDEMO_Cursor.c
Purpose : shows Cursor-API
----------------------------------------------------------------------
*/
#include "GUIDEMO.h"
#if (SHOW_GUIDEMO_CURSOR && GUI_SUPPORT_CURSOR)
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define NUM_CURSORS 3
#define XMAX 28
/*********************************************************************
*
* Types
*
**********************************************************************
*/
typedef struct {
const GUI_CURSOR * pCursor;
char Size;
} CURSOR_INFO;
typedef struct {
CURSOR_INFO aCursor[NUM_CURSORS];
const char * pType;
} CURSORTYPE_INFO;
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
static const CURSORTYPE_INFO _CursorArrow = {
{
{&GUI_CursorArrowS, 'S'},
{&GUI_CursorArrowM, 'M'},
#if (NUM_CURSORS == 3)
{&GUI_CursorArrowL, 'L'},
},
"arrow cursors"
#else
},
"arrow\ncursors"
#endif
};
static const CURSORTYPE_INFO _CursorArrowI = {
{
{&GUI_CursorArrowSI, 'S'},
{&GUI_CursorArrowMI, 'M'},
#if (NUM_CURSORS == 3)
{&GUI_CursorArrowLI, 'L'},
},
"inverted arrow cursors"
#else
},
"inverted\narrow cursors"
#endif
};
static const CURSORTYPE_INFO _CursorCross = {
{
{&GUI_CursorCrossS, 'S'},
{&GUI_CursorCrossM, 'M'},
#if (NUM_CURSORS == 3)
{&GUI_CursorCrossL, 'L'},
},
"cross cursors"
#else
},
"cross\ncursors"
#endif
};
static const CURSORTYPE_INFO _CursorCrossI = {
{
{&GUI_CursorCrossSI, 'S'},
{&GUI_CursorCrossMI, 'M'},
#if (NUM_CURSORS == 3)
{&GUI_CursorCrossLI, 'L'},
},
"inverted cross cursors"
#else
},
"inverted\ncross cursors"
#endif
};
static int _ScreenX0;
static int _ScreenY0;
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _ShowCursorType
*/
static void _ShowCursorType(const CURSORTYPE_INFO* pCursorType, int x0, int y0) {
const GUI_CURSOR * pCursor;
char Char;
int yMax;
int yHot;
int i;
int x;
int y;
yMax = 0;
yHot = 0;
//
// Calculate height and width of biggest cursor
//
for (i = 0; i < NUM_CURSORS; i++) {
pCursor = pCursorType->aCursor[i].pCursor;
if (pCursor->pBitmap->YSize > yMax) {
yMax = pCursor->pBitmap->YSize;
yHot = pCursor->yHot;
}
}
GUI_SetFont(&GUI_FontRounded16);
#if (NUM_CURSORS != 3)
GUI_SetLBorder(x0);
#endif
GUI_DispStringAt(pCursorType->pType, x0, y0);
y0 += GUI_GetFontDistY() + 1;
GUI_SetFont(&GUI_Font13B_ASCII);
for (i = 0; i < NUM_CURSORS; i++) {
pCursor = pCursorType->aCursor[i].pCursor;
Char = pCursorType->aCursor[i].Size;
y = y0 + yHot - pCursor->yHot;
x = ((pCursor->pBitmap->XSize - GUI_GetCharDistX(Char)) / 2);
GUI_DrawBitmap(pCursor->pBitmap, x0 + XMAX * i + 5, y);
GUI_DispCharAt(Char, x0 + XMAX * i + 5 + x, y0 + yMax + 2);
}
}
/*********************************************************************
*
* _DispCursor
*/
extern U8 g_u8GUIItem;
static void _DispCursor(void) {
int xSize;
int ySize;
xSize = LCD_GetXSize();
ySize = LCD_GetYSize();
_ScreenX0 = (xSize - XSIZE_MIN) / 2;
_ScreenY0 = (ySize - YSIZE_MIN) / 2;
g_u8GUIItem = 2;
GUIDEMO_DrawBk();
GUI_SetTextMode(GUI_TM_TRANS);
GUI_SetFont(&GUI_FontRounded22);
GUI_DispStringHCenterAt("Available cursors", xSize / 2, 12);
//
// Display the cursors
//
_ShowCursorType(&_CursorArrow, _ScreenX0 + 20, _ScreenY0 + 50);
_ShowCursorType(&_CursorCross, _ScreenX0 + 20, _ScreenY0 + 120);
_ShowCursorType(&_CursorArrowI, _ScreenX0 + 140, _ScreenY0 + 50);
_ShowCursorType(&_CursorCrossI, _ScreenX0 + 140, _ScreenY0 + 120);
GUIDEMO_Wait(4000);
GUI_CURSOR_Select(&GUI_CursorArrowM);
GUI_CURSOR_Hide();
g_u8GUIItem = 0;
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUIDEMO_Cursor
*/
void GUIDEMO_Cursor(void) {
GUIDEMO_ConfigureDemo("Cursor", "emWin supports\nsoftware cursors", GUIDEMO_SHOW_CURSOR | GUIDEMO_SHOW_CONTROL);
_DispCursor();
}
#else
void GUIDEMO_Cursor_C(void);
void GUIDEMO_Cursor_C(void) {}
#endif // SHOW_GUIDEMO_CURSOR && GUI_SUPPORT_CURSOR
/*************************** End of file ****************************/
/*********************************************************************
* SEGGER Software GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996 - 2018 SEGGER Microcontroller GmbH *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
** emWin V5.46 - 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 by SEGGER Software GmbH to Nuvoton Technology Corporation
at the address: No. 4, Creation Rd. III, Hsinchu Science Park, Taiwan
for the purposes of creating libraries for its
Arm Cortex-M and Arm9 32-bit microcontrollers, commercialized and distributed by Nuvoton Technology Corporation
under the terms and conditions of an End User
License Agreement supplied with the libraries.
Full source code is available at: www.segger.com
We appreciate your understanding and fairness.
----------------------------------------------------------------------
Licensing information
Licensor: SEGGER Software GmbH
Licensed to: Nuvoton Technology Corporation, No. 4, Creation Rd. III, Hsinchu Science Park, 30077 Hsinchu City, Taiwan
Licensed SEGGER software: emWin
License number: GUI-00735
License model: emWin License Agreement, signed February 27, 2018
Licensed platform: Cortex-M and ARM9 32-bit series microcontroller designed and manufactured by or for Nuvoton Technology Corporation
----------------------------------------------------------------------
Support and Update Agreement (SUA)
SUA period: 2018-03-26 - 2019-03-27
Contact to extend SUA: sales@segger.com
----------------------------------------------------------------------
File : GUIDEMO_Intro.c
Purpose : Introduction for emWin generic demo
(This is also a good file to demo and explain basic
emWin features by setting breakpoints)
----------------------------------------------------------------------
*/
#include <string.h>
#include "GUIDEMO.h"
/*********************************************************************
*
* Defines
*/
#define SCREEN_DIV 6 // 2^6 = 64
#define FACTOR_EMWIN 4
#define FACTOR_DESC 11
#define FACTOR_ANY_COMP 22
#define FACTOR_VERSION 31
#define FACTOR_LOGO 38
#define FACTOR_WWW 56
#define DIST_ANY_COMP 18
volatile static char s_u8ShowNuvotonQRCodeFlag;
/*********************************************************************
*
* GUIDEMO_Intro
*
**********************************************************************
*/
void GUIDEMO_Intro(void) {
unsigned xCenter;
unsigned xSize;
unsigned ySize;
char acVersion[30] = "Version of emWin: ";
xSize = LCD_GetXSize();
ySize = LCD_GetYSize();
xCenter = xSize / 2;
GUIDEMO_DrawBk();
GUI_SetTextMode(GUI_TM_TRANS);
//
if (s_u8ShowNuvotonQRCodeFlag)
{
GUI_SetBkColor(GUI_WHITE);
GUI_Clear();
GUI_DrawBitmap(&bmnuvoton_qrcode, (xSize - bmnuvoton_qrcode.XSize) >> 1, (ySize - bmnuvoton_qrcode.YSize) >> 1);
GUI_SetColor(GUI_RED);
GUI_SetFont(&GUI_FontRounded22);
GUI_DispStringHCenterAt("www.nuvoton.com", xCenter, 6);
GUIDEMO_Delay(3000);
GUIDEMO_DrawBk();
}
s_u8ShowNuvotonQRCodeFlag = 1;
// emWin
//
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_FontRounded22);
GUI_DispStringHCenterAt("emWin", xCenter, (FACTOR_EMWIN * ySize) >> SCREEN_DIV);
//
// emWin description
//
GUI_SetFont(&GUI_FontSouvenir18);
GUI_DispStringHCenterAt("Universal graphic software\nfor embedded applications", xCenter, (FACTOR_DESC * ySize) >> SCREEN_DIV);
//
// Any text
//
GUI_SetColor(GUI_MAKE_COLOR(0x2288ff));
GUI_DispStringHCenterAt("Any CPU - Any Display - Any Application", xCenter, (FACTOR_ANY_COMP * ySize) >> SCREEN_DIV);
//
// Compiled
//
GUI_SetFont(&GUI_Font10S_ASCII);
GUI_DispStringHCenterAt("Compiled " __DATE__ " "__TIME__, xCenter, ((FACTOR_ANY_COMP * ySize) >> SCREEN_DIV) + DIST_ANY_COMP);
//
// Version
//
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_FontSouvenir18);
strcat(acVersion, GUI_GetVersionString());
GUI_DispStringHCenterAt(acVersion, xCenter, (FACTOR_VERSION * ySize) >> SCREEN_DIV);
//
// Logo
//
GUI_DrawBitmap(&bmnuvoton_logo_140x70, (xSize - bmnuvoton_logo_140x70.XSize) >> 1, (FACTOR_LOGO * ySize) >> SCREEN_DIV);
//
// www.segger.com
//
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_FontRounded22);
GUI_DispStringHCenterAt("www.nuvoton.com", xCenter - 4, (FACTOR_WWW * ySize) >> SCREEN_DIV);
GUIDEMO_Delay(5000);
}
/*************************** End of file ****************************/
/*********************************************************************
* SEGGER Software GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1996 - 2018 SEGGER Microcontroller GmbH *
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
** emWin V5.46 - 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 by SEGGER Software GmbH to Nuvoton Technology Corporation
at the address: No. 4, Creation Rd. III, Hsinchu Science Park, Taiwan
for the purposes of creating libraries for its
Arm Cortex-M and Arm9 32-bit microcontrollers, commercialized and distributed by Nuvoton Technology Corporation
under the terms and conditions of an End User
License Agreement supplied with the libraries.
Full source code is available at: www.segger.com
We appreciate your understanding and fairness.
----------------------------------------------------------------------
Licensing information
Licensor: SEGGER Software GmbH
Licensed to: Nuvoton Technology Corporation, No. 4, Creation Rd. III, Hsinchu Science Park, 30077 Hsinchu City, Taiwan
Licensed SEGGER software: emWin
License number: GUI-00735
License model: emWin License Agreement, signed February 27, 2018
Licensed platform: Cortex-M and ARM9 32-bit series microcontroller designed and manufactured by or for Nuvoton Technology Corporation
----------------------------------------------------------------------
Support and Update Agreement (SUA)
SUA period: 2018-03-26 - 2019-03-27
Contact to extend SUA: sales@segger.com
----------------------------------------------------------------------
File : GUIDEMO_Speed.c
Purpose : Speed demo
----------------------------------------------------------------------
*/
#include "GUIDEMO.h"
#if (SHOW_GUIDEMO_SPEED)
#include <stdlib.h> // rand()
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
static const GUI_COLOR _aColor[8] = {
0x000000,
0x0000FF,
0x00FF00,
0x00FFFF,
0xFF0000,
0xFF00FF,
0xFFFF00,
0xFFFFFF
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
/*********************************************************************
*
* _GetPixelsPerSecond
*/
static U32 _GetPixelsPerSecond(void) {
GUI_COLOR BkColor;
GUI_COLOR Color;
I32 PixelsPerSecond;
I32 PixelCnt;
I32 t0;
I32 t;
U32 xSize;
U32 ySize;
U32 Cnt;
U32 x0;
U32 x1;
U32 y0;
U32 y1;
//
// Find an area which is not obstructed by any windows
//
xSize = LCD_GetXSize();
ySize = LCD_GetYSize();
Cnt = 0;
x0 = 0;
x1 = xSize - 1;
y0 = 65;
y1 = ySize - 60 - 1;
Color = GUI_GetColor();
BkColor = GUI_GetBkColor();
GUI_SetColor(BkColor);
//
// Repeat fill as often as possible in 100 ms
//
t0 = GUIDEMO_GetTime();
do {
GUI_FillRect(x0, y0, x1, y1);
Cnt++;
t = GUIDEMO_GetTime();
} while ((t - (t0 + 100)) <= 0);
//
// Compute result
//
t -= t0;
PixelCnt = (x1 - x0 + 1) * (y1 - y0 + 1) * Cnt;
PixelsPerSecond = PixelCnt / t * 1000;
GUI_SetColor(Color);
return PixelsPerSecond;
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* GUIDEMO_Speed
*/
void GUIDEMO_Speed(void) {
#if GUI_SUPPORT_TOUCH
GUI_PID_STATE State;
#endif
GUI_RECT ClipRect;
GUI_RECT Rect;
char acText[40] = { 0 };
U32 PixelsPerSecond;
int aColorIndex[8];
int TimeStart;
int vySize;
int xSize;
int ySize;
int i;
GUIDEMO_ConfigureDemo("High speed", "Multi layer clipping\nHighly optimized drivers", 0);
xSize = LCD_GetXSize();
ySize = LCD_GetYSize();
vySize = LCD_GetVYSize();
if (vySize > ySize) {
ClipRect.x0 = 0;
ClipRect.y0 = 0;
ClipRect.x1 = xSize;
ClipRect.y1 = ySize;
GUI_SetClipRect(&ClipRect);
}
for (i = 0; i< 8; i++) {
aColorIndex[i] = GUI_Color2Index(_aColor[i]);
}
TimeStart = GUIDEMO_GetTime();
for (i = 0; ((GUIDEMO_GetTime() - TimeStart) < 5000) && (GUIDEMO_CheckCancel() == 0); i++) {
GUI_SetColorIndex(aColorIndex[i&7]);
//
// Calculate random positions
//
Rect.x0 = rand() % xSize - xSize / 2;
Rect.y0 = rand() % ySize - ySize / 2;
Rect.x1 = Rect.x0 + 20 + rand() % xSize;
Rect.y1 = Rect.y0 + 20 + rand() % ySize;
GUI_FillRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1);
//
// Clip rectangle to visible area and add the number of pixels (for speed computation)
//
if (Rect.x1 >= xSize) {
Rect.x1 = xSize - 1;
}
if (Rect.y1 >= ySize) {
Rect.y1 = ySize - 1;
}
if (Rect.x0 < 0 ) {
Rect.x0 = 0;
}
if (Rect.y1 < 0) {
Rect.y1 = 0;
}
//
// There is no control window. A simple click on any position has to skip the demo.
//
#if GUI_SUPPORT_TOUCH
GUI_PID_GetState(&State);
if (State.Pressed) {
break;
}
#endif
}
GUIDEMO_NotifyStartNext();
PixelsPerSecond = _GetPixelsPerSecond();
GUI_SetClipRect(NULL);
GUIDEMO_AddStringToString(acText, "Pixels/sec: ");
GUIDEMO_AddIntToString(acText, PixelsPerSecond);
GUIDEMO_DrawBk();
GUI_SetColor(GUI_WHITE);
GUI_SetTextMode(GUI_TM_TRANS);
GUI_SetFont(&GUI_FontRounded22);
GUI_DispStringHCenterAt(acText, xSize / 2, (ySize - GUI_GetFontSizeY()) / 2);
GUIDEMO_ConfigureDemo(NULL, NULL, GUIDEMO_SHOW_CURSOR | GUIDEMO_SHOW_CONTROL);
GUIDEMO_Delay(4000);
}
#else
void GUIDEMO_Speed_C(void);
void GUIDEMO_Speed_C(void) {}
#endif // SHOW_GUIDEMO_SPEED
/*************************** End of file ****************************/
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment