A library with drivers for different peripherals on the LPC4088 QuickStart Board or related add-on boards.

Dependencies:   FATFileSystem

Dependents:   LPC4088test LPC4088test_ledonly LPC4088test_deleteall LPC4088_RAMtest ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GFXFb.h Source File

GFXFb.h

00001 /*
00002  *  Copyright 2013 Embedded Artists AB
00003  *
00004  *  Licensed under the Apache License, Version 2.0 (the "License");
00005  *  you may not use this file except in compliance with the License.
00006  *  You may obtain a copy of the License at
00007  *
00008  *    http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  *  Unless required by applicable law or agreed to in writing, software
00011  *  distributed under the License is distributed on an "AS IS" BASIS,
00012  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *  See the License for the specific language governing permissions and
00014  *  limitations under the License.
00015  */
00016 
00017 #ifndef GFXFB_H
00018 #define GFXFB_H
00019 
00020 #include "Adafruit_GFX.h"
00021 
00022 #define BLACK         0x0000
00023 /* Light gray color, 565 mode */
00024 #define LIGHTGRAY     0X7BEF
00025 /* Dark gray color, 565 mode */
00026 #define DARKGRAY      0x39E7
00027 /* White color, 565 mode */
00028 #define WHITE         0xffff
00029 /* Red color, 565 mode */
00030 #define RED           0xF800
00031 /* Green color, 565 mode */
00032 #define GREEN         0x07E0
00033 /* Blue color, 565 mode */
00034 #define BLUE          0x001F
00035 /* Magenta color, 565 mode */
00036 #define MAGENTA       (RED | BLUE)
00037 /* Cyan color, 565 mode */
00038 #define CYAN          (GREEN | BLUE)
00039 /* Yellow color, 565 mode */
00040 #define YELLOW        (RED | GREEN)
00041 /* Light red color, 565 mode */
00042 #define LIGHTRED      0x7800
00043 /* Light green color, 565 mode */
00044 #define LIGHTGREEN    0x03E0
00045 /* Light blue color, 565 mode */
00046 #define LIGHTBLUE     0x000F
00047 /* Light magenta color, 565 mode */
00048 #define LIGHTMAGENTA  (LIGHTRED | LIGHTBLUE)
00049 /* Light cyan color, 565 mode */
00050 #define LIGHTCYAN     (LIGHTGREEN | LIGHTBLUE)
00051 /* Light yellow color, 565 mode */
00052 #define LIGHTYELLOW   (LIGHTRED | LIGHTGREEN)
00053 
00054 /**
00055  * Graphical library based on Adafruit's GFX using a Frame buffer.
00056  */
00057 class GFXFb : public Adafruit_GFX {
00058 public:
00059 
00060     /** Create an interface to the GFX graphical library
00061      *
00062      * @param w width of the display
00063      * @param h height of the display
00064      * @param fb frame buffer that will be used by the graphical library. Can
00065      * be set by calling setFb instead.
00066      */
00067     GFXFb(uint16_t w, uint16_t h, uint16_t* fb = 0);
00068 
00069     virtual void drawPixel(int16_t x, int16_t y, uint16_t color);
00070     virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
00071     virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
00072     virtual void fillScreen(uint16_t color);
00073 
00074     /** Associate a frame buffer with the graphical library.
00075      *  All drawing requests will be performed on the frame buffer.
00076      *
00077      * @param fb frame buffer that will be used by the graphical library
00078      */
00079     void setFb(uint16_t* fb) {_fb = fb;}
00080 
00081     /** Get the frame buffer associated with the graphical library.
00082      *
00083      * @returns the frame buffer associated with the graphical library.
00084      */
00085     uint16_t* getFb() {return _fb;}
00086 
00087     /** Write a null-terminated string
00088      *
00089      * @param s the string to write on the display
00090      */
00091     void writeString(const char* s);
00092 
00093     /** Get the width in pixels of the given string.
00094      *
00095      * @param s width will be calculated on this string
00096      * @returns the width in pixels of the string
00097      */
00098     int16_t getStringWidth(const char* s);
00099 
00100     /** Get the height in pixels of the given string.
00101      *
00102      * @param s height will be calculated on this string
00103      * @returns the height in pixels of the string
00104      */
00105     int16_t getStringHeight(const char* s);
00106 
00107 
00108 private:
00109 
00110     uint16_t* _fb;
00111 };
00112 
00113 #endif
00114 
00115