Adafruit LED Matrix Display program

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Adafruit_GFX.h Source File

Adafruit_GFX.h

00001 
00002 #ifndef _ADAFRUIT_GFX_H
00003 #define _ADAFRUIT_GFX_H
00004  
00005 #include "mbed.h"
00006 //#include "Arduino.h"
00007 //#include "Print.h"
00008  
00009 #define swap(a, b) { int16_t t = a; a = b; b = t; }
00010  
00011 class Adafruit_GFX : public Print {                        // THIS LINE RIGHT HERE
00012  
00013  public:
00014  
00015   Adafruit_GFX(int16_t w, int16_t h); // Constructor
00016  
00017   // This MUST be defined by the subclass:
00018   virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
00019  
00020   // These MAY be overridden by the subclass to provide device-specific
00021   // optimized code.  Otherwise 'generic' versions are used.
00022   virtual void
00023     drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color),
00024     drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color),
00025     drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color),
00026     drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color),
00027     fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color),
00028     fillScreen(uint16_t color),
00029     invertDisplay(bool i);
00030  
00031   // These exist only with Adafruit_GFX (no subclass overrides)
00032   void
00033     drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color),
00034     drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
00035       uint16_t color),
00036     fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color),
00037     fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
00038       int16_t delta, uint16_t color),
00039     drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
00040       int16_t x2, int16_t y2, uint16_t color),
00041     fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
00042       int16_t x2, int16_t y2, uint16_t color),
00043     drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
00044       int16_t radius, uint16_t color),
00045     fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
00046       int16_t radius, uint16_t color),
00047     drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
00048       int16_t w, int16_t h, uint16_t color),
00049     drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
00050       uint16_t bg, uint8_t size),
00051     setCursor(int16_t x, int16_t y),
00052     setTextColor(uint16_t c),
00053     setTextColor(uint16_t c, uint16_t bg),
00054     setTextSize(uint8_t s),
00055     setTextWrap(bool w),
00056     setRotation(uint8_t r);
00057  
00058 #if ARDUINO >= 100
00059   virtual size_t write(uint8_t);
00060 #else
00061   virtual void   write(uint8_t);
00062 #endif
00063  
00064   int16_t
00065     height(void),
00066     width(void);
00067  
00068   uint8_t getRotation(void);
00069  
00070  protected:
00071   const int16_t
00072     WIDTH, HEIGHT;   // This is the 'raw' display w/h - never changes
00073   int16_t
00074     _width, _height, // Display w/h as modified by current rotation
00075     cursor_x, cursor_y;
00076   uint16_t
00077     textcolor, textbgcolor;
00078   uint8_t
00079     textsize,
00080     rotation;
00081   bool
00082     wrap; // If set, 'wrap' text at right edge of display
00083 };
00084