| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

Adafruit_GFX.h
Go to the documentation of this file.
1 #ifndef _ADAFRUIT_GFX_H
2 #define _ADAFRUIT_GFX_H
3
4 #if ARDUINO >= 100
5 #include "Arduino.h"
6 #include "Print.h"
7 #else
8 #include "WProgram.h"
9 #endif
10
11 #include "gfxfont.h"
12
13 class Adafruit_GFX : public Print
14 {
15
16 public:
17
18 Adafruit_GFX(int16_t w, int16_t h); // Constructor
19
20 // This MUST be defined by the subclass:
21 virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
22
23 // These MAY be overridden by the subclass to provide device-specific
24 // optimized code. Otherwise 'generic' versions are used.
25 virtual void
26 drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color),
27 drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color),
28 drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color),
29 drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color),
30 fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color),
31 fillScreen(uint16_t color),
32 invertDisplay(boolean i);
33
34 // These exist only with Adafruit_GFX (no subclass overrides)
35 void
36 drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color),
37 drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
38 uint16_t color),
39 fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color),
40 fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
41 int16_t delta, uint16_t color),
42 drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
43 int16_t x2, int16_t y2, uint16_t color),
44 fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
45 int16_t x2, int16_t y2, uint16_t color),
46 drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
47 int16_t radius, uint16_t color),
48 fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
49 int16_t radius, uint16_t color),
50 drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
51 int16_t w, int16_t h, uint16_t color),
52 drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
53 int16_t w, int16_t h, uint16_t color, uint16_t bg),
54 drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
55 int16_t w, int16_t h, uint16_t color),
56 drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
57 int16_t w, int16_t h, uint16_t color, uint16_t bg),
58 drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
59 int16_t w, int16_t h, uint16_t color),
60 drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
61 uint16_t bg, uint8_t size),
62 setCursor(int16_t x, int16_t y),
63 setTextColor(uint16_t c),
64 setTextColor(uint16_t c, uint16_t bg),
65 setTextSize(uint8_t s),
66 setTextWrap(boolean w),
67 setRotation(uint8_t r),
68 cp437(boolean x=true),
69 setFont(const GFXfont *f = NULL),
70 getTextBounds(char *string, int16_t x, int16_t y,
71 int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h),
72 getTextBounds(const __FlashStringHelper *s, int16_t x, int16_t y,
73 int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h);
74
75 #if ARDUINO >= 100
76 virtual size_t write(uint8_t);
77 #else
78 virtual void write(uint8_t);
79 #endif
80
81 int16_t height(void) const;
82 int16_t width(void) const;
83
84 uint8_t getRotation(void) const;
85
86 // get current cursor position (get rotation safe maximum values, using: width() for x, height() for y)
87 int16_t getCursorX(void) const;
88 int16_t getCursorY(void) const;
89
90 protected:
91 const int16_t
92 WIDTH, HEIGHT; // This is the 'raw' display w/h - never changes
93 int16_t
94 _width, _height, // Display w/h as modified by current rotation
95 cursor_x, cursor_y;
96 uint16_t
97 textcolor, textbgcolor;
98 uint8_t
99 textsize,
100 rotation;
101 boolean
102 wrap, // If set, 'wrap' text at right edge of display
103 _cp437; // If set, use correct CP437 charset (default is off)
104 GFXfont
105 *gfxFont;
106 };
107
108 class Adafruit_GFX_Button
109 {
110
111 public:
112 Adafruit_GFX_Button(void);
113 void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y,
114 uint8_t w, uint8_t h, uint16_t outline, uint16_t fill,
115 uint16_t textcolor, char *label, uint8_t textsize);
116 void drawButton(boolean inverted = false);
117 boolean contains(int16_t x, int16_t y);
118
119 void press(boolean p);
120 boolean isPressed();
121 boolean justPressed();
122 boolean justReleased();
123
124 private:
125 Adafruit_GFX *_gfx;
126 int16_t _x, _y;
127 uint16_t _w, _h;
128 uint8_t _textsize;
129 uint16_t _outlinecolor, _fillcolor, _textcolor;
130 char _label[10];
131
132 boolean currstate, laststate;
133 };
134
135 class GFXcanvas1 : public Adafruit_GFX
136 {
137
138 public:
139 GFXcanvas1(uint16_t w, uint16_t h);
140 ~GFXcanvas1(void);
141 void drawPixel(int16_t x, int16_t y, uint16_t color),
142 fillScreen(uint16_t color);
143 uint8_t *getBuffer(void);
144 private:
145 uint8_t *buffer;
146 };
147
148 class GFXcanvas16 : public Adafruit_GFX
149 {
150 GFXcanvas16(uint16_t w, uint16_t h);
151 ~GFXcanvas16(void);
152 void drawPixel(int16_t x, int16_t y, uint16_t color),
153 fillScreen(uint16_t color);
154 uint16_t *getBuffer(void);
155 private:
156 uint16_t *buffer;
157 };
158
159 #endif // _ADAFRUIT_GFX_H
Adafruit_GFX::drawBitmap
void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color)
Definition: Adafruit_GFX.cpp:430
Adafruit_GFX::drawRect
virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Definition: Adafruit_GFX.cpp:264
Adafruit_GFX::textsize
uint8_t textsize
Definition: Adafruit_GFX.h:99
Adafruit_GFX::invertDisplay
virtual void invertDisplay(boolean i)
Definition: Adafruit_GFX.cpp:1030
Adafruit_GFX::height
int16_t height(void) const
Definition: Adafruit_GFX.cpp:1025
Adafruit_GFX::cursor_y
int16_t cursor_y
Definition: Adafruit_GFX.h:94
GFXcanvas16
Definition: Adafruit_GFX.h:148
Adafruit_GFX::setFont
void setFont(const GFXfont *f=NULL)
Definition: Adafruit_GFX.cpp:783
Adafruit_GFX::fillRoundRect
void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
Definition: Adafruit_GFX.cpp:319
Adafruit_GFX::getCursorY
int16_t getCursorY(void) const
Definition: Adafruit_GFX.cpp:720
Adafruit_GFX::drawRoundRect
void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
Definition: Adafruit_GFX.cpp:303
Adafruit_GFX::drawTriangle
void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
Definition: Adafruit_GFX.cpp:331
Adafruit_GFX::setCursor
void setCursor(int16_t x, int16_t y)
Definition: Adafruit_GFX.cpp:709
Adafruit_GFX::fillTriangle
void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
Definition: Adafruit_GFX.cpp:340
Adafruit_GFX::textbgcolor
uint16_t textbgcolor
Definition: Adafruit_GFX.h:97
Adafruit_GFX::width
int16_t width(void) const
Definition: Adafruit_GFX.cpp:1020
Adafruit_GFX::rotation
uint8_t rotation
Definition: Adafruit_GFX.h:99
Adafruit_GFX::getCursorX
int16_t getCursorX(void) const
Definition: Adafruit_GFX.cpp:715
Adafruit_GFX::cursor_x
int16_t cursor_x
Definition: Adafruit_GFX.h:94
Adafruit_GFX::drawPixel
virtual void drawPixel(int16_t x, int16_t y, uint16_t color)=0
Adafruit_GFX::drawXBitmap
void drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color)
Definition: Adafruit_GFX.cpp:512
Adafruit_GFX
Definition: Adafruit_GFX.h:13
Adafruit_GFX::drawCircleHelper
void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color)
Definition: Adafruit_GFX.cpp:125
GFXcanvas1
Definition: Adafruit_GFX.h:135
Adafruit_GFX::fillRect
virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
Definition: Adafruit_GFX.cpp:287
Adafruit_GFX::fillCircleHelper
void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color)
Definition: Adafruit_GFX.cpp:176
Adafruit_GFX::getTextBounds
void getTextBounds(char *string, int16_t x, int16_t y, int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h)
Definition: Adafruit_GFX.cpp:804
Adafruit_GFX::setTextColor
void setTextColor(uint16_t c)
Definition: Adafruit_GFX.cpp:730
Adafruit_GFX::fillScreen
virtual void fillScreen(uint16_t color)
Definition: Adafruit_GFX.cpp:297
Adafruit_GFX::_cp437
boolean _cp437
Definition: Adafruit_GFX.h:102
Adafruit_GFX_Button
Definition: Adafruit_GFX.h:108
Adafruit_GFX::write
virtual void write(uint8_t)
Definition: Adafruit_GFX.cpp:534
Adafruit_GFX::_height
int16_t _height
Definition: Adafruit_GFX.h:94
Adafruit_GFX::cp437
void cp437(boolean x=true)
Definition: Adafruit_GFX.cpp:778
Adafruit_GFX::getRotation
uint8_t getRotation(void) const
Definition: Adafruit_GFX.cpp:748
Adafruit_GFX::drawLine
virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
Definition: Adafruit_GFX.cpp:212
GFXfont
Definition: gfxfont.h:18
Adafruit_GFX::drawChar
void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size)
Definition: Adafruit_GFX.cpp:603
Adafruit_GFX::drawCircle
void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Definition: Adafruit_GFX.cpp:88
Adafruit_GFX::drawFastHLine
virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
Definition: Adafruit_GFX.cpp:280
Adafruit_GFX::fillCircle
void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color)
Definition: Adafruit_GFX.cpp:168
Adafruit_GFX::gfxFont
GFXfont * gfxFont
Definition: Adafruit_GFX.h:105
Adafruit_GFX::textcolor
uint16_t textcolor
Definition: Adafruit_GFX.h:97
Adafruit_GFX::wrap
boolean wrap
Definition: Adafruit_GFX.h:102
x
int32_t x
Definition: LTC2492_Thermocouple_Meter.ino:119
gfxfont.h
Adafruit_GFX::setTextWrap
void setTextWrap(boolean w)
Definition: Adafruit_GFX.cpp:743
Adafruit_GFX::setTextSize
void setTextSize(uint8_t s)
Definition: Adafruit_GFX.cpp:725
Adafruit_GFX::HEIGHT
const int16_t HEIGHT
Definition: Adafruit_GFX.h:92
Adafruit_GFX::Adafruit_GFX
Adafruit_GFX(int16_t w, int16_t h)
Definition: Adafruit_GFX.cpp:73
Adafruit_GFX::setRotation
void setRotation(uint8_t r)
Definition: Adafruit_GFX.cpp:753
i
static int i
Definition: DC2430A.ino:184
Adafruit_GFX::drawFastVLine
virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
Definition: Adafruit_GFX.cpp:273
Adafruit_GFX::_width
int16_t _width
Definition: Adafruit_GFX.h:94
Adafruit_GFX::WIDTH
const int16_t WIDTH
Definition: Adafruit_GFX.h:92