upm  0.1.8
Sensor/Actuator repository for libmraa (v0.4.5)
 All Data Structures Files Functions Variables Macros Pages
gfx.h
1 /*
2  * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
3  * Copyright (c) 2014 Intel Corporation.
4  *
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:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
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.
23  */
24 #pragma once
25 
26 #include <string>
27 #include <stdio.h>
28 #include <unistd.h>
29 #include <stdint.h>
30 #include <mraa.h>
31 
32 #define swap(a, b) { int16_t t = a; a = b; b = t; }
33 
34 namespace upm {
35 
41 class GFX {
42  public:
51  GFX (int width, int height, uint8_t * screenBuffer, const unsigned char * font);
52 
56  ~GFX ();
57 
66  virtual void setAddrWindow (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1) = 0;
67 
76  virtual void drawPixel (int16_t x, int16_t y, uint16_t color) = 0;
77 
81  virtual void refresh () = 0;
82 
93  void drawChar (int16_t x, int16_t y, uint8_t data, uint16_t color, uint16_t bg, uint8_t size);
94 
100  void print (std::string msg);
101 
109  mraa_result_t setPixel (int x, int y, uint16_t color);
110 
116  void fillScreen (uint16_t color);
117 
127  void fillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
128 
137  void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
138 
148  void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
149 
161  void drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
162 
171  void drawCircle (int16_t x, int16_t y, int16_t r, uint16_t color);
172 
179  void setCursor (int16_t x, int16_t y);
180 
187  void setTextColor (uint16_t textColor, uint16_t textBGColor);
188 
194  void setTextSize (uint8_t size);
195 
201  void setTextWrap (uint8_t wrap);
202 
203  int m_height;
204  int m_width;
208  int m_cursorX;
209  int m_cursorY;
210  int m_wrap;
212  uint8_t * m_map;
214  protected:
215  const int16_t WIDTH, HEIGHT;
216  const unsigned char * m_font;
217  };
218 }
void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
Definition: gfx.cxx:74
int m_textSize
Definition: gfx.h:205
void setTextWrap(uint8_t wrap)
Definition: gfx.cxx:174
int m_cursorY
Definition: gfx.h:209
int m_width
Definition: gfx.h:204
uint8_t * m_map
Definition: gfx.h:212
GFX helper class.
Definition: gfx.h:41
virtual void drawPixel(int16_t x, int16_t y, uint16_t color)=0
void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
Definition: gfx.cxx:115
void drawChar(int16_t x, int16_t y, uint8_t data, uint16_t color, uint16_t bg, uint8_t size)
Definition: gfx.cxx:179
void fillScreen(uint16_t color)
Definition: gfx.cxx:57
~GFX()
Definition: gfx.cxx:40
virtual void refresh()=0
int m_textBGColor
Definition: gfx.h:207
void setTextSize(uint8_t size)
Definition: gfx.cxx:169
int m_cursorX
Definition: gfx.h:208
void drawCircle(int16_t x, int16_t y, int16_t r, uint16_t color)
Definition: gfx.cxx:122
void setCursor(int16_t x, int16_t y)
Definition: gfx.cxx:157
int m_wrap
Definition: gfx.h:210
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Definition: gfx.cxx:69
int m_textColor
Definition: gfx.h:206
int m_height
Definition: gfx.h:203
void print(std::string msg)
Definition: gfx.cxx:213
GFX(int width, int height, uint8_t *screenBuffer, const unsigned char *font)
Definition: gfx.cxx:33
void setTextColor(uint16_t textColor, uint16_t textBGColor)
Definition: gfx.cxx:163
mraa_result_t setPixel(int x, int y, uint16_t color)
Definition: gfx.cxx:44
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Definition: gfx.cxx:62
virtual void setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1)=0