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 
27 #pragma once
28 
29 #include <mraa.hpp>
30 
31 #define adagfxswap(a, b) { int16_t t = a; a = b; b = t; }
32 
33 namespace upm
34 {
38  class GFX {
39  public:
40 
47  GFX(int16_t w, int16_t h);
48 
57  virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
58 
68  virtual void drawLine(int16_t x0,
69  int16_t y0,
70  int16_t x1,
71  int16_t y1,
72  uint16_t color);
73 
82  virtual void drawFastVLine(int16_t x,
83  int16_t y,
84  int16_t h,
85  uint16_t color);
86 
95  virtual void drawFastHLine(int16_t x,
96  int16_t y,
97  int16_t w,
98  uint16_t color);
99 
109  virtual void drawRect(int16_t x,
110  int16_t y,
111  int16_t w,
112  int16_t h,
113  uint16_t color);
114 
124  virtual void fillRect(int16_t x,
125  int16_t y,
126  int16_t w,
127  int16_t h,
128  uint16_t color);
129 
135  virtual void fillScreen(uint16_t color);
136 
142  virtual void invertDisplay(bool i);
143 
152  void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
153 
163  void drawCircleHelper(int16_t x0,
164  int16_t y0,
165  int16_t r,
166  uint8_t cornername,
167  uint16_t color);
168 
177  void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
178 
189  void fillCircleHelper(int16_t x0,
190  int16_t y0,
191  int16_t r,
192  uint8_t cornername,
193  int16_t delta,
194  uint16_t color);
195 
207  void drawTriangle(int16_t x0,
208  int16_t y0,
209  int16_t x1,
210  int16_t y1,
211  int16_t x2,
212  int16_t y2,
213  uint16_t color);
214 
226  void fillTriangle(int16_t x0,
227  int16_t y0,
228  int16_t x1,
229  int16_t y1,
230  int16_t x2,
231  int16_t y2,
232  uint16_t color);
233 
244  void drawRoundRect(int16_t x0,
245  int16_t y0,
246  int16_t w,
247  int16_t h,
248  int16_t radius,
249  uint16_t color);
250 
261  void fillRoundRect(int16_t x0,
262  int16_t y0,
263  int16_t w,
264  int16_t h,
265  int16_t radius,
266  uint16_t color);
267 
278  void drawChar(int16_t x,
279  int16_t y,
280  unsigned char c,
281  uint16_t color,
282  uint16_t bg,
283  uint8_t size);
284 
290  int16_t getCursorX(void) const;
291 
297  int16_t getCursorY(void) const;
298 
305  void setCursor(int16_t x, int16_t y);
306 
312  void setTextColor(uint16_t c);
313 
320  void setTextColor(uint16_t c, uint16_t bg);
321 
327  void setTextSize(uint8_t s);
328 
334  void setTextWrap(bool w);
335 
341  uint8_t getRotation(void) const;
342 
349  void setRotation(uint8_t r);
350 
356  void cp437(bool x);
357 
364  virtual void write(uint8_t c);
365 
371  void print(std::string msg);
372 
378  int16_t width(void) const;
379 
385  int16_t height(void) const;
386 
387  protected:
388 
389  const int16_t WIDTH;
390  const int16_t HEIGHT;
391 
392  int16_t _width;
393  int16_t _height;
394 
395  uint8_t rotation;
396 
397  uint16_t textcolor;
398  uint16_t textbgcolor;
399  int16_t cursor_x;
400  int16_t cursor_y;
401  uint8_t textsize;
402  bool wrap;
403  bool _cp437;
404  static const unsigned char font[];
405  };
406 }
virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
Definition: gfx.cxx:45
void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
Definition: gfx.cxx:254
void setTextSize(uint8_t s)
Definition: gfx.cxx:426
virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
Definition: gfx.cxx:96
void setTextWrap(bool w)
Definition: gfx.cxx:430
GFX helper class.
Definition: gfx.h:38
virtual void drawPixel(int16_t x, int16_t y, uint16_t color)=0
int16_t height(void) const
Definition: gfx.cxx:488
virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Definition: gfx.cxx:103
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
int16_t getCursorX(void) const
Definition: gfx.cxx:402
virtual void fillScreen(uint16_t color)
Definition: gfx.cxx:124
void setTextColor(uint16_t c)
Definition: gfx.cxx:415
GFX(int16_t w, int16_t h)
Definition: gfx.cxx:31
void setRotation(uint8_t r)
Definition: gfx.cxx:438
void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color)
Definition: gfx.cxx:165
void setCursor(int16_t x, int16_t y)
Definition: gfx.cxx:410
void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
Definition: gfx.cxx:356
void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
Definition: gfx.cxx:337
virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Definition: gfx.cxx:89
void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color)
Definition: gfx.cxx:209
void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size)
Definition: gfx.cxx:371
void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Definition: gfx.cxx:204
uint8_t getRotation(void) const
Definition: gfx.cxx:434
int16_t getCursorY(void) const
Definition: gfx.cxx:406
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
void cp437(bool x)
Definition: gfx.cxx:454
virtual void invertDisplay(bool i)
Definition: gfx.cxx:128
virtual void write(uint8_t c)
Definition: gfx.cxx:458
virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Definition: gfx.cxx:114