upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
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 
31 #include <mraa.hpp>
32 
33 #define swap(a, b) { int16_t t = a; a = b; b = t; }
34 
35 namespace upm {
36 
42 class GFX {
43  public:
52  GFX (int width, int height, uint8_t * screenBuffer, const unsigned char * font);
53 
57  ~GFX ();
58 
67  virtual void setAddrWindow (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1) = 0;
68 
77  virtual void drawPixel (int16_t x, int16_t y, uint16_t color) = 0;
78 
82  virtual void refresh () = 0;
83 
94  void drawChar (int16_t x, int16_t y, uint8_t data, uint16_t color, uint16_t bg, uint8_t size);
95 
101  void print (std::string msg);
102 
110  mraa::Result setPixel (int x, int y, uint16_t color);
111 
117  void fillScreen (uint16_t color);
118 
128  void fillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
129 
138  void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
139 
149  void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
150 
162  void drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
163 
172  void drawCircle (int16_t x, int16_t y, int16_t r, uint16_t color);
173 
180  void setCursor (int16_t x, int16_t y);
181 
188  void setTextColor (uint16_t textColor, uint16_t textBGColor);
189 
195  void setTextSize (uint8_t size);
196 
202  void setTextWrap (uint8_t wrap);
203 
204  int m_height;
205  int m_width;
209  int m_cursorX;
210  int m_cursorY;
211  int m_wrap;
213  uint8_t * m_map;
215  protected:
216  const int16_t WIDTH, HEIGHT;
217  const unsigned char * m_font;
218  };
219 }
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:206
void setTextWrap(uint8_t wrap)
Definition: gfx.cxx:174
int m_cursorY
Definition: gfx.h:210
int m_width
Definition: gfx.h:205
uint8_t * m_map
Definition: gfx.h:213
GFX helper class.
Definition: gfx.h:42
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:208
Definition: a110x.h:33
void setTextSize(uint8_t size)
Definition: gfx.cxx:169
int m_cursorX
Definition: gfx.h:209
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:211
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Definition: gfx.cxx:69
int m_textColor
Definition: gfx.h:207
mraa::Result setPixel(int x, int y, uint16_t color)
Definition: gfx.cxx:44
int m_height
Definition: gfx.h:204
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
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