modify

Dependents:   ThingPlug_Ethernet_Example_temp_V2

Fork of Adafruit_GFX by justin kim

Committer:
irinakim
Date:
Sat Aug 15 23:25:09 2015 +0000
Revision:
5:d533c761006e
Parent:
4:256d9b541ab0
l;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
SomeRandomBloke 2:a7d4ac7ed08a 1 /*
SomeRandomBloke 2:a7d4ac7ed08a 2 This is the core graphics library for all our displays, providing a common
SomeRandomBloke 2:a7d4ac7ed08a 3 set of graphics primitives (points, lines, circles, etc.). It needs to be
SomeRandomBloke 2:a7d4ac7ed08a 4 paired with a hardware-specific library for each display device we carry
SomeRandomBloke 2:a7d4ac7ed08a 5 (to handle the lower-level functions).
SomeRandomBloke 2:a7d4ac7ed08a 6
SomeRandomBloke 2:a7d4ac7ed08a 7 Adafruit invests time and resources providing this open source code, please
SomeRandomBloke 2:a7d4ac7ed08a 8 support Adafruit & open-source hardware by purchasing products from Adafruit!
SomeRandomBloke 2:a7d4ac7ed08a 9
SomeRandomBloke 2:a7d4ac7ed08a 10 Copyright (c) 2013 Adafruit Industries. All rights reserved.
SomeRandomBloke 2:a7d4ac7ed08a 11
SomeRandomBloke 2:a7d4ac7ed08a 12 Redistribution and use in source and binary forms, with or without
SomeRandomBloke 2:a7d4ac7ed08a 13 modification, are permitted provided that the following conditions are met:
SomeRandomBloke 0:08cfbae05724 14
SomeRandomBloke 2:a7d4ac7ed08a 15 - Redistributions of source code must retain the above copyright notice,
SomeRandomBloke 2:a7d4ac7ed08a 16 this list of conditions and the following disclaimer.
SomeRandomBloke 2:a7d4ac7ed08a 17 - Redistributions in binary form must reproduce the above copyright notice,
SomeRandomBloke 2:a7d4ac7ed08a 18 this list of conditions and the following disclaimer in the documentation
SomeRandomBloke 2:a7d4ac7ed08a 19 and/or other materials provided with the distribution.
SomeRandomBloke 0:08cfbae05724 20
SomeRandomBloke 2:a7d4ac7ed08a 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
SomeRandomBloke 2:a7d4ac7ed08a 22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
SomeRandomBloke 2:a7d4ac7ed08a 23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
SomeRandomBloke 2:a7d4ac7ed08a 24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
SomeRandomBloke 2:a7d4ac7ed08a 25 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
SomeRandomBloke 2:a7d4ac7ed08a 26 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SomeRandomBloke 2:a7d4ac7ed08a 27 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
SomeRandomBloke 2:a7d4ac7ed08a 28 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
SomeRandomBloke 2:a7d4ac7ed08a 29 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
SomeRandomBloke 2:a7d4ac7ed08a 30 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
SomeRandomBloke 2:a7d4ac7ed08a 31 POSSIBILITY OF SUCH DAMAGE.
SomeRandomBloke 2:a7d4ac7ed08a 32 */
SomeRandomBloke 0:08cfbae05724 33
SomeRandomBloke 0:08cfbae05724 34 #ifndef _ADAFRUIT_GFX_H
SomeRandomBloke 0:08cfbae05724 35 #define _ADAFRUIT_GFX_H
SomeRandomBloke 0:08cfbae05724 36
SomeRandomBloke 0:08cfbae05724 37 #include "mbed.h"
SomeRandomBloke 0:08cfbae05724 38 #include "Stream.h"
SomeRandomBloke 0:08cfbae05724 39
SomeRandomBloke 0:08cfbae05724 40
SomeRandomBloke 0:08cfbae05724 41 #define swap(a, b) { int16_t t = a; a = b; b = t; }
SomeRandomBloke 0:08cfbae05724 42 #define boolean bool
irinakim 5:d533c761006e 43 struct LocateDef
irinakim 5:d533c761006e 44 {
irinakim 5:d533c761006e 45 uint16_t x_data;
irinakim 5:d533c761006e 46 uint16_t y_data;
irinakim 5:d533c761006e 47 };
SomeRandomBloke 0:08cfbae05724 48
SomeRandomBloke 1:e67555532f16 49 class Adafruit_GFX : public Stream
SomeRandomBloke 0:08cfbae05724 50 {
SomeRandomBloke 0:08cfbae05724 51 public:
SomeRandomBloke 0:08cfbae05724 52
SomeRandomBloke 0:08cfbae05724 53 //Adafruit_GFX();
SomeRandomBloke 1:e67555532f16 54 Adafruit_GFX(int16_t w, int16_t h); // Constructor
SomeRandomBloke 0:08cfbae05724 55 // i have no idea why we have to formally call the constructor. kinda sux
SomeRandomBloke 1:e67555532f16 56 //void constructor(int16_t w, int16_t h);
SomeRandomBloke 0:08cfbae05724 57
SomeRandomBloke 0:08cfbae05724 58 virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
justinkim 3:04b9498d00d8 59 void invertDisplay(boolean i);
SomeRandomBloke 0:08cfbae05724 60
SomeRandomBloke 0:08cfbae05724 61 // these are 'generic' drawing functions, so we can share them!
justinkim 3:04b9498d00d8 62 virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,uint16_t color);
SomeRandomBloke 0:08cfbae05724 63 virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
SomeRandomBloke 0:08cfbae05724 64 virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
SomeRandomBloke 0:08cfbae05724 65 virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
SomeRandomBloke 0:08cfbae05724 66 virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
SomeRandomBloke 0:08cfbae05724 67 virtual void fillScreen(uint16_t color);
justinkim 3:04b9498d00d8 68
SomeRandomBloke 0:08cfbae05724 69 void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
SomeRandomBloke 0:08cfbae05724 70 void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color);
SomeRandomBloke 0:08cfbae05724 71 void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
SomeRandomBloke 0:08cfbae05724 72 void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color);
SomeRandomBloke 0:08cfbae05724 73
SomeRandomBloke 0:08cfbae05724 74 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 75 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 76 void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
SomeRandomBloke 0:08cfbae05724 77 void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
SomeRandomBloke 0:08cfbae05724 78
SomeRandomBloke 0:08cfbae05724 79 void drawBitmap(int16_t x, int16_t y,
SomeRandomBloke 0:08cfbae05724 80 const uint8_t *bitmap, int16_t w, int16_t h,
SomeRandomBloke 0:08cfbae05724 81 uint16_t color);
SomeRandomBloke 0:08cfbae05724 82 void drawChar(int16_t x, int16_t y, unsigned char c,
SomeRandomBloke 0:08cfbae05724 83 uint16_t color, uint16_t bg, uint8_t size);
SomeRandomBloke 0:08cfbae05724 84
SomeRandomBloke 0:08cfbae05724 85 void setCursor(int16_t x, int16_t y);
SomeRandomBloke 0:08cfbae05724 86 void setTextColor(uint16_t c);
SomeRandomBloke 0:08cfbae05724 87 void setTextColor(uint16_t c, uint16_t bg);
irinakim 5:d533c761006e 88 void getCursor(LocateDef* LOC);
SomeRandomBloke 0:08cfbae05724 89 void setTextSize(uint8_t s);
SomeRandomBloke 0:08cfbae05724 90 void setTextWrap(boolean w);
SomeRandomBloke 0:08cfbae05724 91
SomeRandomBloke 0:08cfbae05724 92 int16_t height(void);
SomeRandomBloke 0:08cfbae05724 93 int16_t width(void);
SomeRandomBloke 0:08cfbae05724 94
SomeRandomBloke 0:08cfbae05724 95 void setRotation(uint8_t r);
SomeRandomBloke 0:08cfbae05724 96 uint8_t getRotation(void);
SomeRandomBloke 0:08cfbae05724 97
SomeRandomBloke 0:08cfbae05724 98 protected:
SomeRandomBloke 0:08cfbae05724 99 virtual int _putc(int value);
SomeRandomBloke 0:08cfbae05724 100 virtual int _getc();
SomeRandomBloke 0:08cfbae05724 101
SomeRandomBloke 1:e67555532f16 102 const int16_t WIDTH, HEIGHT; // this is the 'raw' display w/h - never changes
SomeRandomBloke 0:08cfbae05724 103 int16_t _width, _height; // dependent on rotation
SomeRandomBloke 0:08cfbae05724 104 int16_t cursor_x, cursor_y;
SomeRandomBloke 0:08cfbae05724 105 uint16_t textcolor, textbgcolor;
SomeRandomBloke 0:08cfbae05724 106 uint8_t textsize;
SomeRandomBloke 0:08cfbae05724 107 uint8_t rotation;
SomeRandomBloke 0:08cfbae05724 108 boolean wrap; // If set, 'wrap' text at right edge of display
SomeRandomBloke 0:08cfbae05724 109 };
SomeRandomBloke 0:08cfbae05724 110
irinakim 5:d533c761006e 111
SomeRandomBloke 0:08cfbae05724 112 #endif
justinkim 4:256d9b541ab0 113