LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
lcd.c
Go to the documentation of this file.
1
/*
2
* @brief Simple LCD colorbar example with image and cursor
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 "board.h"
33
#include "
Cursor.h
"
34
53
/*****************************************************************************
54
* Private types/enumerations/variables
55
****************************************************************************/
56
57
#define LCD_WIDTH BOARD_LCD.PPL
58
#define LCD_HEIGHT BOARD_LCD.LPP
59
#define LOGO_WIDTH 110
60
#define LOGO_HEIGHT 42
61
62
/* pointer to frame buffer */
63
static
uint16_t *
framebuffer
= (uint16_t *)
FRAMEBUFFER_ADDR
;
64
static
volatile
uint32_t
msec
;
65
66
/*****************************************************************************
67
* Public types/enumerations/variables
68
****************************************************************************/
69
70
/* Image */
71
extern
const
unsigned
short
image
[];
72
73
/*****************************************************************************
74
* Private functions
75
****************************************************************************/
76
77
/* Put a pixel at the x, y coordinate */
78
static
void
putpixel
(
uint32_t
x,
uint32_t
y, uint16_t val) {
79
framebuffer
[x + y *
LCD_WIDTH
] = val;
80
}
81
82
/*****************************************************************************
83
* Public functions
84
****************************************************************************/
85
90
void
SysTick_Handler
(
void
)
91
{
92
if
(
msec
) {
93
msec
--;
94
}
95
}
96
101
int
main
(
void
)
102
{
103
uint32_t
i, j;
104
int
cursor_x = 100, cursor_y = 150;
105
int16_t tmp_x = -1, tmp_y = -1;
106
107
Board_Init
();
108
Board_LCD_Init
();
109
110
Chip_GPIO_Init
();
111
112
SysTick_Config(
SystemCoreClock
/ 1000);
113
msec
= 5;
114
while
(
msec
) {}
115
116
/* Fill Colorbar only*/
117
for
(i = 0; i <
LCD_WIDTH
*
LCD_HEIGHT
/ 4; i++) {
118
framebuffer
[i] = 0x1F;
119
}
120
for
(i =
LCD_WIDTH
*
LCD_HEIGHT
/ 4; i <
LCD_WIDTH
*
LCD_HEIGHT
* 2 / 4; i++) {
121
framebuffer
[i] = 0x3F << 5;
122
}
123
for
(i =
LCD_WIDTH
*
LCD_HEIGHT
* 2 / 4; i <
LCD_WIDTH
*
LCD_HEIGHT
* 3 / 4; i++) {
124
framebuffer
[i] = 0x1F << 11;
125
}
126
for
(i =
LCD_WIDTH
*
LCD_HEIGHT
* 3 / 4; i <
LCD_WIDTH
*
LCD_HEIGHT
; i++) {
127
framebuffer
[i] = 0xFFFF;
128
}
129
/* Fill NXP logo */
130
for
(j = 0; j <
LOGO_HEIGHT
; j++) {
131
for
(i = 0; i <
LOGO_WIDTH
; i++) {
132
putpixel
(i, j,
image
[(i + j * LOGO_WIDTH)]);
133
}
134
}
135
136
Chip_LCD_Init
( (
LCD_Config_Type
*) &
BOARD_LCD
);
137
Init_Touch_Controller
();
138
Chip_LCD_SetUPFrameBuffer
( (
void
*)
framebuffer
);
139
Chip_LCD_Power
(
ENABLE
);
140
msec
= 100;
141
while
(
msec
) {}
142
143
Chip_LCD_Cursor_Enable
(0,
DISABLE
);
144
Chip_LCD_Cursor_Config
(
LCD_CURSOR_32x32
,
true
);
145
Chip_LCD_Cursor_WriteImage
(0, (
void
*)
Cursor
);
146
Chip_LCD_Cursor_SetPos
(cursor_x, cursor_y);
147
Chip_LCD_Cursor_Enable
(0,
ENABLE
);
148
149
/* Turn on backlight */
150
Board_LCD_Set_Backlight
(1);
151
152
msec
= 20;
153
while
(
msec
) {}
154
155
while
(1) {
156
GetTouchPos
((int16_t *) &tmp_x, (int16_t *) &tmp_y);
157
if
((tmp_x >= 0) && (tmp_y > 0)) {
158
cursor_x = tmp_x -
CURSOR_H_SIZE
/ 2;
159
cursor_y = tmp_y -
CURSOR_V_SIZE
/ 2;
160
}
161
162
if
((
LCD_WIDTH
-
CURSOR_H_SIZE
/ 2) < cursor_x) {
163
cursor_x =
LCD_WIDTH
-
CURSOR_H_SIZE
/ 2;
164
}
165
166
if
(-(
CURSOR_H_SIZE
/ 2) > cursor_x) {
167
cursor_x = -(
CURSOR_H_SIZE
/ 2);
168
}
169
170
if
((LCD_HEIGHT -
CURSOR_V_SIZE
/ 2) < cursor_y) {
171
cursor_y = (LCD_HEIGHT -
CURSOR_V_SIZE
/ 2);
172
}
173
174
if
(-(
CURSOR_V_SIZE
/ 2) > cursor_y) {
175
cursor_y = -(
CURSOR_V_SIZE
/ 2);
176
}
177
Chip_LCD_Cursor_SetPos
(cursor_x, cursor_y);
178
}
179
}
180
applications
lpc18xx_43xx
examples
periph
periph_lcd
lcd.c
Generated on Fri Nov 16 2012 13:36:38 for LPCOpen Platform by
1.8.2