blob: a54c6d047975314a99b9f71b67d3d32b42b49e14 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001/*
Richard Burton9c549902022-02-15 16:39:18 +00002 * Copyright (c) 2021-2022 Arm Limited. All rights reserved.
alexander3c798932021-03-26 21:42:19 +00003 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000017#ifndef GLCD_H
18#define GLCD_H
alexander3c798932021-03-26 21:42:19 +000019
20#include <stdint.h>
21
22/******************************************************************************
23 Color coding
24 GLCD is coded: 15..11 red, 10..5 green, 4..0 blue (unsigned short)
25 GLCD_R5, GLCD_G6, GLCD_B5
26 original coding: 17..12 red, 11..6 green, 5..0 blue
27 ORG_R6, ORG_G6, ORG_B6
28
29 ORG_R1..5 = GLCD_R0..4, ORG_R0 = GLCD_R4
30 ORG_G0..5 = GLCD_G0..5,
31 ORG_B1..5 = GLCD_B0..4, ORG_B0 = GLCD_B4
32
33 GLCD RGB color definitions
34******************************************************************************/
35#define Black 0x0000 /* 0, 0, 0 */
36#define Navy 0x000F /* 0, 0, 128 */
37#define DarkGreen 0x03E0 /* 0, 128, 0 */
38#define DarkCyan 0x03EF /* 0, 128, 128 */
39#define Maroon 0x7800 /* 128, 0, 0 */
40#define Purple 0x780F /* 128, 0, 128 */
41#define Olive 0x7BE0 /* 128, 128, 0 */
42#define LightGrey 0xC618 /* 192, 192, 192 */
43#define DarkGrey 0x7BEF /* 128, 128, 128 */
44#define Blue 0x001F /* 0, 0, 255 */
45#define Green 0x07E0 /* 0, 255, 0 */
46#define Cyan 0x07FF /* 0, 255, 255 */
47#define Red 0xF800 /* 255, 0, 0 */
48#define Magenta 0xF81F /* 255, 0, 255 */
49#define Yellow 0xFFE0 /* 255, 255, 0 */
50#define White 0xFFFF /* 255, 255, 255 */
51
52/************************** Orientation configuration ************************/
53#ifndef LANDSCAPE
54#define LANDSCAPE 1 /* 1 for landscape, 0 for portrait. */
55#endif
56#ifndef ROTATE180
57#define ROTATE180 1 /* 1 to rotate the screen for 180 deg. */
58#endif
59
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000060/*------------------------- Speed dependent settings -------------------------*/
alexander3c798932021-03-26 21:42:19 +000061
62/* If processor works on high frequency delay has to be increased, it can be
63 increased by factor 2^N by this constant. */
64#define DELAY_2N 8
65
66/*---------------------- Graphic LCD size definitions ------------------------*/
67#if (LANDSCAPE == 1)
68 #define GLCD_WIDTH 320 /* Screen Width (in pixels). */
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000069 #define GLCD_HEIGHT 240 /* Screen Height (in pixels). */
alexander3c798932021-03-26 21:42:19 +000070#else
71 #define GLCD_WIDTH 240 /* Screen Width (in pixels). */
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000072 #define GLCD_HEIGHT 320 /* Screen Height (in pixels). */
alexander3c798932021-03-26 21:42:19 +000073#endif
74
75#define BPP 16 /* Bits per pixel. */
76#define BYPP ((BPP+7)/8) /* Bytes per pixel. */
77
78
79/**
80 * @brief Initialize the Himax LCD with HX8347-D LCD Controller.
81 */
82void GLCD_Initialize(void);
83
84/**
85 * @brief Set draw window region to whole screen.
86 */
87void GLCD_WindowMax(void);
88
89/**
90 * @brief Set draw window region.
91 * @param[in] x Horizontal position.
92 * @param[in] y Vertical position.
93 * @param[in] w Window width in pixel.
94 * @param[in] h Window height in pixels.
95 */
96void GLCD_SetWindow(unsigned int x, unsigned int y,
97 unsigned int w, unsigned int h);
98
99/**
100 * @brief Set foreground color.
101 * @param[in] color Foreground color.
102 */
103void GLCD_SetTextColor(unsigned short color);
104
105/**
106 * @brief Set background color.
107 * @param[in] color Background color.
108 */
109void GLCD_SetBackColor(unsigned short color);
110
111/**
112 * @brief Clear display.
113 * @param[in] color Display clearing color.
114 *
115 */
116void GLCD_Clear(unsigned short color);
117
118/**
119 * @brief Draw character on given position.
120 * @param[in] x Horizontal position.
121 * @param[in] y Vertical position.
122 * @param[in] cw Character width in pixel.
123 * @param[in] ch Character height in pixels.
124 * @param[in] c Pointer to character bitmap.
125 *
126 */
127void GLCD_DrawChar(unsigned int x, unsigned int y,
128 unsigned int cw, unsigned int ch,
129 unsigned char *c);
130
131/**
132 * @brief Display character on given line.
133 * @param[in] ln Line number.
134 * @param[in] col Column number.
135 * @param[in] fi Font index (0 = 9x15).
136 * @param[in] c ASCII character.
137 */
138void GLCD_DisplayChar(unsigned int ln, unsigned int col,
139 unsigned char fi, unsigned char c);
140
141
142/**
143 * @brief Display string on given line.
144 * @param[in] ln Line number.
145 * @param[in] col Column number.
146 * @param[in] fi Font index (0 = 9x15).
147 * @param[in] s Pointer to string.
148 */
149void GLCD_DisplayString(unsigned int ln, unsigned int col,
150 unsigned char fi, char *s);
151
152/**
153 * @brief Clear given line.
154 * @param[in] ln: Line number.
155 * @param[in] fi Font index (0 = 9x15).
156 */
157void GLCD_ClearLn(unsigned int ln, unsigned char fi);
158
159/**
160 * @brief Display graphical bitmap image at position x horizontally and y
161 * vertically. This function is optimized for 16 bits per pixel
162 * format, it has to be adapted for any other format.
163 * @param[in] x Horizontal position.
164 * @param[in] y Vertical position.
165 * @param[in] w Width of bitmap.
166 * @param[in] h Height of bitmap.
167 * @param[in] bitmap Address at which the bitmap data resides.
168 */
169void GLCD_Bitmap(unsigned int x, unsigned int y,
170 unsigned int w, unsigned int h,
171 unsigned short *bitmap);
172
173/**
174 * @brief Displays an 8 bit image, conversion to the LCD's
175 * 16 bit codec is done on the fly.
176 * @param[in] data Pointer to the full sized image data.
177 * @param[in] width Image width.
178 * @param[in] height Image height.
179 * @param[in] channels Number of channels in the image.
180 * @param[in] pos_x Start x position for the LCD.
181 * @param[in] pos_y Start y position for the LCD.
182 * @param[in] downsample_factor Factor by which the image
183 * is downsampled by.
184 */
Richard Burton9c549902022-02-15 16:39:18 +0000185void GLCD_Image(const void *data, const uint32_t width,
alexander3c798932021-03-26 21:42:19 +0000186 const uint32_t height, const uint32_t channels,
187 const uint32_t pos_x, const uint32_t pos_y,
188 const uint32_t downsample_factor);
189
190/**
191 * @brief Draw box filled with color.
192 * @param[in] x Horizontal position.
193 * @param[in] y Vertical position.
194 * @param[in] w Window width in pixels.
195 * @param[in] h Window height in pixels.
196 * @param[in] color Box color.
197 */
198void GLCD_Box(unsigned int x, unsigned int y,
199 unsigned int w, unsigned int h,
200 unsigned short color);
201
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000202#endif /* GLCD_H */