LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
main.c
Go to the documentation of this file.
1 /*
2  * @brief emWin Hello World example
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2012
6  * All rights reserved.
7  *
8  * @par
9  * Software that is described herein is for illustrative purposes only
10  * which provides customers with programming information regarding the
11  * LPC products. This software is supplied "AS IS" without any warranties of
12  * any kind, and NXP Semiconductors and its licensor disclaim any and
13  * all warranties, express or implied, including all implied warranties of
14  * merchantability, fitness for a particular purpose and non-infringement of
15  * intellectual property rights. NXP Semiconductors assumes no responsibility
16  * or liability for the use of the software, conveys no license or rights under any
17  * patent, copyright, mask work right, or any other intellectual property rights in
18  * or to any products. NXP Semiconductors reserves the right to make changes
19  * in the software without notification. NXP Semiconductors also makes no
20  * representation or warranty that such application will be suitable for the
21  * specified use without further testing or modification.
22  *
23  * @par
24  * Permission to use, copy, modify, and distribute this software and its
25  * documentation is hereby granted, under NXP Semiconductors' and its
26  * licensor's relevant copyrights in the software, without fee, provided that it
27  * is used in conjunction with NXP Semiconductors microcontrollers. This
28  * copyright, permission, and disclaimer notice must appear in all copies of
29  * this code.
30  */
31 
32 #include "GUI.h"
33 #include "board.h"
34 
50 /*****************************************************************************
51  * Private types/enumerations/variables
52  ****************************************************************************/
53 
54 /* LCD width and height (from board LCD setup descriptor) */
55 #define LCD_WIDTH BOARD_LCD.PPL
56 #define LCD_HEIGHT BOARD_LCD.LPP
57 
58 #if defined(__IAR_SYSTEMS_ICC__)
59  #define LOCATE_AT(x) LOCATE_ATXX(x)
60 #elif defined(__ARMCC_VERSION)
61  #define LOCATE_AT(x) __attribute__ ((at(x)))
62 #elif (defined(__CODE_RED))
63  #define LOCATE_AT(x) LOCATE_ATX(x)
64 #endif
65 
66 /*****************************************************************************
67  * Public types/enumerations/variables
68  ****************************************************************************/
69 
73 #define GUI_BUF LOCATE_AT(GUI_BUF_ADDR)
74 #define GUI_BUF_ADDR (FRAMEBUFFER_ADDR + 0x00050000)
75 #define GUI_NUMBYTES ((1024 * 1024) * 2)
77 U32 GUI_Block_Size = 0x128;
78 GUI_BUF U32 GUI_Memory[GUI_NUMBYTES / sizeof(U32)];
79 
84 
85 /*****************************************************************************
86  * Private functions
87  ****************************************************************************/
88 
89 /* mSec delay */
90 static void lcdDelay(uint32_t delay)
91 {
92  delay += systick_timems;
93  while (systick_timems < delay) {}
94 }
95 
96 /* Initialize the LCD for the current board */
97 static void lcdInit(void)
98 {
99  /* Board specific LCD pre-setup */
100  Board_LCD_Init();
101 
102  /* Setup for current board */
106  lcdDelay(100);
107 
108  /* Turn on backlight */
110 }
111 
112 /*****************************************************************************
113  * Public functions
114  ****************************************************************************/
115 
120 void SysTick_Handler(void)
121 {
122  systick_timems++;
123 }
124 
129 int main(void)
130 {
131  int xPos, yPos, xSize;
132  int i = 0;
133 
134  Board_Init();
135 
136  /* sysTick will handle touch events at 1KHz */
137  SysTick_Config(Chip_Clock_GetRate(CLK_MX_MXCORE) / 1000);
138 
139  /* Setup LCD */
140  lcdInit();
141 
142  /* emWin start */
143  GUI_Init();
144 
145  /* Solid color display */
146  GUI_SetBkColor(GUI_RED);
147  GUI_Clear();
148  GUI_Delay(1000);
149  GUI_SetBkColor(GUI_GREEN);
150  GUI_Clear();
151  GUI_Delay(1000);
152  GUI_SetBkColor(GUI_BLUE);
153  GUI_Clear();
154  GUI_Delay(1000);
155  GUI_SetBkColor(GUI_BLACK);
156  GUI_Clear();
157 
158  xPos = LCD_GetXSize() / 2;
159  yPos = LCD_GetYSize() / 3;
160  GUI_SetColor(GUI_BROWN);
161  GUI_SetTextMode(GUI_TM_REV);
162  GUI_SetFont(GUI_FONT_20F_ASCII);
163  GUI_DispStringHCenterAt("Hello NXP", xPos, yPos);
164  GUI_SetFont(GUI_FONT_D24X32);
165  GUI_SetColor(GUI_LIGHTYELLOW);
166  xSize = GUI_GetStringDistX("0000");
167  xPos -= xSize / 2;
168  yPos += 24 + 10;
169  while (1) {
170  GUI_DispDecAt(i++, xPos, yPos, 4);
171  if (i > 9999) {
172  i = 0;
173  }
174 
175  GUI_Delay(10);
176  }
177 }
178