Testanto funções Display
Embed:
(wiki syntax)
Show/hide line numbers
ADA_GFX_kbv.h
00001 00002 // link: 00003 // https://os.mbed.com/users/davidprentice/code/Nucleo_dir_L152//file/d88d2ad55fac/ADA_GFX_kbv/ADA_GFX_kbv.h/ 00004 // Committer: davidprentice 00005 // Date: 19 months ago 00006 // 2021-04-21 00007 // 00008 // ADA_GFX_kbv.h 00009 // 00010 #ifndef _ADAFRUIT_GFX_H 00011 #define _ADAFRUIT_GFX_H 00012 00013 //#define USE_VFONTS 00014 00015 #include "Arduino.h" 00016 #define boolean bool 00017 00018 #ifndef HEX 00019 #define HEX 1 00020 #endif 00021 00022 #define swap(a, b) { int16_t t = a; a = b; b = t; } 00023 00024 class Adafruit_GFX { //: public Stream { // requires an interface 00025 00026 public: 00027 00028 Adafruit_GFX(int16_t w, int16_t h); // Constructor 00029 00030 // This MUST be defined by the subclass: 00031 virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; 00032 00033 // These MAY be overridden by the subclass to provide device-specific 00034 // optimized code. Otherwise 'generic' versions are used. 00035 virtual void 00036 drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color), 00037 drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color), 00038 drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color), 00039 drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), 00040 fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), 00041 fillScreen(uint16_t color), 00042 invertDisplay(boolean i); 00043 00044 // These exist only with Adafruit_GFX (no subclass overrides) 00045 void 00046 drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), 00047 drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, 00048 uint16_t color), 00049 fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), 00050 fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, 00051 int16_t delta, uint16_t color), 00052 drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, 00053 int16_t x2, int16_t y2, uint16_t color), 00054 fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, 00055 int16_t x2, int16_t y2, uint16_t color), 00056 drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, 00057 int16_t radius, uint16_t color), 00058 fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, 00059 int16_t radius, uint16_t color), 00060 drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, 00061 int16_t w, int16_t h, uint16_t color), 00062 drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, 00063 uint16_t bg, uint8_t size), 00064 setCursor(int16_t x, int16_t y), 00065 setTextColor(uint16_t c), 00066 setTextColor(uint16_t c, uint16_t bg), 00067 setTextSize(uint8_t s), 00068 setTextWrap(boolean w), 00069 setRotation(uint8_t r); 00070 00071 #if defined(ARDUINO) && ARDUINO < 100 00072 virtual void write(uint8_t); 00073 #else 00074 virtual size_t write(uint8_t); 00075 #endif 00076 int printf(const char* format, ...); 00077 void print(const char *s) { printf("%s", s); } 00078 void print(char *s) { printf("%s", s); } 00079 void print(char c) { printf("%c", c); } 00080 void print(int16_t v) { printf("%d", v); } 00081 void print(int32_t vl) { printf("%ld", vl); } 00082 void print(double vd, int =2) { printf("%0.2f", vd); } 00083 void println(uint8_t u, int fmt=0) { if (fmt == 0) printf("%u\n", u); else printf("%04X\n", u); } 00084 void println(uint16_t u, int fmt=0) { if (fmt == 0) printf("%u\n", u); else printf("%04X\n", u); } 00085 void println(uint32_t ul, int fmt=0) { if (fmt == 0) printf("%lu\n", ul); else printf("%04lX\n", ul); } 00086 void println(const char *s="") { printf("%s\n", s); } 00087 void println(double vd, int prec=2) { printf("%0.2f\n", vd); } 00088 00089 int16_t 00090 height(void), 00091 width(void); 00092 00093 uint8_t getRotation(void); 00094 00095 protected: 00096 const int16_t 00097 WIDTH, HEIGHT; // This is the 'raw' display w/h - never changes 00098 int16_t 00099 _width, _height, // Display w/h as modified by current rotation 00100 cursor_x, cursor_y; 00101 uint16_t 00102 textcolor, textbgcolor; 00103 uint8_t 00104 textsize, 00105 rotation; 00106 boolean 00107 wrap; // If set, 'wrap' text at right edge of display 00108 00109 #if defined USE_VFONTS 00110 public: 00111 void setFont(const PROGMEM uint8_t *ads, uint8_t mode = 0); 00112 void drawFontChar(int16_t x, int16_t y, uint8_t c, uint16_t color, uint16_t bg, uint8_t size); 00113 int8_t charWidth(uint8_t c); 00114 private: 00115 uint8_t *vfont_ads, vfont_wid, vfont_ht, vfont_ofs, vfont_siz, vfont_mode, *vfont_letter_ads; 00116 #endif 00117 00118 }; 00119 00120 #endif // _ADAFRUIT_GFX_H 00121 00122
Generated on Fri Jul 15 2022 19:32:00 by
1.7.2