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