A library with drivers for different peripherals on the LPC4088 QuickStart Board or related add-on boards.
Dependents: LPC4088test LPC4088test_ledonly LPC4088test_deleteall LPC4088_RAMtest ... more
GFXFb.h@20:e1e36493f347, 2015-06-10 (annotated)
- Committer:
- embeddedartists
- Date:
- Wed Jun 10 08:34:09 2015 +0000
- Revision:
- 20:e1e36493f347
- Parent:
- 12:15597e45eea0
Fixed compiler error in MCIFileSystem regarding us_ticker_api.h
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 12:15597e45eea0 | 1 | /* |
embeddedartists | 12:15597e45eea0 | 2 | * Copyright 2013 Embedded Artists AB |
embeddedartists | 12:15597e45eea0 | 3 | * |
embeddedartists | 12:15597e45eea0 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
embeddedartists | 12:15597e45eea0 | 5 | * you may not use this file except in compliance with the License. |
embeddedartists | 12:15597e45eea0 | 6 | * You may obtain a copy of the License at |
embeddedartists | 12:15597e45eea0 | 7 | * |
embeddedartists | 12:15597e45eea0 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
embeddedartists | 12:15597e45eea0 | 9 | * |
embeddedartists | 12:15597e45eea0 | 10 | * Unless required by applicable law or agreed to in writing, software |
embeddedartists | 12:15597e45eea0 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
embeddedartists | 12:15597e45eea0 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
embeddedartists | 12:15597e45eea0 | 13 | * See the License for the specific language governing permissions and |
embeddedartists | 12:15597e45eea0 | 14 | * limitations under the License. |
embeddedartists | 12:15597e45eea0 | 15 | */ |
embeddedartists | 0:0fdadbc3d852 | 16 | |
embeddedartists | 0:0fdadbc3d852 | 17 | #ifndef GFXFB_H |
embeddedartists | 0:0fdadbc3d852 | 18 | #define GFXFB_H |
embeddedartists | 0:0fdadbc3d852 | 19 | |
embeddedartists | 0:0fdadbc3d852 | 20 | #include "Adafruit_GFX.h" |
embeddedartists | 0:0fdadbc3d852 | 21 | |
embeddedartists | 0:0fdadbc3d852 | 22 | #define BLACK 0x0000 |
embeddedartists | 0:0fdadbc3d852 | 23 | /* Light gray color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 24 | #define LIGHTGRAY 0X7BEF |
embeddedartists | 0:0fdadbc3d852 | 25 | /* Dark gray color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 26 | #define DARKGRAY 0x39E7 |
embeddedartists | 0:0fdadbc3d852 | 27 | /* White color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 28 | #define WHITE 0xffff |
embeddedartists | 0:0fdadbc3d852 | 29 | /* Red color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 30 | #define RED 0xF800 |
embeddedartists | 0:0fdadbc3d852 | 31 | /* Green color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 32 | #define GREEN 0x07E0 |
embeddedartists | 0:0fdadbc3d852 | 33 | /* Blue color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 34 | #define BLUE 0x001F |
embeddedartists | 0:0fdadbc3d852 | 35 | /* Magenta color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 36 | #define MAGENTA (RED | BLUE) |
embeddedartists | 0:0fdadbc3d852 | 37 | /* Cyan color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 38 | #define CYAN (GREEN | BLUE) |
embeddedartists | 0:0fdadbc3d852 | 39 | /* Yellow color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 40 | #define YELLOW (RED | GREEN) |
embeddedartists | 0:0fdadbc3d852 | 41 | /* Light red color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 42 | #define LIGHTRED 0x7800 |
embeddedartists | 0:0fdadbc3d852 | 43 | /* Light green color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 44 | #define LIGHTGREEN 0x03E0 |
embeddedartists | 0:0fdadbc3d852 | 45 | /* Light blue color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 46 | #define LIGHTBLUE 0x000F |
embeddedartists | 0:0fdadbc3d852 | 47 | /* Light magenta color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 48 | #define LIGHTMAGENTA (LIGHTRED | LIGHTBLUE) |
embeddedartists | 0:0fdadbc3d852 | 49 | /* Light cyan color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 50 | #define LIGHTCYAN (LIGHTGREEN | LIGHTBLUE) |
embeddedartists | 0:0fdadbc3d852 | 51 | /* Light yellow color, 565 mode */ |
embeddedartists | 0:0fdadbc3d852 | 52 | #define LIGHTYELLOW (LIGHTRED | LIGHTGREEN) |
embeddedartists | 0:0fdadbc3d852 | 53 | |
embeddedartists | 0:0fdadbc3d852 | 54 | /** |
embeddedartists | 0:0fdadbc3d852 | 55 | * Graphical library based on Adafruit's GFX using a Frame buffer. |
embeddedartists | 0:0fdadbc3d852 | 56 | */ |
embeddedartists | 0:0fdadbc3d852 | 57 | class GFXFb : public Adafruit_GFX { |
embeddedartists | 0:0fdadbc3d852 | 58 | public: |
embeddedartists | 0:0fdadbc3d852 | 59 | |
embeddedartists | 0:0fdadbc3d852 | 60 | /** Create an interface to the GFX graphical library |
embeddedartists | 0:0fdadbc3d852 | 61 | * |
embeddedartists | 0:0fdadbc3d852 | 62 | * @param w width of the display |
embeddedartists | 0:0fdadbc3d852 | 63 | * @param h height of the display |
embeddedartists | 0:0fdadbc3d852 | 64 | * @param fb frame buffer that will be used by the graphical library. Can |
embeddedartists | 0:0fdadbc3d852 | 65 | * be set by calling setFb instead. |
embeddedartists | 0:0fdadbc3d852 | 66 | */ |
embeddedartists | 0:0fdadbc3d852 | 67 | GFXFb(uint16_t w, uint16_t h, uint16_t* fb = 0); |
embeddedartists | 0:0fdadbc3d852 | 68 | |
embeddedartists | 0:0fdadbc3d852 | 69 | virtual void drawPixel(int16_t x, int16_t y, uint16_t color); |
embeddedartists | 0:0fdadbc3d852 | 70 | virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); |
embeddedartists | 0:0fdadbc3d852 | 71 | virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); |
embeddedartists | 0:0fdadbc3d852 | 72 | virtual void fillScreen(uint16_t color); |
embeddedartists | 0:0fdadbc3d852 | 73 | |
embeddedartists | 0:0fdadbc3d852 | 74 | /** Associate a frame buffer with the graphical library. |
embeddedartists | 0:0fdadbc3d852 | 75 | * All drawing requests will be performed on the frame buffer. |
embeddedartists | 0:0fdadbc3d852 | 76 | * |
embeddedartists | 0:0fdadbc3d852 | 77 | * @param fb frame buffer that will be used by the graphical library |
embeddedartists | 0:0fdadbc3d852 | 78 | */ |
embeddedartists | 0:0fdadbc3d852 | 79 | void setFb(uint16_t* fb) {_fb = fb;} |
embeddedartists | 0:0fdadbc3d852 | 80 | |
embeddedartists | 0:0fdadbc3d852 | 81 | /** Get the frame buffer associated with the graphical library. |
embeddedartists | 0:0fdadbc3d852 | 82 | * |
embeddedartists | 0:0fdadbc3d852 | 83 | * @returns the frame buffer associated with the graphical library. |
embeddedartists | 0:0fdadbc3d852 | 84 | */ |
embeddedartists | 0:0fdadbc3d852 | 85 | uint16_t* getFb() {return _fb;} |
embeddedartists | 0:0fdadbc3d852 | 86 | |
embeddedartists | 0:0fdadbc3d852 | 87 | /** Write a null-terminated string |
embeddedartists | 0:0fdadbc3d852 | 88 | * |
embeddedartists | 0:0fdadbc3d852 | 89 | * @param s the string to write on the display |
embeddedartists | 0:0fdadbc3d852 | 90 | */ |
embeddedartists | 0:0fdadbc3d852 | 91 | void writeString(const char* s); |
embeddedartists | 0:0fdadbc3d852 | 92 | |
embeddedartists | 0:0fdadbc3d852 | 93 | /** Get the width in pixels of the given string. |
embeddedartists | 0:0fdadbc3d852 | 94 | * |
embeddedartists | 0:0fdadbc3d852 | 95 | * @param s width will be calculated on this string |
embeddedartists | 0:0fdadbc3d852 | 96 | * @returns the width in pixels of the string |
embeddedartists | 0:0fdadbc3d852 | 97 | */ |
embeddedartists | 0:0fdadbc3d852 | 98 | int16_t getStringWidth(const char* s); |
embeddedartists | 0:0fdadbc3d852 | 99 | |
embeddedartists | 0:0fdadbc3d852 | 100 | /** Get the height in pixels of the given string. |
embeddedartists | 0:0fdadbc3d852 | 101 | * |
embeddedartists | 0:0fdadbc3d852 | 102 | * @param s height will be calculated on this string |
embeddedartists | 0:0fdadbc3d852 | 103 | * @returns the height in pixels of the string |
embeddedartists | 0:0fdadbc3d852 | 104 | */ |
embeddedartists | 0:0fdadbc3d852 | 105 | int16_t getStringHeight(const char* s); |
embeddedartists | 0:0fdadbc3d852 | 106 | |
embeddedartists | 0:0fdadbc3d852 | 107 | |
embeddedartists | 0:0fdadbc3d852 | 108 | private: |
embeddedartists | 0:0fdadbc3d852 | 109 | |
embeddedartists | 0:0fdadbc3d852 | 110 | uint16_t* _fb; |
embeddedartists | 0:0fdadbc3d852 | 111 | }; |
embeddedartists | 0:0fdadbc3d852 | 112 | |
embeddedartists | 0:0fdadbc3d852 | 113 | #endif |
embeddedartists | 0:0fdadbc3d852 | 114 | |
embeddedartists | 0:0fdadbc3d852 | 115 |