source: rtos_arduino/trunk/arduino_lib/libraries/Robot_Control/src/utility/Adafruit_GFX.h@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 5.7 KB
Line 
1/******************************************************************
2 This is the core graphics library for all our displays, providing
3 basic graphics primitives (points, lines, circles, etc.). It needs
4 to be paired with a hardware-specific library for each display
5 device we carry (handling the lower-level functions).
6
7 Adafruit invests time and resources providing this open
8 source code, please support Adafruit and open-source hardware
9 by purchasing products from Adafruit!
10
11 Written by Limor Fried/Ladyada for Adafruit Industries.
12 BSD license, check license.txt for more information.
13 All text above must be included in any redistribution.
14 ******************************************************************/
15
16#ifndef _ADAFRUIT_GFX_H
17#define _ADAFRUIT_GFX_H
18
19#if ARDUINO >= 100
20 #include "Arduino.h"
21 #include "Print.h"
22#else
23 #include "WProgram.h"
24#endif
25
26//#include "PImage.h"
27
28#define swap(a, b) { int16_t t = a; a = b; b = t; }
29
30/* TODO
31enum RectMode {
32 CORNER,
33 CORNERS,
34 RADIUS,
35 CENTER
36};
37*/
38
39typedef uint16_t color;
40
41class Adafruit_GFX : public Print {
42 public:
43
44 Adafruit_GFX(int16_t w, int16_t h); // Constructor
45
46 // This MUST be defined by the subclass:
47 virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
48
49 // These MAY be overridden by the subclass to provide device-specific
50 // optimized code. Otherwise 'generic' versions are used.
51 virtual void
52 drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color),
53 drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color),
54 drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color),
55 drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color),
56 fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color),
57 fillScreen(uint16_t color),
58 invertDisplay(boolean i);
59
60 // These exist only with Adafruit_GFX (no subclass overrides)
61 void
62 drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color),
63 drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
64 uint16_t color),
65 fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color),
66 fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
67 int16_t delta, uint16_t color),
68 drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
69 int16_t x2, int16_t y2, uint16_t color),
70 fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
71 int16_t x2, int16_t y2, uint16_t color),
72 drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
73 int16_t radius, uint16_t color),
74 fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
75 int16_t radius, uint16_t color),
76 drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
77 int16_t w, int16_t h, uint16_t color),
78 drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
79 uint16_t bg, uint8_t size),
80 setCursor(int16_t x, int16_t y),
81 setTextColor(uint16_t c),
82 setTextColor(uint16_t c, uint16_t bg),
83 setTextSize(uint8_t s),
84 setTextWrap(boolean w),
85 setRotation(uint8_t r);
86
87#if ARDUINO >= 100
88 virtual size_t write(uint8_t);
89#else
90 virtual void write(uint8_t);
91#endif
92
93 int16_t
94 height(void),
95 width(void);
96
97 uint8_t getRotation(void);
98
99
100 /*
101 * Processing-like graphics primitives
102 */
103
104 /// transforms a color in 16-bit form given the RGB components.
105 /// The default implementation makes a 5-bit red, a 6-bit
106 /// green and a 5-bit blue (MSB to LSB). Devices that use
107 /// different scheme should override this.
108 virtual uint16_t newColor(uint8_t red, uint8_t green, uint8_t blue);
109
110
111 // http://processing.org/reference/background_.html
112 void background(uint8_t red, uint8_t green, uint8_t blue);
113 void background(color c);
114
115 // http://processing.org/reference/fill_.html
116 void fill(uint8_t red, uint8_t green, uint8_t blue);
117 void fill(color c);
118
119 // http://processing.org/reference/noFill_.html
120 void noFill();
121
122 // http://processing.org/reference/stroke_.html
123 void stroke(uint8_t red, uint8_t green, uint8_t blue);
124 void stroke(color c);
125
126 // http://processing.org/reference/noStroke_.html
127 void noStroke();
128
129 void text(const char * text, int16_t x, int16_t y);
130 void text(int value, uint8_t posX, uint8_t posY);
131 void text(long value, uint8_t posX, uint8_t posY);
132 void text(char value, uint8_t posX, uint8_t posY);
133
134 void textWrap(const char * text, int16_t x, int16_t y);
135
136 void textSize(uint8_t size);
137
138 // similar to ellipse() in Processing, but with
139 // a single radius.
140 // http://processing.org/reference/ellipse_.html
141 void circle(int16_t x, int16_t y, int16_t r);
142
143 void point(int16_t x, int16_t y);
144
145 void line(int16_t x1, int16_t y1, int16_t x2, int16_t y2);
146
147 void quad(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t x3, int16_t y3, int16_t x4, int16_t y4);
148
149 void rect(int16_t x, int16_t y, int16_t width, int16_t height);
150
151 void rect(int16_t x, int16_t y, int16_t width, int16_t height, int16_t radius);
152
153 void triangle(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t x3, int16_t y3);
154
155 /* TODO
156 void rectMode(RectMode mode);
157
158 void pushStyle();
159 void popStyle();
160 */
161
162// PImage loadImage(const char * fileName) { return PImage::loadImage(fileName); }
163
164// void image(PImage & img, uint16_t x, uint16_t y);
165
166 protected:
167 const int16_t
168 WIDTH, HEIGHT; // This is the 'raw' display w/h - never changes
169 int16_t
170 _width, _height, // Display w/h as modified by current rotation
171 cursor_x, cursor_y;
172 uint16_t
173 textcolor, textbgcolor;
174 uint8_t
175 textsize,
176 rotation;
177 boolean
178 wrap; // If set, 'wrap' text at right edge of display
179
180 /*
181 * Processing-style graphics state
182 */
183
184 color strokeColor;
185 bool useStroke;
186 color fillColor;
187 bool useFill;
188};
189
190#endif // _ADAFRUIT_GFX_H
Note: See TracBrowser for help on using the repository browser.