EU1KY AA
LCD.h
Go to the documentation of this file.
1 /*
2  * (c) Yury Kuchura
3  * kuchura@gmail.com
4  *
5  * This code can be used on terms of WTFPL Version 2 (http://www.wtfpl.net/).
6  */
7 
8 #ifndef LCD_H_INCLUDED
9 #define LCD_H_INCLUDED
10 
11 #include <stdint.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
18 typedef struct __attribute__((packed))
19 {
20  uint16_t x;
21  uint16_t y;
23 
24 
26 typedef uint32_t LCDColor;
27 
29 #define LCD_RGB(r, g, b) ((LCDColor) ( 0xFF000000ul | \
30  (( ((uint32_t)(r)) & 0xFF) << 16) | \
31  (( ((uint32_t)(g)) & 0xFF) << 8) | \
32  ( ((uint32_t)(b)) & 0xFF) \
33  ))
34 
36 enum
37 {
38  LCD_BLACK = LCD_RGB(0, 0, 0),
39  LCD_GRAY = LCD_RGB(127, 127, 127),
40  LCD_RED = LCD_RGB(255, 0, 0),
41  LCD_GREEN = LCD_RGB(0, 255, 0),
42  LCD_BLUE = LCD_RGB(0, 0, 255),
43  LCD_YELLOW = LCD_RGB(255, 255, 0),
44  LCD_PURPLE = LCD_RGB(255, 0, 255),
45  LCD_CYAN = LCD_RGB(0, 255, 255),
46  LCD_WHITE = LCD_RGB(255, 255, 255)
47 };
48 
50 void LCD_Init(void);
51 
53 LCDPoint LCD_MakePoint(int x, int y);
54 
57 LCDColor LCD_MakeRGB(uint8_t r, uint8_t g, uint8_t b);
58 
60 void LCD_SetPixel(LCDPoint p, LCDColor color);
61 
63 void LCD_FillRect(LCDPoint p1, LCDPoint p2, LCDColor color);
64 
66 void LCD_FillAll(LCDColor c);
67 
69 void LCD_Rectangle(LCDPoint a, LCDPoint b, LCDColor c);
70 
71 
72 void LCD_Circle(LCDPoint center, uint16_t r, LCDColor color);
73 
74 void LCD_FillCircle(LCDPoint center, uint16_t r, LCDColor color);
75 
77 void LCD_DrawArc(int32_t x, int32_t y, int32_t radius, float astartdeg, float aenddeg, LCDColor color);
78 
79 void LCD_VLine(LCDPoint p1, uint16_t lenght, LCDColor color);
80 
81 void LCD_HLine(LCDPoint p1, uint16_t lenght, LCDColor color);
82 
84 void LCD_Line(LCDPoint p1, LCDPoint p2, LCDColor c);
85 
87 void LCD_TurnOn(void);
88 
91 void LCD_TurnOff(void);
92 
94 void LCD_BacklightOn(void);
95 
97 void LCD_BacklightOff(void);
98 
100 void LCD_InvertPixel(LCDPoint p);
101 
102 void LCD_InvertRect(LCDPoint p1, LCDPoint p2);
103 
104 LCDColor LCD_ReadPixel(LCDPoint p);
105 
106 uint16_t LCD_GetWidth(void);
107 
108 uint16_t LCD_GetHeight(void);
109 
110 void LCD_WaitForRedraw(void);
111 
112 uint32_t LCD_IsOff(void);
113 
114 void LCD_DrawBitmap(LCDPoint origin, const uint8_t *bmpData, uint32_t bmpDataSize);
115 
116 void LCD_ShowActiveLayerOnly(void);
117 
118 // Functions that store and recover window bitmaps
119 // to be used in temporary windows and pop-ups
120 
124 uint8_t* LCD_Push(void);
125 
127 void LCD_Pop(void);
128 
129 #ifdef __cplusplus
130 }
131 #endif
132 
133 #endif //LCD_H_INCLUDED
void LCD_Pop(void)
Restore last saved LCD contents from the stack in SDRAM memory.
Definition: LCD.c:434
LCDColor LCD_ReadPixel(LCDPoint p)
Definition: LCD.c:158
Definition: LCD.h:45
uint32_t LCDColor
LCD color type.
Definition: LCD.h:26
uint8_t * LCD_Push(void)
Store LCD contents to the stack in SDRAM memory.
void LCD_Init(void)
Initialize hardware, turn on and fill display with black.
Definition: LCD.c:61
Definition: LCD.h:42
Definition: LCD.h:38
void LCD_WaitForRedraw(void)
Definition: LCD.c:100
uint16_t LCD_GetHeight(void)
Definition: LCD.c:40
void LCD_FillRect(LCDPoint p1, LCDPoint p2, LCDColor color)
Fill rectangle with given corner points with given color.
Definition: LCD.c:107
Definition: LCD.h:41
struct __attribute__((packed))
LCD point descriptor.
Definition: LCD.h:18
void LCD_InvertPixel(LCDPoint p)
Invert color of display pixel.
Definition: LCD.c:166
Definition: LCD.h:39
void LCD_BacklightOn(void)
Turn on LCD backlight.
Definition: LCD.c:45
void LCD_Circle(LCDPoint center, uint16_t r, LCDColor color)
Definition: LCD.c:223
void LCD_FillAll(LCDColor c)
Fill the entire display with given color.
Definition: LCD.c:139
void LCD_BacklightOff(void)
Turn off LCD backlight.
Definition: LCD.c:49
void LCD_VLine(LCDPoint p1, uint16_t lenght, LCDColor color)
Definition: LCD.c:201
Definition: LCD.h:43
void LCD_Line(LCDPoint p1, LCDPoint p2, LCDColor c)
Draw line between given points with given color.
Definition: LCD.c:186
uint32_t color
Definition: keyboard.c:29
void LCD_Rectangle(LCDPoint a, LCDPoint b, LCDColor c)
Draw lines forming a rectangle with given corner points with given color.
Definition: LCD.c:179
uint32_t LCD_IsOff(void)
Definition: LCD.c:95
#define LCD_RGB(r, g, b)
Convert 24-bit RGB color to 888 format with macro.
Definition: LCD.h:29
void LCD_SetPixel(LCDPoint p, LCDColor color)
Sets pixel at given point to given color.
Definition: LCD.c:172
void LCD_FillCircle(LCDPoint center, uint16_t r, LCDColor color)
Definition: LCD.c:230
LCDPoint LCD_MakePoint(int x, int y)
Make LCDPoint from x and y coordinates.
Definition: LCD.c:150
void LCD_TurnOn(void)
Turn on LCD and backlight.
Definition: LCD.c:87
void LCD_ShowActiveLayerOnly(void)
Definition: LCD.c:53
LCDColor LCD_MakeRGB(uint8_t r, uint8_t g, uint8_t b)
Definition: LCD.c:145
uint16_t LCD_GetWidth(void)
Definition: LCD.c:35
void LCD_InvertRect(LCDPoint p1, LCDPoint p2)
Definition: LCD.c:123
void LCD_DrawArc(int32_t x, int32_t y, int32_t radius, float astartdeg, float aenddeg, LCDColor color)
Draw arc using start and end in degrees (0 .. 360)
Definition: LCD.c:286
Definition: LCD.h:40
void LCD_HLine(LCDPoint p1, uint16_t lenght, LCDColor color)
Definition: LCD.c:212
Definition: LCD.h:46
void LCD_DrawBitmap(LCDPoint origin, const uint8_t *bmpData, uint32_t bmpDataSize)
Definition: LCD.c:391
LCDPoint
Definition: LCD.h:22
void LCD_TurnOff(void)
Definition: LCD.c:91
Definition: LCD.h:44