LPCOpen Platform
v1.03
LPCOpen Platform for NXP LPC Microcontrollers
Main Page
Modules
Data Structures
Files
Related Pages
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
58
/*****************************************************************************
59
* Private types/enumerations/variables
60
****************************************************************************/
61
62
#define LCD_WIDTH BOARD_LCD.PPL
63
#define LCD_HEIGHT BOARD_LCD.LPP
64
#define LOGO_WIDTH 110
65
#define LOGO_HEIGHT 42
66
67
/* pointer to frame buffer */
68
static
uint16_t *
framebuffer
= (uint16_t *)
FRAMEBUFFER_ADDR
;
69
static
volatile
uint32_t
msec
;
70
71
/*****************************************************************************
72
* Public types/enumerations/variables
73
****************************************************************************/
74
75
/* Image */
76
extern
const
unsigned
short
image
[];
77
78
/*****************************************************************************
79
* Private functions
80
****************************************************************************/
81
82
/* Put a pixel at the x, y coordinate */
83
static
void
putpixel
(
uint32_t
x,
uint32_t
y, uint16_t val) {
84
framebuffer
[x + y *
LCD_WIDTH
] = val;
85
}
86
87
/*****************************************************************************
88
* Public functions
89
****************************************************************************/
90
95
void
SysTick_Handler
(
void
)
96
{
97
if
(
msec
) {
98
msec
--;
99
}
100
}
101
106
int
main
(
void
)
107
{
108
uint32_t
i, j;
109
int
cursor_x = 100, cursor_y = 150;
110
int16_t tmp_x = -1, tmp_y = -1;
111
112
Board_Init
();
113
Board_LCD_Init
();
114
115
Chip_GPIO_Init
(
LPC_GPIO
);
116
117
SysTick_Config(
SystemCoreClock
/ 1000);
118
msec
= 5;
119
while
(
msec
) {}
120
121
/* Fill Colorbar only*/
122
for
(i = 0; i <
LCD_WIDTH
*
LCD_HEIGHT
/ 4; i++)
123
framebuffer
[i] = 0x1F;
124
for
(i =
LCD_WIDTH
*
LCD_HEIGHT
/ 4; i <
LCD_WIDTH
*
LCD_HEIGHT
* 2 / 4; i++)
125
framebuffer
[i] = 0x3F << 5;
126
for
(i =
LCD_WIDTH
*
LCD_HEIGHT
* 2 / 4; i <
LCD_WIDTH
*
LCD_HEIGHT
* 3 / 4; i++)
127
framebuffer
[i] = 0x1F << 11;
128
for
(i =
LCD_WIDTH
*
LCD_HEIGHT
* 3 / 4; i <
LCD_WIDTH
*
LCD_HEIGHT
; i++)
129
framebuffer
[i] = 0xFFFF;
130
/* Fill NXP logo */
131
for
(j = 0; j <
LOGO_HEIGHT
; j++)
132
for
(i = 0; i <
LOGO_WIDTH
; i++)
133
putpixel
(i, j,
image
[(i + j * LOGO_WIDTH)]);
134
135
Chip_LCD_Init
(
LPC_LCD
, (
LCD_Config_T
*) &
BOARD_LCD
);
136
137
Board_InitTouchController
();
138
Chip_LCD_SetUPFrameBuffer
(
LPC_LCD
, (
void
*)
framebuffer
);
139
Chip_LCD_PowerOn
(
LPC_LCD
);
140
msec
= 100;
141
while
(
msec
) {}
142
143
Chip_LCD_Cursor_Disable
(
LPC_LCD
, 0);
144
Chip_LCD_Cursor_Config
(
LPC_LCD
,
LCD_CURSOR_32x32
,
true
);
145
Chip_LCD_Cursor_WriteImage
(
LPC_LCD
, 0, (
void
*)
Cursor
);
146
Chip_LCD_Cursor_SetClip
(
LPC_LCD
,
CURSOR_H_OFS
,
CURSOR_V_OFS
);
147
Chip_LCD_Cursor_SetPos
(
LPC_LCD
, cursor_x, cursor_y);
148
Chip_LCD_Cursor_Enable
(
LPC_LCD
, 0);
149
150
/* Turn on backlight */
151
Board_SetLCDBacklight
(1);
152
153
msec
= 20;
154
while
(
msec
) {}
155
156
while
(1) {
157
Board_GetTouchPos
((int16_t *) &tmp_x, (int16_t *) &tmp_y);
158
if
((tmp_x >= 0) && (tmp_y >= 0)) {
159
cursor_x = tmp_x;
160
cursor_y = tmp_y;
161
}
162
163
if
(
LCD_WIDTH
< cursor_x) {
164
cursor_x =
LCD_WIDTH
-
CURSOR_H_OFS
;
165
}
166
167
if
(LCD_HEIGHT < cursor_y) {
168
cursor_y = (LCD_HEIGHT -
CURSOR_V_OFS
);
169
}
170
Chip_LCD_Cursor_SetPos
(
LPC_LCD
, cursor_x, cursor_y);
171
}
172
}
173
applications
lpc17xx_40xx
examples
periph
periph_lcd
lcd.c
Generated on Fri May 10 2013 10:42:07 for LPCOpen Platform by
1.8.2