Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Adafruit_GFX by
Adafruit_GFX.h
00001 /****************************************************************** 00002 This is the core graphics library for all our displays, providing 00003 basic graphics primitives (points, lines, circles, etc.). It needs 00004 to be paired with a hardware-specific library for each display 00005 device we carry (handling the lower-level functions). 00006 00007 Adafruit invests time and resources providing this open 00008 source code, please support Adafruit and open-source hardware 00009 by purchasing products from Adafruit! 00010 00011 Written by Limor Fried/Ladyada for Adafruit Industries. 00012 BSD license, check license.txt for more information. 00013 All text above must be included in any redistribution. 00014 ******************************************************************/ 00015 00016 #ifndef _ADAFRUIT_GFX_H 00017 #define _ADAFRUIT_GFX_H 00018 00019 #include "mbed.h" 00020 #include "Stream.h" 00021 00022 00023 #define swap(a, b) { int16_t t = a; a = b; b = t; } 00024 #define boolean bool 00025 00026 class Adafruit_GFX : public Stream 00027 { 00028 public: 00029 00030 //Adafruit_GFX(); 00031 Adafruit_GFX(int16_t w, int16_t h); // Constructor 00032 // i have no idea why we have to formally call the constructor. kinda sux 00033 //void constructor(int16_t w, int16_t h); 00034 00035 virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; 00036 virtual void invertDisplay(boolean i); 00037 00038 // these are 'generic' drawing functions, so we can share them! 00039 void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,uint16_t color); 00040 virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); 00041 virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); 00042 virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 00043 virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 00044 virtual void fillScreen(uint16_t color); 00045 00046 void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); 00047 void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color); 00048 void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); 00049 void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color); 00050 00051 void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,int16_t x2, int16_t y2, uint16_t color); 00052 void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); 00053 void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); 00054 void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); 00055 00056 void drawBitmap(int16_t x, int16_t y, 00057 const uint8_t *bitmap, int16_t w, int16_t h, 00058 uint16_t color); 00059 void drawChar(int16_t x, int16_t y, unsigned char c, 00060 uint16_t color, uint16_t bg, uint8_t size); 00061 00062 void setCursor(int16_t x, int16_t y); 00063 void setTextColor(uint16_t c); 00064 void setTextColor(uint16_t c, uint16_t bg); 00065 void setTextSize(uint8_t s); 00066 void setTextWrap(boolean w); 00067 00068 int16_t height(void); 00069 int16_t width(void); 00070 00071 void setRotation(uint8_t r); 00072 uint8_t getRotation(void); 00073 00074 protected: 00075 virtual int _putc(int value); 00076 virtual int _getc(); 00077 00078 const int16_t WIDTH, HEIGHT; // this is the 'raw' display w/h - never changes 00079 int16_t _width, _height; // dependent on rotation 00080 int16_t cursor_x, cursor_y; 00081 uint16_t textcolor, textbgcolor; 00082 uint8_t textsize; 00083 uint8_t rotation; 00084 boolean wrap; // If set, 'wrap' text at right edge of display 00085 }; 00086 00087 #endif
Generated on Tue Jul 12 2022 20:45:22 by
1.7.2
