blob: 376565f01cbb429bd58be9e0f77d88008ddd9f9c [file] [log] [blame]
zongqiang.zhang0c6a0882019-08-07 14:48:21 +08001/**
2 \file glcd_graphics.h
3 \brief Graphics routines
4 \author Andy Gock
5 */
6
7/*
8 Copyright (c) 2012, Andy Gock
9
10 All rights reserved.
11
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14 * Redistributions of source code must retain the above copyright
15 notice, this list of conditions and the following disclaimer.
16 * Redistributions in binary form must reproduce the above copyright
17 notice, this list of conditions and the following disclaimer in the
18 documentation and/or other materials provided with the distribution.
19 * Neither the name of Andy Gock nor the
20 names of its contributors may be used to endorse or promote products
21 derived from this software without specific prior written permission.
22
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
27 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33*/
34
35#ifndef GLCD_GRAPHICS_H_
36#define GLCD_GRAPHICS_H_
37
38/** \addtogroup Graphics Graphics
39 * Graphics specific functions such as drawing lines, circles, rectangles etc.
40 * @{
41 */
42
43/**
44 * Set pixel to specified colour
45 * \param x X-coordinate
46 * \param y Y-coordinate
47 * \param color Colour to set pixel
48 * \see ColourConstants
49 */
50void glcd_set_pixel(uint8_t x, uint8_t y, uint8_t color);
51
52/**
53 * Get state of pixel from specified location
54 * \param x X-coordinate
55 * \param y Y-coordinate
56 * \return Colour
57 */
58uint8_t glcd_get_pixel(uint8_t x, uint8_t y);
59
60/**
61 * Invert state of pixel of specified location
62 * \param x X-coordinate
63 * \param y Y-coordinate
64 */
65void glcd_invert_pixel(uint8_t x, uint8_t y);
66
67/**
68 * Draw line
69 * \param x0 Start x-coordinate
70 * \param y0 Start y-coordinate
71 * \param x1 End x-coordinate
72 * \param y1 End y-coordinate
73 * \param color Colour to set pixels
74 * \see ColourConstants
75 */
76void glcd_draw_line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t color);
77
78/**
79 * Draw rectangle and fill with colour.
80 * The border of the rectangle is the same as fill colour
81 * \param x Start x-coordinate (left-most)
82 * \param y Start y-coordinate (top-most)
83 * \param w Width
84 * \param h Height
85 * \param color Colour to fill with
86 * \see ColourConstants
87 */
88void glcd_fill_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color);
89
90/**
91 * Draw rectangle but do not fill.
92 * The border of the rectangle is the same as fill colour
93 * \param x Start x-coordinate (left-most)
94 * \param y Start y-coordinate (top-most)
95 * \param w Width
96 * \param h Height
97 * \param color Colour of border
98 * \see ColourConstants
99 */
100void glcd_draw_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color);
101
102/**
103 * Draw rectangle but do not fill. User specified thickness.
104 * The border of the rectangle is the same as fill colour
105 * \param x Start x-coordinate (left-most)
106 * \param y Start y-coordinate (top-most)
107 * \param w Width (outermost pixels)
108 * \param h Height
109 * \param tx Thickness of horizontal border along X axis
110 * \param ty Thickness of vertical border along Y axis
111 * \param color Colour of border
112 * \see ColourConstants
113 */
114void glcd_draw_rect_thick(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t tx, uint8_t ty, uint8_t color);
115
116/**
117 * Draw rectangle but do not fill. Place a shadow line on the bottom-right of the window.
118 * The border of the rectangle is the same as fill colour
119 * \param x Start x-coordinate (left-most)
120 * \param y Start y-coordinate (top-most)
121 * \param w Width
122 * \param h Height
123 * \param color Colour of border
124 * \see ColourConstants
125 */
126void glcd_draw_rect_shadow(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color);
127
128/**
129 * Draw circle but do not fill.
130 * The border of the rectangle is the same as fill colour
131 * \param x0 Centre x-coordinate (left-most)
132 * \param y0 Centre y-coordinate (top-most)
133 * \param r Radius
134 * \param color Colour of border
135 * \see ColourConstants
136 */
137void glcd_draw_circle(uint8_t x0, uint8_t y0, uint8_t r, uint8_t color);
138
139/**
140 * Draw circle and fill.
141 * The border of the rectangle is the same as fill colour
142 * \param x0 Centre x-coordinate (left-most)
143 * \param y0 Centre y-coordinate (top-most)
144 * \param r Radius
145 * \param color Colour of border
146 * \see ColourConstants
147 */
148void glcd_fill_circle(uint8_t x0, uint8_t y0, uint8_t r, uint8_t color);
149
150/**
151 * Invert pixels in a retangular area.
152 * \param x Start x-coordinate (left-most)
153 * \param y Start y-coordinate (top-most)
154 * \param w Width
155 * \param h Height
156 */
157void glcd_invert_area(uint8_t x, uint8_t y, uint8_t w, uint8_t h);
158
159/**
160 * Draw bitmap to screen buffer.
161 * Note this will draw to the entire buffer, its not yet possible to draw partially to the LCD.
162 * Not yet supported with AVR pgmspace.
163 * \param data Pointer to bitmap data.
164 */
165void glcd_draw_bitmap(const unsigned char *data);
166
167/** @}*/
168
169#endif /* GLCD_GRAPHICS_H_ */