A library with drivers for different peripherals on the LPC4088 QuickStart Board or related add-on boards.
Fork of EALib by
GFXFb.h@0:0fdadbc3d852, 2013-09-26 (annotated)
- Committer:
- embeddedartists
- Date:
- Thu Sep 26 06:37:02 2013 +0000
- Revision:
- 0:0fdadbc3d852
- Child:
- 12:15597e45eea0
First version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:0fdadbc3d852 | 1 | |
embeddedartists | 0:0fdadbc3d852 | 2 | #ifndef GFXFB_H |
embeddedartists | 0:0fdadbc3d852 | 3 | #define GFXFB_H |
embeddedartists | 0:0fdadbc3d852 | 4 | |
embeddedartists | 0:0fdadbc3d852 | 5 | #include "Adafruit_GFX.h" |
embeddedartists | 0:0fdadbc3d852 | 6 | |
embeddedartists | 0:0fdadbc3d852 | 7 | #define BLACK 0x0000 |
embeddedartists | 0:0fdadbc3d852 | 8 | /* Light gray color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 9 | #define LIGHTGRAY 0X7BEF |
embeddedartists | 0:0fdadbc3d852 | 10 | /* Dark gray color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 11 | #define DARKGRAY 0x39E7 |
embeddedartists | 0:0fdadbc3d852 | 12 | /* White color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 13 | #define WHITE 0xffff |
embeddedartists | 0:0fdadbc3d852 | 14 | /* Red color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 15 | #define RED 0xF800 |
embeddedartists | 0:0fdadbc3d852 | 16 | /* Green color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 17 | #define GREEN 0x07E0 |
embeddedartists | 0:0fdadbc3d852 | 18 | /* Blue color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 19 | #define BLUE 0x001F |
embeddedartists | 0:0fdadbc3d852 | 20 | /* Magenta color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 21 | #define MAGENTA (RED | BLUE) |
embeddedartists | 0:0fdadbc3d852 | 22 | /* Cyan color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 23 | #define CYAN (GREEN | BLUE) |
embeddedartists | 0:0fdadbc3d852 | 24 | /* Yellow color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 25 | #define YELLOW (RED | GREEN) |
embeddedartists | 0:0fdadbc3d852 | 26 | /* Light red color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 27 | #define LIGHTRED 0x7800 |
embeddedartists | 0:0fdadbc3d852 | 28 | /* Light green color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 29 | #define LIGHTGREEN 0x03E0 |
embeddedartists | 0:0fdadbc3d852 | 30 | /* Light blue color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 31 | #define LIGHTBLUE 0x000F |
embeddedartists | 0:0fdadbc3d852 | 32 | /* Light magenta color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 33 | #define LIGHTMAGENTA (LIGHTRED | LIGHTBLUE) |
embeddedartists | 0:0fdadbc3d852 | 34 | /* Light cyan color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 35 | #define LIGHTCYAN (LIGHTGREEN | LIGHTBLUE) |
embeddedartists | 0:0fdadbc3d852 | 36 | /* Light yellow color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 37 | #define LIGHTYELLOW (LIGHTRED | LIGHTGREEN) |
embeddedartists | 0:0fdadbc3d852 | 38 | |
embeddedartists | 0:0fdadbc3d852 | 39 | /** |
embeddedartists | 0:0fdadbc3d852 | 40 | * Graphical library based on Adafruit's GFX using a Frame buffer. |
embeddedartists | 0:0fdadbc3d852 | 41 | */ |
embeddedartists | 0:0fdadbc3d852 | 42 | class GFXFb : public Adafruit_GFX { |
embeddedartists | 0:0fdadbc3d852 | 43 | public: |
embeddedartists | 0:0fdadbc3d852 | 44 | |
embeddedartists | 0:0fdadbc3d852 | 45 | /** Create an interface to the GFX graphical library |
embeddedartists | 0:0fdadbc3d852 | 46 | * |
embeddedartists | 0:0fdadbc3d852 | 47 | * @param w width of the display |
embeddedartists | 0:0fdadbc3d852 | 48 | * @param h height of the display |
embeddedartists | 0:0fdadbc3d852 | 49 | * @param fb frame buffer that will be used by the graphical library. Can |
embeddedartists | 0:0fdadbc3d852 | 50 | * be set by calling setFb instead. |
embeddedartists | 0:0fdadbc3d852 | 51 | */ |
embeddedartists | 0:0fdadbc3d852 | 52 | GFXFb(uint16_t w, uint16_t h, uint16_t* fb = 0); |
embeddedartists | 0:0fdadbc3d852 | 53 | |
embeddedartists | 0:0fdadbc3d852 | 54 | virtual void drawPixel(int16_t x, int16_t y, uint16_t color); |
embeddedartists | 0:0fdadbc3d852 | 55 | virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); |
embeddedartists | 0:0fdadbc3d852 | 56 | virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); |
embeddedartists | 0:0fdadbc3d852 | 57 | virtual void fillScreen(uint16_t color); |
embeddedartists | 0:0fdadbc3d852 | 58 | |
embeddedartists | 0:0fdadbc3d852 | 59 | /** Associate a frame buffer with the graphical library. |
embeddedartists | 0:0fdadbc3d852 | 60 | * All drawing requests will be performed on the frame buffer. |
embeddedartists | 0:0fdadbc3d852 | 61 | * |
embeddedartists | 0:0fdadbc3d852 | 62 | * @param fb frame buffer that will be used by the graphical library |
embeddedartists | 0:0fdadbc3d852 | 63 | */ |
embeddedartists | 0:0fdadbc3d852 | 64 | void setFb(uint16_t* fb) {_fb = fb;} |
embeddedartists | 0:0fdadbc3d852 | 65 | |
embeddedartists | 0:0fdadbc3d852 | 66 | /** Get the frame buffer associated with the graphical library. |
embeddedartists | 0:0fdadbc3d852 | 67 | * |
embeddedartists | 0:0fdadbc3d852 | 68 | * @returns the frame buffer associated with the graphical library. |
embeddedartists | 0:0fdadbc3d852 | 69 | */ |
embeddedartists | 0:0fdadbc3d852 | 70 | uint16_t* getFb() {return _fb;} |
embeddedartists | 0:0fdadbc3d852 | 71 | |
embeddedartists | 0:0fdadbc3d852 | 72 | /** Write a null-terminated string |
embeddedartists | 0:0fdadbc3d852 | 73 | * |
embeddedartists | 0:0fdadbc3d852 | 74 | * @param s the string to write on the display |
embeddedartists | 0:0fdadbc3d852 | 75 | */ |
embeddedartists | 0:0fdadbc3d852 | 76 | void writeString(const char* s); |
embeddedartists | 0:0fdadbc3d852 | 77 | |
embeddedartists | 0:0fdadbc3d852 | 78 | /** Get the width in pixels of the given string. |
embeddedartists | 0:0fdadbc3d852 | 79 | * |
embeddedartists | 0:0fdadbc3d852 | 80 | * @param s width will be calculated on this string |
embeddedartists | 0:0fdadbc3d852 | 81 | * @returns the width in pixels of the string |
embeddedartists | 0:0fdadbc3d852 | 82 | */ |
embeddedartists | 0:0fdadbc3d852 | 83 | int16_t getStringWidth(const char* s); |
embeddedartists | 0:0fdadbc3d852 | 84 | |
embeddedartists | 0:0fdadbc3d852 | 85 | /** Get the height in pixels of the given string. |
embeddedartists | 0:0fdadbc3d852 | 86 | * |
embeddedartists | 0:0fdadbc3d852 | 87 | * @param s height will be calculated on this string |
embeddedartists | 0:0fdadbc3d852 | 88 | * @returns the height in pixels of the string |
embeddedartists | 0:0fdadbc3d852 | 89 | */ |
embeddedartists | 0:0fdadbc3d852 | 90 | int16_t getStringHeight(const char* s); |
embeddedartists | 0:0fdadbc3d852 | 91 | |
embeddedartists | 0:0fdadbc3d852 | 92 | |
embeddedartists | 0:0fdadbc3d852 | 93 | private: |
embeddedartists | 0:0fdadbc3d852 | 94 | |
embeddedartists | 0:0fdadbc3d852 | 95 | uint16_t* _fb; |
embeddedartists | 0:0fdadbc3d852 | 96 | }; |
embeddedartists | 0:0fdadbc3d852 | 97 | |
embeddedartists | 0:0fdadbc3d852 | 98 | #endif |
embeddedartists | 0:0fdadbc3d852 | 99 | |
embeddedartists | 0:0fdadbc3d852 | 100 |