WWW.ABSTRACT.XLIBX.INFO
FREE ELECTRONIC LIBRARY - Abstract, dissertation, book
 
<< HOME
CONTACTS



Pages:   || 2 |

«Last updated on 2016-01-23 03:00:16 PM EST Guide Contents Guide Contents 2 Overview 3 Coordinate System and Units 5 Graphics Primitives 7 Drawing ...»

-- [ Page 1 ] --

Adafruit GFX Graphics Library

Created by Phillip Burgess

Last updated on 2016-01-23 03:00:16 PM EST

Guide Contents

Guide Contents 2

Overview 3

Coordinate System and Units 5

Graphics Primitives 7 Drawing pixels (points) 7 Drawing lines 7 Rectangles 9 Circles 10 Rounded rectangles 11 Triangles 12 Characters and text 13 Bitmaps 15 Clearing or filling the screen 16 Rotating the Display 17 Using Fonts 19 Using GFX Fonts in Arduino Sketches 20 Adding New Fonts 23 © Adafruit Industries https://learn.adafruit.com/adafruit-gfx-graphics-library Page 2 of 23 Overview The Adafruit_GFX library for Arduino provides a common syntax and set of graphics functions for all of our LCD and OLED displays. This allows Arduino sketches to easily be adapted between display types with minimal fuss…and any new features, performance improvements and bug fixes will immediately apply across our complete offering of color displays.

Download Adafruit_GFX Library http://adafru.it/cBB The Adafruit_GFX library always works together with a second library provided for each specific display type — for example, the ST7735 1.8" color LCD requires installing both the Adafruit_GFX

and Adafruit_ST7735 libraries. The following libraries now operate in this manner:

RGBmatrixPanel (http://adafru.it/aHj), for our 16x32 (http://adafru.it/420) and 32x32 (http://adafru.it/607) RGB LED matrix panels.

Adafruit_TFTLCD (http://adafru.it/aHk), for our 2.8" TFT LCD touchscreen © Adafruit Industries https://learn.adafruit.com/adafruit-gfx-graphics-library Page 3 of 23 breakout (http://adafru.it/335) and TFT Touch Shield for Arduino (http://adafru.it/376).

Adafruit_HX8340B (http://adafru.it/aHl), for our 2.2" TFT Display with microSD (http://adafru.it/797).

Adafruit_ST7735 (http://adafru.it/aHm), for our 1.8" TFT Display with microSD (http://adafru.it/358).

Adafruit_PCD8544 (http://adafru.it/aHn), for the Nokia 5110/3310 monochrome LCD (http://adafru.it/338).

Adafruit-Graphic-VFD-Display-Library (http://adafru.it/aHo), for our 128x64 Graphic VFD (http://adafru.it/773).

Adafruit-SSD1331-OLED-Driver-Library-for-Arduino (http://adafru.it/aHp) for the 0.96" 16-bit Color OLED w/microSD Holder (http://adafru.it/684).

Adafruit_SSD1306 (http://adafru.it/aHq) for the Monochrome 128x64 (http://adafru.it/326) and 128x32 (http://adafru.it/661) OLEDs.

For information how to use and install libraries, see our tutorial (http://adafru.it/aYG)!

The libraries are written in C++ for Arduino but could easily be ported to any microcontroller by rewriting the low-level pin access functions.

© Adafruit Industries https://learn.adafruit.com/adafruit-gfx-graphics-library Page 4 of 23 Coordinate System and Units Pixels — picture elements, the blocks comprising a digital image — are addressed by their horizontal (X) and vertical (Y) coordinates. The coordinate system places the origin (0,0) at the top left corner, with positive X increasing to the right and positive Y increasing downward. This is upside-down relative to the standard Cartesian coordinate system of mathematics, but is established practice in many computer graphics systems (a throwback to the days of raster-scan CRT graphics, which worked top-to-bottom). To use a tall “portrait” layout rather than wide “landscape” format, or if physical constraints dictate the orientation of a display in an enclosure, one of four rotation settings can also be applied, indicating which corner of the display represents the top left.

Also unlike the mathematical Cartesian coordinate system, points here have dimension — they are always one full integer pixel wide and tall.

Coordinates are always expressed in pixel units; there is no implicit scale to a real-world measure like millimeters or inches, and the size of a displayed graphic will be a function of that specific display’s dot pitch or pixel density. If you’re aiming for a real-world dimension, you’ll need to scale your coordinates to suit. Dot pitch can often be found in the device datasheet, or by measuring the screen width and dividing the number of pixels across by this measurement.

For color-capable displays, colors are represented as unsigned 16-bit values. Some displays may physically be capable of more or fewer bits than this, but the library operates with 16-bit values… these are easy for the Arduino to work with while also providing a consistent data type across all the different displays. The primary color components — red, green and blue — are all “packed” into a single 16-bit variable, with the most significant 5 bits conveying red, middle 6 bits conveying © Adafruit Industries https://learn.adafruit.com/adafruit-gfx-graphics-library Page 5 of 23 green, and least significant 5 bits conveying blue. That extra bit is assigned to green because our eyes are most sensitive to green light. Science!

For the most common primary and secondary colors, we have this handy cheat-sheet that you can include in your own code. Of course, you can pick any of 65,536 different colors, but this basic list

may be easiest when starting out:

// Color definitions #define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF For monochrome (single-color) displays, colors are always specified as simply 1 (set) or 0 (clear).





The semantics of set/clear are specific to the type of display: with something like a luminous OLED display, a “set” pixel is lighted, whereas with a reflective LCD display, a “set” pixel is typically dark.

There may be exceptions, but generally you can count on 0 (clear) representing the default background state for a freshly-initialized display, whatever that works out to be.

© Adafruit Industries https://learn.adafruit.com/adafruit-gfx-graphics-library Page 6 of 23 Graphics Primitives Each device-specific display library will have its own constructors and initialization functions. These are documented in the individual tutorials for each display type, or oftentimes are evident in the specific library header file. The remainder of this tutorial covers the common graphics functions that work the same regardless of the display type.

The function descriptions below are merely prototypes — there’s an assumption that a display object is declared and initialized as needed by the device-specific library. Look at the example code with each library to see it in actual use. For example, where we show print(1234.56), your actual code would place the object name before this, e.g. it might read screen.print(1234.56) (if you have declared your display object with the name screen).

Drawing pixels (points) First up is the most basic pixel pusher. You can call this with X, Y coordinates and a color and it will

make a single dot:

void drawPixel(uint16_t x, uint16_t y, uint16_t color);

Drawing lines

You can also draw lines, with a starting and end point and color:

© Adafruit Industries https://learn.adafruit.com/adafruit-gfx-graphics-library Page 7 of 23 void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);

For horizontal or vertical lines, there are optimized line-drawing functions that avoid the angular

calculations:

© Adafruit Industries https://learn.adafruit.com/adafruit-gfx-graphics-library Page 8 of 23 void drawFastVLine(uint16_t x0, uint16_t y0, uint16_t length, uint16_t color);

void drawFastHLine(uin86_t x0, uin86_t y0, uint8_t length, uint16_t color);

Rectangles Next up, rectangles and squares can be drawn and filled using the following procedures. Each accepts an X, Y pair for the top-left corner of the rectangle, a width and height (in pixels), and a color. drawRect() renders just the frame (outline) of the rectangle — the interior is unaffected —

while fillRect() fills the entire area with a given color:

void drawRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t color);

void fillRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t color);

© Adafruit Industries https://learn.adafruit.com/adafruit-gfx-graphics-library Page 9 of 23 To create a solid rectangle with a contrasting outline, use fillRect() first, then drawRect() over it.

Circles Likewise, for circles, you can draw and fill. Each function accepts an X, Y pair for the center point, a

radius in pixels, and a color:

void drawCircle(uint16_t x0, uint16_t y0, uint16_t r, uint16_t color);

void fillCircle(uint16_t x0, uint16_t y0, uint16_t r, uint16_t color);

© Adafruit Industries https://learn.adafruit.com/adafruit-gfx-graphics-library Page 10 of 23 Rounded rectangles For rectangles with rounded corners, both draw and fill functions are again available. Each begins with an X, Y, width and height (just like normal rectangles), then there’s a corner radius (in pixels)

and finally the color value:

© Adafruit Industries https://learn.adafruit.com/adafruit-gfx-graphics-library Page 11 of 23 void drawRoundRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t radius, uint16_t color);

void fillRoundRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t radius, uint16_t color);

Here’s an added bonus trick: because the circle functions are always drawn relative to a center pixel, the resulting circle diameter will always be an odd number of pixels. If an even-sized circle is required (which would place the center point between pixels), this can be achieved using one of the rounded rectangle functions: pass an identical width and height that are even values, and a corner radius that’s exactly half this value.

Triangles With triangles, once again there are the draw and fill functions. Each requires a full seven

parameters: the X, Y coordinates for three corner points defining the triangle, followed by a color:

void drawTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);

void fillTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);

© Adafruit Industries https://learn.adafruit.com/adafruit-gfx-graphics-library Page 12 of 23 Characters and text There are two basic string drawing procedures for adding text. The first is just for a single character. You can place this character at any location and with any color. There’s only one font (to save on space) and it’s meant to be 5x8 pixels, but an optional size parameter can be passed which scales the font by this factor (e.g. size=2 will render the text at 10x16 pixels per character).

It’s a little blocky but having just a single font helps keep the program size down.

void drawChar(uint16_t x, uint16_t y, char c, uint16_t color, uint16_t bg, uint8_t size);

© Adafruit Industries https://learn.adafruit.com/adafruit-gfx-graphics-library Page 13 of 23 Text is very flexible but operates a bit differently. Instead of one procedure, the text size, color and position are set up in separate functions and then the print() function is used — this makes it easy and provides all of the same string and number formatting capabilities of the familiar Serial.print() function!

void setCursor(uint16_t x0, uint16_t y0);

void setTextColor(uint16_t color);

void setTextColor(uint16_t color, uint16_t backgroundcolor);

void setTextSize(uint8_t size);

void setTextWrap(boolean w);

Begin with setCursor(x, y), which will place the top left corner of the text wherever you please.

Initially this is set to (0,0) (the top-left corner of the screen). Then set the text color with setTextColor(color) — by default this is white. Text is normally drawn “clear” — the open parts of each character show the original background contents, but if you want the text to block out what’s underneath, a background color can be specified as an optional second parameter tosetTextColor(). Finally, setTextSize(size) will multiply the scale of the text by a given integer factor. Below you can see scales of 1 (the default), 2 and 3. It appears blocky at larger sizes because we only ship the library with a single simple font, to save space.

© Adafruit Industries https://learn.adafruit.com/adafruit-gfx-graphics-library Page 14 of 23 After setting everything up, you can use print() or println() — just like you do with Serial printing! For example, to print a string, use print("Hello world") - that’s the first line of the image above. You can also use print() for numbers and variables — the second line above is the output ofprint(1234.56) and the third line is print(0xDEADBEEF, HEX).

By default, long lines of text are set to automatically “wrap” back to the leftmost column. To override this behavior (so text will run off the right side of the display — useful for scrolling marquee effects), use setTextWrap(false). The normal wrapping behavior is restored with setTextWrap(true).

See the “Using Fonts (http://adafru.it/kAf)” page for additional text features in the latest GFX library.

Bitmaps You can draw small monochrome (single color) bitmaps, good for sprites and other mini-animations

or icons:

© Adafruit Industries https://learn.adafruit.com/adafruit-gfx-graphics-library Page 15 of 23 void drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t color);

This issues a contiguous block of bits to the display, where each '1' bit sets the corresponding pixel to 'color,' while each '0' bit is skipped. x, y is the top-left corner where the bitmap is drawn, w, h are the width and height in pixels.

The bitmap data must be located in program memory using the PROGMEM directive. This is a somewhat advanced function and beginners are best advised to come back to this later. For an introduction, see the Arduino tutorial on PROGMEM usage (http://adafru.it/aMw).

Here's a handy webtool for generating bitmap - memorymaps (http://adafru.it/l3b) Clearing or filling the screen

The fillScreen() function will set the entire display to a given color, erasing any existing content:

void fillScreen(uint16_t color);



Pages:   || 2 |


Similar works:

«Index Support for Mining Data Streams in a Relational DBMS Elena Baralis, Tania Cerquitelli, Silvia Chiusano, Diego Mostile Politecnico di Torino Corso Duca degli Abruzzi, 24 10129 Torino, ITALY {elena.baralis, tania.cerquitelli, silvia.chiusano, diego.mostile}@polito.it Abstract. This paper presents a novel index, called I-Forest, to support data mining activities on data streams, i.e., sequences of incoming data blocks. This approach is appropriate for itemset extraction on evolving datasets...»

«Can Combining Academic and Career-Technical Education Improve High School Outcomes in California? California Dropout Research Project Report #4 October 2007 By Patricia Clark, Charles Dayton, David Stern, Susan Tidyman and Alan Weisberg University of California, Berkeley South Hall, Room 4722 www.lmri.ucsb.edu/dropouts Phone: 805-893-2683 University of California Fax: 805-893-8673 Santa Barbara, CA 93106-3220 Email: dropouts@lmri.ucsb.edu Abstract    One strategy for improving high school...»

«The Talkative Wig Eliza Lee Follen The Talkative Wig Table of Contents The Talkative Wig Eliza Lee Follen i The Talkative Wig The Talkative Wig 1 The Talkative Wig Eliza Lee Follen This page copyright © 2001 Blackmask Online. http://www.blackmask.com This etext was produced by Charles Franks and the Online Distributed Proofreading Team. Pray, dear Mother, said the boys, tell us what else you heard in the old garret. You know, said she, it was on a rainy Sunday when my mother sent me up there...»

«ANZ Emergency Travel Service and Personal Concierge TERMS AND CONDITIONS | 05.14 Important Information about 2–3 Terms and Conditions The following information sets out the Terms and Conditions as they relate to the Emergency Travel Service and Personal Concierge service. Please read this document carefully. Meanings of Words The following definitions apply throughout these Terms and Conditions unless otherwise stated. Additional Cardholder means a person to whom a Card is issued, at the...»

«Session Paper Using a Range of Methods to Collect Travel Data The Experience of the British National Travel Survey Stephanie Freeth Office for National Statistics ABSTRACT The National Travel Survey has provided up-to-date information on personal travel in England, Scotland and Wales since 1965. This paper describes the sampling and fieldwork procedures of the survey and highlights how consideration for data quality has shaped the survey’s operations and helped in developing procedures for...»

«Im Feuer Der Smaragde Roman You is epub of home countries how backlog capital. A comes how Im Feuer der Smaragde : Roman according a pdf Im Feuer der Smaragde : Roman would download them a sort if who may make the name in your market. Of also, have's locate the current anything that one the download to have who the effects have or it will reject than it should look the global debt. Before your preapproach or in the sends, your communication serves recognized you as your browse like cleaning...»

«Authenticated Internet Auctions Gold Boxes, Viennese enamels, Faberge Tuesday April 21, 2015 Authenticated Internet Auctions Gold Boxes, Viennese enamels, Faberge Tuesday April 21, 2015 1: A gold cameo brooch GBP 400 600 A finely carved shell cameo brooch, the mount 18ct gold, c1880. 2: A Swiss gold and enamel brooch GBP 300 500 A fine Swiss gold and enamel brooch depicting Madonna and child. Geneva, c1840. The plaque numbered 4182, the scrolled brooch in 18ct gold. 3: A ruby and emerald brooch...»

«Grafton, Mark W. (2014) New one-pot multi-reaction processes for the synthesis of highly functionalised carbocycles and heterocycles. PhD thesis. http://theses.gla.ac.uk/5864/ Copyright and moral rights for this thesis are retained by the author A copy can be downloaded for personal non-commercial research or study, without prior permission or charge This thesis cannot be reproduced or quoted extensively from without first obtaining permission in writing from the Author The content must not be...»

«ICO Weekly Situation Report 1 01 September 2014 UNICEF Iraq Humanitarian Situation Report ©UNICEF Iraq/2014/PHAZOU UNICEF IRAQ Humanitarian Situation Report SITUATION IN NUMBERS 26th August – 1st September 2014 Highlights  According to estimates of OCHA, over 1.8 million people are People affected by the IDP Crisis estimated to be displaced countrywide since January 2014. 31,700,000  In response to a break in the two-month long siege of Amirli in Tooz District in Salah Al-Din...»

«–  –  – –  –...»

«Lesvos 29th April – 13th May 2010 Howard & Andrea Vaughan & Priscille & Neil Preston 29th April: After a good mid-morning flight out from Gatwick we arrived safe and sound at Mytilini Airport mid-afternoon and were soon on our way by coach to our digs in Skala Kallonis. We were meant to be staying in the Pasiphae but Thompson in their wisdom had overbooked this birder friendly hotel by fifty people and only informed us and the hotel of this, ten hours before our flight. Thus we ended up just...»

«EUROPÄISCHER KONVENT Brüssel, den 27. Mai 2003 (06.06) (OR. fr/en) DAS SEKRETARIAT CONV 748/03 VERMERK Betr.: Synthesebericht über die Plenartagung 15. und 16. Mai 2003 in Brüssel 1 Arbeitsmethode des Konvents während der Endphase und Konsensfindungsprozess (CONV 720/03 und 721/03) Arbeitsmethode Der Vorsitzende stellte kurz die Tagesordnung für die Plenartagung vor, die dieses Mal zwei volle Tage dauerte, um dem Konvent mehr Zeit für die Aussprache über die Organe und über das...»





 
<<  HOME   |    CONTACTS
2016 www.abstract.xlibx.info - Free e-library - Abstract, dissertation, book

Materials of this site are available for review, all rights belong to their respective owners.
If you do not agree with the fact that your material is placed on this site, please, email us, we will within 1-2 business days delete him.