upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
st7735_gfx.hpp
1 /*
2  * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
3  * Copyright (c) 2014 Intel Corporation.
4  *
5  * Based on GFX interface by Adafruit Industries.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  */
26 #pragma once
27 
28 #include <string>
29 #include <stdio.h>
30 #include <unistd.h>
31 #include <stdint.h>
32 
33 #include <mraa.hpp>
34 
35 #define swap(a, b) { int16_t t = a; a = b; b = t; }
36 
37 namespace upm {
38 
44 class GFX {
45  public:
54  GFX (int width, int height, uint8_t * screenBuffer, const unsigned char * font);
55 
59  virtual ~GFX ();
60 
69  virtual void setAddrWindow (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1) = 0;
70 
79  virtual void drawPixel (int16_t x, int16_t y, uint16_t color) = 0;
80 
84  virtual void refresh () = 0;
85 
96  void drawChar (int16_t x, int16_t y, uint8_t data, uint16_t color, uint16_t bg, uint8_t size);
97 
103  void print (std::string msg);
104 
112  mraa::Result setPixel (int x, int y, uint16_t color);
113 
119  void fillScreen (uint16_t color);
120 
130  void fillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
131 
140  void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
141 
151  void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
152 
164  void drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
165 
174  void drawCircle (int16_t x, int16_t y, int16_t r, uint16_t color);
175 
182  void setCursor (int16_t x, int16_t y);
183 
190  void setTextColor (uint16_t textColor, uint16_t textBGColor);
191 
197  void setTextSize (uint8_t size);
198 
204  void setTextWrap (uint8_t wrap);
205 
206  int m_height;
207  int m_width;
208  int m_textSize;
209  int m_textColor;
210  int m_textBGColor;
211  int m_cursorX;
212  int m_cursorY;
213  int m_wrap;
215  uint8_t * m_map;
217  protected:
218  const int16_t WIDTH, HEIGHT;
219  const unsigned char * m_font;
220  };
221 }
virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
Definition: ili9341_gfx.cxx:46
int m_textSize
Definition: ssd1351_gfx.hpp:446
void setTextSize(uint8_t s)
Definition: ili9341_gfx.cxx:427
int m_cursorY
Definition: ssd1351_gfx.hpp:450
int m_width
Definition: ssd1351_gfx.hpp:444
void setTextWrap(bool w)
Definition: ili9341_gfx.cxx:431
uint8_t * m_map
Definition: st7735_gfx.hpp:215
virtual void drawPixel(int16_t x, int16_t y, uint16_t color)=0
int16_t height(void) const
Definition: ili9341_gfx.cxx:489
void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
Definition: ili9341_gfx.cxx:243
virtual void fillScreen(uint16_t color)
Definition: ili9341_gfx.cxx:125
virtual ~GFX()
Definition: ili9341_gfx.hpp:53
void setTextColor(uint16_t c)
Definition: ili9341_gfx.cxx:416
virtual void refresh()=0
GFX(int16_t w, int16_t h)
Definition: ili9341_gfx.cxx:32
int m_textBGColor
Definition: ssd1351_gfx.hpp:448
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
int m_cursorX
Definition: ssd1351_gfx.hpp:449
void setCursor(int16_t x, int16_t y)
Definition: ili9341_gfx.cxx:411
int m_wrap
Definition: ssd1351_gfx.hpp:451
virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Definition: ili9341_gfx.cxx:90
int m_textColor
Definition: ssd1351_gfx.hpp:447
void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size)
Definition: ili9341_gfx.cxx:372
mraa::Result setPixel(int x, int y, uint16_t color)
Definition: st7735_gfx.cxx:46
int m_height
Definition: ssd1351_gfx.hpp:445
void print(std::string msg)
Definition: ili9341_gfx.cxx:478
int16_t width(void) const
Definition: ili9341_gfx.cxx:485
void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Definition: ili9341_gfx.cxx:133
virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Definition: ili9341_gfx.cxx:115
virtual void setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1)=0