TR-mbed 1.0
Loading...
Searching...
No Matches
Adafruit_GFX.h
Go to the documentation of this file.
1/***********************************
2This is a our graphics core library, for all our displays.
3We'll be adapting all the
4existing libaries to use this core to make updating, support
5and upgrading easier!
6
7Adafruit invests time and resources providing this open source code,
8please support Adafruit and open-source hardware by purchasing
9products from Adafruit!
10
11Written by Limor Fried/Ladyada for Adafruit Industries.
12BSD license, check license.txt for more information
13All text above must be included in any redistribution
14****************************************/
15
16/*
17 * Modified by Neal Horman 7/14/2012 for use in mbed
18 */
19
20#ifndef _ADAFRUIT_GFX_H_
21#define _ADAFRUIT_GFX_H_
22
23#include "Adafruit_GFX_Config.h"
24
25static inline void swap(int16_t &a, int16_t &b)
26{
27 int16_t t = a;
28
29 a = b;
30 b = t;
31}
32
33#ifndef _BV
34#define _BV(bit) (1<<(bit))
35#endif
36
37#define BLACK 0
38#define WHITE 1
39
49class Adafruit_GFX : public Stream
50{
51public:
52 Adafruit_GFX(int16_t w, int16_t h)
53 : _rawWidth(w)
54 , _rawHeight(h)
55 , _width(w)
56 , _height(h)
57 , cursor_x(0)
58 , cursor_y(0)
61 , textsize(1)
62 , rotation(0)
63 , wrap(true)
64 {};
65
67 // this must be defined by the subclass
68 virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
69 // this is optional
70 virtual void invertDisplay(bool i) {};
71
72 // Stream implementation - provides printf() interface
73 // You would otherwise be forced to use writeChar()
74 virtual int _putc(int value) { return writeChar(value); };
75 virtual int _getc() { return -1; };
76
77#ifdef GFX_WANT_ABSTRACTS
78 // these are 'generic' drawing functions, so we can share them!
79
83 virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
87 virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
91 virtual void fillScreen(uint16_t color);
92
96 void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
97 void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color);
98
102 void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
103 void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color);
104
108 void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
112 void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
113
117 void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
121 void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
125 void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color);
126#endif
127
128#if defined(GFX_WANT_ABSTRACTS) || defined(GFX_SIZEABLE_TEXT)
132 virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
136 virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
140 virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
141#endif
142
144 void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size);
146 size_t writeChar(uint8_t);
147
149 inline int16_t width(void) { return _width; };
151 inline int16_t height(void) { return _height; };
152
154 inline void setTextCursor(int16_t x, int16_t y) { cursor_x = x; cursor_y = y; };
155#if defined(GFX_WANT_ABSTRACTS) || defined(GFX_SIZEABLE_TEXT)
159 inline void setTextSize(uint8_t s) { textsize = (s > 0) ? s : 1; };
160#endif
162 inline void setTextColor(uint16_t c) { textcolor = c; textbgcolor = c; }
164 inline void setTextColor(uint16_t c, uint16_t b) { textcolor = c; textbgcolor = b; };
166 inline void setTextWrap(bool w) { wrap = w; };
167
169 void setRotation(uint8_t r);
171 inline uint8_t getRotation(void) { rotation %= 4; return rotation; };
172
173protected:
174 int16_t _rawWidth, _rawHeight; // this is the 'raw' display w/h - never changes
175 int16_t _width, _height; // dependent on rotation
178 uint8_t textsize;
179 uint8_t rotation;
180 bool wrap; // If set, 'wrap' text at right edge of display
181};
182
183#endif
#define BLACK
Definition Adafruit_GFX.h:37
#define WHITE
Definition Adafruit_GFX.h:38
ArrayXXi a
Definition Array_initializer_list_23_cxx11.cpp:1
int i
Definition BiCGSTAB_step_by_step.cpp:9
RowVector3d w
Definition Matrix_resize_int.cpp:3
Scalar Scalar * c
Definition benchVecAdd.cpp:17
Scalar * b
Definition benchVecAdd.cpp:17
Scalar Scalar int size
Definition benchVecAdd.cpp:17
Definition Adafruit_GFX.h:50
virtual void invertDisplay(bool i)
Definition Adafruit_GFX.h:70
size_t writeChar(uint8_t)
Draw a text character at the text cursor location.
Definition Adafruit_GFX.cpp:366
int16_t _rawWidth
Definition Adafruit_GFX.h:174
uint16_t textbgcolor
Definition Adafruit_GFX.h:177
void setTextWrap(bool w)
Set text wraping mode true or false.
Definition Adafruit_GFX.h:166
uint8_t rotation
Definition Adafruit_GFX.h:179
void setTextColor(uint16_t c, uint16_t b)
Set the text foreground and background colors independantly.
Definition Adafruit_GFX.h:164
int16_t _rawHeight
Definition Adafruit_GFX.h:174
void setTextColor(uint16_t c)
Set the text foreground and background colors to be the same.
Definition Adafruit_GFX.h:162
virtual int _getc()
Definition Adafruit_GFX.h:75
void setRotation(uint8_t r)
Set the display rotation, 1, 2, 3, or 4.
Definition Adafruit_GFX.cpp:437
Adafruit_GFX(int16_t w, int16_t h)
Definition Adafruit_GFX.h:52
bool wrap
Definition Adafruit_GFX.h:180
uint16_t textcolor
Definition Adafruit_GFX.h:177
virtual int _putc(int value)
Definition Adafruit_GFX.h:74
int16_t cursor_x
Definition Adafruit_GFX.h:176
uint8_t getRotation(void)
Get the current rotation.
Definition Adafruit_GFX.h:171
int16_t width(void)
Get the width of the display in pixels.
Definition Adafruit_GFX.h:149
int16_t _width
Definition Adafruit_GFX.h:175
void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size)
Draw a text character at a specified pixel location.
Definition Adafruit_GFX.cpp:389
virtual void drawPixel(int16_t x, int16_t y, uint16_t color)=0
Paint one BLACK or WHITE pixel in the display buffer.
int16_t _height
Definition Adafruit_GFX.h:175
int16_t height(void)
Get the height of the display in pixels.
Definition Adafruit_GFX.h:151
uint8_t textsize
Definition Adafruit_GFX.h:178
void setTextCursor(int16_t x, int16_t y)
Set the text cursor location, based on the size of the text.
Definition Adafruit_GFX.h:154
int16_t cursor_y
Definition Adafruit_GFX.h:176
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition gnuplot_common_settings.hh:12
RealScalar s
Definition level1_cplx_impl.h:126
Scalar * y
Definition level1_cplx_impl.h:124
int EIGEN_BLAS_FUNC() swap(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
Definition level1_impl.h:130
::int16_t int16_t
Definition Meta.h:55