sGUI  V1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
lcd.h
Go to the documentation of this file.
1 #ifndef __LCD_H__
2 #define __LCD_H__
3 
72 #ifdef __cplusplus
73 extern "C" {
74 #endif /* __cplusplus */
75 
76 /*----- Header-Files -------------------------------------------------------*/
77 #include <stdint.h> /* Standard integer formats */
78 #include "lcd_conf.h" /* LCD configuration */
79 #include "color.h" /* Color definitions */
80 #include "font.h" /* Fonts definitions */
81 #include "lcd_lld.h" /* Graphic controller communication */
82 
83 /*----- Macros -------------------------------------------------------------*/
84 
85 /*----- Data types ---------------------------------------------------------*/
89 typedef struct _BMP_Header {
90  uint16_t Magic;
91  uint32_t FileSize;
92  uint16_t Reserved1;
93  uint16_t Reserved2;
94  uint32_t DataOffset;
96  uint32_t HeaderSize;
97  uint32_t Width;
98  uint32_t Height;
99  uint16_t Planes;
100  uint16_t BitsPerPixel;
101  uint32_t CompressionType;
102  uint32_t ImageDataSize;
103  uint32_t HPixelsPerMeter;
105  uint32_t VPixelsPerMeter;
106  uint32_t ColorsUsed;
109  uint32_t ColorsRequired;
111 } BMP_Header;
112 
116 typedef struct _BMP {
118  uint8_t *Data;
119 } BMP;
120 
124 typedef enum _BMP_STATUS
125 {
126  BMP_OK = 0,
138 } BMP_STATUS;
139 
140 /*----- Function prototypes ------------------------------------------------*/
141 /* Text functionality */
142 void LCD_SetTextColor(LCDCOLOR Color);
143 void LCD_SetBackColor(LCDCOLOR Color);
144 void LCD_SetFont(FONT_T *pFont);
145 FONT_T* LCD_GetFont(void);
146 uint8_t LCD_GetLineCount(void);
147 void LCD_ClearLine(uint8_t Line);
148 void LCD_DisplayCharXY(uint16_t x, uint16_t y, char Ascii);
149 void LCD_DisplayCharLine(uint8_t Line, uint8_t Column, char Ascii);
150 void LCD_DisplayStringXY(uint16_t x, uint16_t y, const char *ptr);
151 void LCD_DisplayStringLine(uint8_t Line, const char *ptr);
152 void LCD_DisplayStringCenterLine(uint8_t Line, const char *ptr);
153 
154 /* Log console functionality */
155 void LCD_Log_AddMsg(char *ptr);
156 void LCD_Log_Update(void);
157 
158 /* Simple geometric functionality */
159 void LCD_DrawLine(uint16_t Xstart, uint16_t Ystart, uint16_t Xstop,
160  uint16_t Ystop, LCDCOLOR Color);
161 void LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t width,
162  uint16_t height, LCDCOLOR Color);
163 void LCD_DrawRectF(uint16_t Xpos, uint16_t Ypos, uint16_t width,
164  uint16_t height, LCDCOLOR Color);
165 void LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius,
166  LCDCOLOR Color);
167 void LCD_DrawCircleF(uint8_t Xpos, uint16_t Ypos, uint16_t Radius,
168  LCDCOLOR Color);
169 
170 /* Bitmap functionality */
171 BMP_STATUS LCD_BMP_DrawBitmap(const char *filename, uint16_t Xpos,
172  uint16_t Ypos);
173 BMP_STATUS LCD_BMP_ReadFile(BMP *bmp, const char *filename);
174 uint32_t LCD_BMP_GetWidth(BMP *bmp);
175 uint32_t LCD_BMP_GetHeight(BMP *bmp);
176 uint16_t LCD_BMP_GetDepth(BMP *bmp);
177 BMP_STATUS LCD_BMP_GetPixelRGB(BMP *bmp, uint32_t x, uint32_t y, uint8_t *r,
178  uint8_t *g, uint8_t *b);
179 const char* LCD_BMP_GetErrorDescription(uint8_t errorcode);
180 
181 /*----- Data ---------------------------------------------------------------*/
182 
183 /*----- Implementation -----------------------------------------------------*/
188 static inline void LCD_Clear(LCDCOLOR Color) {
189  LCD_FillArea(SCRN_LEFT, SCRN_TOP, SCRN_RIGHT, SCRN_BOTTOM, Color);
190 }
191 
192 /*----- EOF ----------------------------------------------------------------*/
193 
194 #ifdef __cplusplus
195 }
196 #endif /* __cplusplus */
197 
206 #endif /* __LCD_H__ */
uint32_t LCD_BMP_GetWidth(BMP *bmp)
Returns the image's width.
Definition: bmp.c:257
void LCD_DisplayCharXY(uint16_t x, uint16_t y, char Ascii)
Displays one character (16dots width, 24dots height) on the LCD. Position is set with a x- and a y-co...
Definition: text.c:199
uint32_t VPixelsPerMeter
Definition: lcd.h:105
uint32_t FileSize
Definition: lcd.h:91
uint32_t DataOffset
Definition: lcd.h:94
uint16_t Magic
Definition: lcd.h:90
uint32_t ColorsRequired
Definition: lcd.h:109
void LCD_SetBackColor(LCDCOLOR Color)
Sets the Background color.
Definition: text.c:152
BMP_STATUS LCD_BMP_ReadFile(BMP *bmp, const char *filename)
Reads the specified BMP image file. It does only read bitmaps with 16, 24 or 32 bits per pixel and u...
Definition: bmp.c:200
const char * LCD_BMP_GetErrorDescription(uint8_t errorcode)
Returns a description of the last error code.
Definition: bmp.c:346
void LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t width, uint16_t height, LCDCOLOR Color)
Displays a rectangle.
Definition: geometry.c:161
uint16_t Reserved2
Definition: lcd.h:93
void LCD_SetTextColor(LCDCOLOR Color)
Sets the Text color.
Definition: text.c:144
uint32_t CompressionType
Definition: lcd.h:101
void LCD_DisplayStringXY(uint16_t x, uint16_t y, const char *ptr)
Displays a string on the LCD. Position is set with the x- and y-coordinate.
Definition: text.c:236
uint32_t LCD_BMP_GetHeight(BMP *bmp)
Returns the image's height.
Definition: bmp.c:271
void LCD_DrawCircleF(uint8_t Xpos, uint16_t Ypos, uint16_t Radius, LCDCOLOR Color)
Displays a filled circle.
Definition: geometry.c:212
void LCD_Log_Update(void)
Update the log messages on the display. This is used, if the screen is overwritten by user...
Definition: log.c:141
void LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius, LCDCOLOR Color)
Displays a circle.
Definition: geometry.c:191
uint32_t Height
Definition: lcd.h:98
void LCD_ClearLine(uint8_t Line)
Clears the selected line.
Definition: text.c:186
void LCD_DisplayCharLine(uint8_t Line, uint8_t Column, char Ascii)
Displays one character (16dots width, 24dots height) on the LCD. Position is set with a line and a co...
Definition: text.c:223
uint32_t HPixelsPerMeter
Definition: lcd.h:103
Definition: lcd.h:126
void LCD_DisplayStringCenterLine(uint8_t Line, const char *ptr)
Displays a string on the LCD. Position is set at the y-coordinate on center of the display...
Definition: text.c:288
uint16_t BitsPerPixel
Definition: lcd.h:100
static void LCD_Clear(LCDCOLOR Color)
Clears the whole LCD.
Definition: lcd.h:188
struct _BMP_Header BMP_Header
Bitmap header.
Simple graphic library controller communication interface.
struct _BMP BMP
Bitmap image.
uint16_t Planes
Definition: lcd.h:99
_BMP_STATUS
Error codes.
Definition: lcd.h:124
uint32_t ImageDataSize
Definition: lcd.h:102
Simple graphic library color definitions.
BMP_STATUS LCD_BMP_GetPixelRGB(BMP *bmp, uint32_t x, uint32_t y, uint8_t *r, uint8_t *g, uint8_t *b)
Populates the arguments with the specified pixel's RGB values.
Definition: bmp.c:304
uint16_t LCD_BMP_GetDepth(BMP *bmp)
Returns the image's color depth (bits per pixel).
Definition: bmp.c:285
uint8_t LCD_GetLineCount(void)
Gets the current count of possible lines.
Definition: text.c:176
enum _BMP_STATUS BMP_STATUS
Error codes.
uint16_t LCDCOLOR
Data type for a color definition.
Definition: color.h:98
void LCD_Log_AddMsg(char *ptr)
Add a log message to the screen.
Definition: log.c:122
BMP_Header Header
Definition: lcd.h:117
void LCD_DisplayStringLine(uint8_t Line, const char *ptr)
Displays a string on a line on the LCD. Position is set with a line number.
Definition: text.c:250
uint8_t * Data
Definition: lcd.h:118
static void LCD_FillArea(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Fill a specified area on the display with the same color.
Definition: lcd_lld.h:104
Bitmap header.
Definition: lcd.h:89
void LCD_DrawLine(uint16_t Xstart, uint16_t Ystart, uint16_t Xstop, uint16_t Ystop, LCDCOLOR Color)
Draw a line on the display starting at (Xstart/Ystart) and ending at (Xstop/Ystop). This function draws the line with the Bresenham's line algorithm.
Definition: geometry.c:103
uint32_t Width
Definition: lcd.h:97
This struct encapsulates the parameters of a font.
Definition: font.h:113
uint32_t ColorsUsed
Definition: lcd.h:106
uint16_t Reserved1
Definition: lcd.h:92
Bitmap image.
Definition: lcd.h:116
Definition: lcd.h:127
BMP_STATUS LCD_BMP_DrawBitmap(const char *filename, uint16_t Xpos, uint16_t Ypos)
Reads the specified BMP image file and print it to the LCD. It does only read bitmaps with 16...
Definition: bmp.c:127
Simple graphic library font data.
void LCD_SetFont(FONT_T *pFont)
Sets the current font.
Definition: text.c:160
void LCD_DrawRectF(uint16_t Xpos, uint16_t Ypos, uint16_t width, uint16_t height, LCDCOLOR Color)
Displays a filled rectangle.
Definition: geometry.c:178
uint32_t HeaderSize
Definition: lcd.h:96
FONT_T * LCD_GetFont(void)
Gets the current font.
Definition: text.c:168