upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups 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 
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 }
virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
Definition: gfx.cxx:45
int m_textSize
Definition: gfx.h:206
void setTextSize(uint8_t s)
Definition: gfx.cxx:426
int m_cursorY
Definition: gfx.h:210
int m_width
Definition: gfx.h:205
void setTextWrap(bool w)
Definition: gfx.cxx:430
uint8_t * m_map
Definition: gfx.h:213
virtual void drawPixel(int16_t x, int16_t y, uint16_t color)=0
int16_t height(void) const
Definition: gfx.cxx:488
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:242
virtual void fillScreen(uint16_t color)
Definition: gfx.cxx:124
~GFX()
Definition: gfx.cxx:40
void setTextColor(uint16_t c)
Definition: gfx.cxx:415
virtual void refresh()=0
GFX(int16_t w, int16_t h)
Definition: gfx.cxx:31
int m_textBGColor
Definition: gfx.h:208
int m_cursorX
Definition: gfx.h:209
void setCursor(int16_t x, int16_t y)
Definition: gfx.cxx:410
int m_wrap
Definition: gfx.h:211
virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Definition: gfx.cxx:89
int m_textColor
Definition: gfx.h:207
void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size)
Definition: gfx.cxx:371
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:477
int16_t width(void) const
Definition: gfx.cxx:484
void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Definition: gfx.cxx:132
virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Definition: gfx.cxx:114
virtual void setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1)=0