2 * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
3 * Copyright (c) 2014 Intel Corporation.
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 #define swap(a, b) { int16_t t = a; a = b; b = t; }
37 * @brief GFX helper class
39 * This file used by the screen.
44 * Instanciates a GFX object
46 * @param width screen width
47 * @param height screen height
48 * @param screenBuffer pointer to screen buffer
49 * @param font pointer to font map
51 GFX (int width, int height, uint8_t * screenBuffer, const unsigned char * font);
54 * GFX object destructor
59 * Set the window address
61 * @param x0 first coordinate
62 * @param y0 first coordinate
63 * @param x1 second coordinate
64 * @param y1 second coordinate
66 virtual void setAddrWindow (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1) = 0;
69 * Send pixel collor (RGB) to the chip. Must be implemented by
72 * @param x axis on horizontal scale
73 * @param y axis on vertical scale
74 * @param color rgb value
76 virtual void drawPixel (int16_t x, int16_t y, uint16_t color) = 0;
79 * Copy the buffer to the chip via SPI interface.
81 virtual void refresh () = 0;
86 * @param x axis on horizontal scale
87 * @param y axis on vertical scale
88 * @param data character to write
89 * @param color character's color
90 * @param bg character's background color
91 * @param size size of the font
93 void drawChar (int16_t x, int16_t y, uint8_t data, uint16_t color, uint16_t bg, uint8_t size);
96 * Print the message to the screen
98 * @param msg message which will be printed
100 void print (std::string msg);
103 * Print the message to the screen
105 * @param x axis on horizontal scale
106 * @param y axis on vertical scale
107 * @param color pixel's color
109 mraa_result_t setPixel (int x, int y, uint16_t color);
112 * Fill screen with selected color
114 * @param color selected's color
116 void fillScreen (uint16_t color);
119 * Fill rectangle with selected color
121 * @param x axis on horizontal scale (top left corner)
122 * @param y axis on vertical scale (top left corner)
123 * @param w distanse from x
124 * @param h distanse from y
125 * @param color selected color
127 void fillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
130 * Draw line in vertical scale.
132 * @param x axis on horizontal scale
133 * @param y axis on vertical scale
134 * @param h distanse from y
135 * @param color selected color
137 void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
140 * Draw line from coordinate C0 to coordinate C1
142 * @param x0 first coordinate
143 * @param y0 first coordinate
144 * @param x1 second coordinate
145 * @param y1 second coordinate
146 * @param color selected color
148 void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
153 * @param x0 first coordinate
154 * @param y0 first coordinate
155 * @param x1 second coordinate
156 * @param y1 second coordinate
157 * @param x2 third coordinate
158 * @param y2 third coordinate
159 * @param color selected color
161 void drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
166 * @param x center of circule on X scale
167 * @param y center of circule on Y scale
169 void drawCircle (int16_t x, int16_t y, int16_t r, uint16_t color);
172 * Set cursor for text message
174 * @param x axis on horizontal scale
175 * @param y axis on vertical scale
177 void setCursor (int16_t x, int16_t y);
180 * Set text color for the message
182 * @param textColor font color
183 * @param textBGColor background color
185 void setTextColor (uint16_t textColor, uint16_t textBGColor);
188 * Set the size of the font
190 * @param size font size
192 void setTextSize (uint8_t size);
195 * Wrap printed message.
197 * @param wrap true (0x1) or false (0x0)
199 void setTextWrap (uint8_t wrap);
201 int m_height; /**< Screen height */
202 int m_width; /**< Screen width */
203 int m_textSize; /**< Printed text size */
204 int m_textColor; /**< Printed text color */
205 int m_textBGColor; /**< Printed text background color */
206 int m_cursorX; /**< Cursor X coordinate */
207 int m_cursorY; /**< Cursor Y coordinate */
208 int m_wrap; /**< Wrapper flag (true or false) */
210 uint8_t * m_map; /**< Screens buffer */
213 const int16_t WIDTH, HEIGHT;
214 const unsigned char * m_font;