Clone of the Adafruit Graphics Library

Fork of Adafruit_GFX by justin kim

Committer:
SomeRandomBloke
Date:
Thu Aug 15 13:26:47 2013 +0000
Revision:
1:e67555532f16
Parent:
0:08cfbae05724
Child:
2:a7d4ac7ed08a
updates to latest constructor and fixed char issue

Who changed what in which revision?

UserRevisionLine numberNew contents of line
SomeRandomBloke 0:08cfbae05724 1 /******************************************************************
SomeRandomBloke 0:08cfbae05724 2 This is the core graphics library for all our displays, providing
SomeRandomBloke 0:08cfbae05724 3 basic graphics primitives (points, lines, circles, etc.). It needs
SomeRandomBloke 0:08cfbae05724 4 to be paired with a hardware-specific library for each display
SomeRandomBloke 0:08cfbae05724 5 device we carry (handling the lower-level functions).
SomeRandomBloke 0:08cfbae05724 6
SomeRandomBloke 0:08cfbae05724 7 Adafruit invests time and resources providing this open
SomeRandomBloke 0:08cfbae05724 8 source code, please support Adafruit and open-source hardware
SomeRandomBloke 0:08cfbae05724 9 by purchasing products from Adafruit!
SomeRandomBloke 0:08cfbae05724 10
SomeRandomBloke 0:08cfbae05724 11 Written by Limor Fried/Ladyada for Adafruit Industries.
SomeRandomBloke 0:08cfbae05724 12 BSD license, check license.txt for more information.
SomeRandomBloke 0:08cfbae05724 13 All text above must be included in any redistribution.
SomeRandomBloke 0:08cfbae05724 14 ******************************************************************/
SomeRandomBloke 0:08cfbae05724 15
SomeRandomBloke 0:08cfbae05724 16 #ifndef _ADAFRUIT_GFX_H
SomeRandomBloke 0:08cfbae05724 17 #define _ADAFRUIT_GFX_H
SomeRandomBloke 0:08cfbae05724 18
SomeRandomBloke 0:08cfbae05724 19 #include "mbed.h"
SomeRandomBloke 0:08cfbae05724 20 #include "Stream.h"
SomeRandomBloke 0:08cfbae05724 21
SomeRandomBloke 0:08cfbae05724 22
SomeRandomBloke 0:08cfbae05724 23 #define swap(a, b) { int16_t t = a; a = b; b = t; }
SomeRandomBloke 0:08cfbae05724 24 #define boolean bool
SomeRandomBloke 0:08cfbae05724 25
SomeRandomBloke 1:e67555532f16 26 class Adafruit_GFX : public Stream
SomeRandomBloke 0:08cfbae05724 27 {
SomeRandomBloke 0:08cfbae05724 28 public:
SomeRandomBloke 0:08cfbae05724 29
SomeRandomBloke 0:08cfbae05724 30 //Adafruit_GFX();
SomeRandomBloke 1:e67555532f16 31 Adafruit_GFX(int16_t w, int16_t h); // Constructor
SomeRandomBloke 0:08cfbae05724 32 // i have no idea why we have to formally call the constructor. kinda sux
SomeRandomBloke 1:e67555532f16 33 //void constructor(int16_t w, int16_t h);
SomeRandomBloke 0:08cfbae05724 34
SomeRandomBloke 0:08cfbae05724 35 virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
SomeRandomBloke 0:08cfbae05724 36 virtual void invertDisplay(boolean i);
SomeRandomBloke 0:08cfbae05724 37
SomeRandomBloke 0:08cfbae05724 38 // these are 'generic' drawing functions, so we can share them!
SomeRandomBloke 0:08cfbae05724 39 void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,uint16_t color);
SomeRandomBloke 0:08cfbae05724 40 virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
SomeRandomBloke 0:08cfbae05724 41 virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
SomeRandomBloke 0:08cfbae05724 42 virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
SomeRandomBloke 0:08cfbae05724 43 virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
SomeRandomBloke 0:08cfbae05724 44 virtual void fillScreen(uint16_t color);
SomeRandomBloke 0:08cfbae05724 45
SomeRandomBloke 0:08cfbae05724 46 void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
SomeRandomBloke 0:08cfbae05724 47 void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color);
SomeRandomBloke 0:08cfbae05724 48 void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
SomeRandomBloke 0:08cfbae05724 49 void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color);
SomeRandomBloke 0:08cfbae05724 50
SomeRandomBloke 0:08cfbae05724 51 void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,int16_t x2, int16_t y2, uint16_t color);
SomeRandomBloke 0:08cfbae05724 52 void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
SomeRandomBloke 0:08cfbae05724 53 void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
SomeRandomBloke 0:08cfbae05724 54 void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
SomeRandomBloke 0:08cfbae05724 55
SomeRandomBloke 0:08cfbae05724 56 void drawBitmap(int16_t x, int16_t y,
SomeRandomBloke 0:08cfbae05724 57 const uint8_t *bitmap, int16_t w, int16_t h,
SomeRandomBloke 0:08cfbae05724 58 uint16_t color);
SomeRandomBloke 0:08cfbae05724 59 void drawChar(int16_t x, int16_t y, unsigned char c,
SomeRandomBloke 0:08cfbae05724 60 uint16_t color, uint16_t bg, uint8_t size);
SomeRandomBloke 0:08cfbae05724 61
SomeRandomBloke 0:08cfbae05724 62 void setCursor(int16_t x, int16_t y);
SomeRandomBloke 0:08cfbae05724 63 void setTextColor(uint16_t c);
SomeRandomBloke 0:08cfbae05724 64 void setTextColor(uint16_t c, uint16_t bg);
SomeRandomBloke 0:08cfbae05724 65 void setTextSize(uint8_t s);
SomeRandomBloke 0:08cfbae05724 66 void setTextWrap(boolean w);
SomeRandomBloke 0:08cfbae05724 67
SomeRandomBloke 0:08cfbae05724 68 int16_t height(void);
SomeRandomBloke 0:08cfbae05724 69 int16_t width(void);
SomeRandomBloke 0:08cfbae05724 70
SomeRandomBloke 0:08cfbae05724 71 void setRotation(uint8_t r);
SomeRandomBloke 0:08cfbae05724 72 uint8_t getRotation(void);
SomeRandomBloke 0:08cfbae05724 73
SomeRandomBloke 0:08cfbae05724 74 protected:
SomeRandomBloke 0:08cfbae05724 75 virtual int _putc(int value);
SomeRandomBloke 0:08cfbae05724 76 virtual int _getc();
SomeRandomBloke 0:08cfbae05724 77
SomeRandomBloke 1:e67555532f16 78 const int16_t WIDTH, HEIGHT; // this is the 'raw' display w/h - never changes
SomeRandomBloke 0:08cfbae05724 79 int16_t _width, _height; // dependent on rotation
SomeRandomBloke 0:08cfbae05724 80 int16_t cursor_x, cursor_y;
SomeRandomBloke 0:08cfbae05724 81 uint16_t textcolor, textbgcolor;
SomeRandomBloke 0:08cfbae05724 82 uint8_t textsize;
SomeRandomBloke 0:08cfbae05724 83 uint8_t rotation;
SomeRandomBloke 0:08cfbae05724 84 boolean wrap; // If set, 'wrap' text at right edge of display
SomeRandomBloke 0:08cfbae05724 85 };
SomeRandomBloke 0:08cfbae05724 86
SomeRandomBloke 0:08cfbae05724 87 #endif