upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
ili9341_gfx.hpp
1 
27 #pragma once
28 
29 #include <cstdint>
30 #include <string>
31 
32 #define adagfxswap(a, b) { int16_t t = a; a = b; b = t; }
33 
34 namespace upm
35 {
39  class GFX {
40  public:
41 
48  GFX(int16_t w, int16_t h);
49 
53  virtual ~GFX() {};
54 
63  virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
64 
74  virtual void drawLine(int16_t x0,
75  int16_t y0,
76  int16_t x1,
77  int16_t y1,
78  uint16_t color);
79 
88  virtual void drawFastVLine(int16_t x,
89  int16_t y,
90  int16_t h,
91  uint16_t color);
92 
101  virtual void drawFastHLine(int16_t x,
102  int16_t y,
103  int16_t w,
104  uint16_t color);
105 
115  virtual void drawRect(int16_t x,
116  int16_t y,
117  int16_t w,
118  int16_t h,
119  uint16_t color);
120 
130  virtual void fillRect(int16_t x,
131  int16_t y,
132  int16_t w,
133  int16_t h,
134  uint16_t color);
135 
141  virtual void fillScreen(uint16_t color);
142 
148  virtual void invertDisplay(bool i);
149 
158  void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
159 
169  void drawCircleHelper(int16_t x0,
170  int16_t y0,
171  int16_t r,
172  uint8_t cornername,
173  uint16_t color);
174 
183  void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
184 
195  void fillCircleHelper(int16_t x0,
196  int16_t y0,
197  int16_t r,
198  uint8_t cornername,
199  int16_t delta,
200  uint16_t color);
201 
213  void drawTriangle(int16_t x0,
214  int16_t y0,
215  int16_t x1,
216  int16_t y1,
217  int16_t x2,
218  int16_t y2,
219  uint16_t color);
220 
232  void fillTriangle(int16_t x0,
233  int16_t y0,
234  int16_t x1,
235  int16_t y1,
236  int16_t x2,
237  int16_t y2,
238  uint16_t color);
239 
250  void drawRoundRect(int16_t x0,
251  int16_t y0,
252  int16_t w,
253  int16_t h,
254  int16_t radius,
255  uint16_t color);
256 
267  void fillRoundRect(int16_t x0,
268  int16_t y0,
269  int16_t w,
270  int16_t h,
271  int16_t radius,
272  uint16_t color);
273 
284  void drawChar(int16_t x,
285  int16_t y,
286  unsigned char c,
287  uint16_t color,
288  uint16_t bg,
289  uint8_t size);
290 
296  int16_t getCursorX(void) const;
297 
303  int16_t getCursorY(void) const;
304 
311  void setCursor(int16_t x, int16_t y);
312 
318  void setTextColor(uint16_t c);
319 
326  void setTextColor(uint16_t c, uint16_t bg);
327 
333  void setTextSize(uint8_t s);
334 
340  void setTextWrap(bool w);
341 
347  uint8_t getRotation(void) const;
348 
355  void setRotation(uint8_t r);
356 
362  void cp437(bool x);
363 
370  virtual void write(uint8_t c);
371 
377  void print(std::string msg);
378 
384  int16_t width(void) const;
385 
391  int16_t height(void) const;
392 
393  protected:
394 
395  const int16_t WIDTH;
396  const int16_t HEIGHT;
397 
398  int16_t _width;
399  int16_t _height;
400 
401  uint8_t rotation;
402 
403  uint16_t textcolor;
404  uint16_t textbgcolor;
405  int16_t cursor_x;
406  int16_t cursor_y;
407  uint8_t textsize;
408  bool wrap;
409  bool _cp437;
410  static const unsigned char font[];
411  };
412 }
virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
Definition: ili9341_gfx.cxx:46
void fillTriangle(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:255
void setTextSize(uint8_t s)
Definition: ili9341_gfx.cxx:427
virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
Definition: ili9341_gfx.cxx:97
void setTextWrap(bool w)
Definition: ili9341_gfx.cxx:431
GFX helper class.
Definition: ili9341_gfx.hpp:39
virtual void drawPixel(int16_t x, int16_t y, uint16_t color)=0
int16_t height(void) const
Definition: ili9341_gfx.cxx:489
virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Definition: ili9341_gfx.cxx:104
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
int16_t getCursorX(void) const
Definition: ili9341_gfx.cxx:403
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
GFX(int16_t w, int16_t h)
Definition: ili9341_gfx.cxx:32
void setRotation(uint8_t r)
Definition: ili9341_gfx.cxx:439
void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color)
Definition: ili9341_gfx.cxx:166
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
void setCursor(int16_t x, int16_t y)
Definition: ili9341_gfx.cxx:411
void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
Definition: ili9341_gfx.cxx:357
void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
Definition: ili9341_gfx.cxx:338
virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Definition: ili9341_gfx.cxx:90
void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color)
Definition: ili9341_gfx.cxx:210
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
void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Definition: ili9341_gfx.cxx:205
uint8_t getRotation(void) const
Definition: ili9341_gfx.cxx:435
int16_t getCursorY(void) const
Definition: ili9341_gfx.cxx:407
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
void cp437(bool x)
Definition: ili9341_gfx.cxx:455
virtual void invertDisplay(bool i)
Definition: ili9341_gfx.cxx:129
virtual void write(uint8_t c)
Definition: ili9341_gfx.cxx:459
virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Definition: ili9341_gfx.cxx:115