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

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?

UserRevisionLine numberNew 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 4:b32cf4ef45c5 16
embeddedartists 4:b32cf4ef45c5 17 /******************************************************************************
embeddedartists 4:b32cf4ef45c5 18 * Includes
embeddedartists 4:b32cf4ef45c5 19 *****************************************************************************/
embeddedartists 4:b32cf4ef45c5 20
embeddedartists 0:0fdadbc3d852 21 #include "mbed.h"
embeddedartists 0:0fdadbc3d852 22 #include "GFXFb.h"
embeddedartists 0:0fdadbc3d852 23
embeddedartists 0:0fdadbc3d852 24
embeddedartists 0:0fdadbc3d852 25 GFXFb::GFXFb(uint16_t w, uint16_t h, uint16_t* fb) : Adafruit_GFX(w, h) {
embeddedartists 0:0fdadbc3d852 26 _fb = fb;
embeddedartists 0:0fdadbc3d852 27 }
embeddedartists 0:0fdadbc3d852 28
embeddedartists 0:0fdadbc3d852 29
embeddedartists 0:0fdadbc3d852 30 void GFXFb::drawPixel(int16_t x, int16_t y, uint16_t color) {
embeddedartists 0:0fdadbc3d852 31 if (_fb == 0) return;
embeddedartists 0:0fdadbc3d852 32
embeddedartists 0:0fdadbc3d852 33 if (x < 0 || x >= width() || y < 0 || y >= height()) return;
embeddedartists 0:0fdadbc3d852 34
embeddedartists 0:0fdadbc3d852 35 *(_fb + x + y*_width ) = color;
embeddedartists 0:0fdadbc3d852 36 }
embeddedartists 0:0fdadbc3d852 37
embeddedartists 0:0fdadbc3d852 38 void GFXFb::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) {
embeddedartists 0:0fdadbc3d852 39 int16_t y2 = y + h - 1;
embeddedartists 0:0fdadbc3d852 40
embeddedartists 0:0fdadbc3d852 41 if (y < 0) y = 0;
embeddedartists 0:0fdadbc3d852 42 if (y2 >= _height) y2 = _height-1;
embeddedartists 0:0fdadbc3d852 43
embeddedartists 0:0fdadbc3d852 44 if (_fb == 0) return;
embeddedartists 0:0fdadbc3d852 45 if (x < 0 || x >= _width || y >= _height || y2 < y) return;
embeddedartists 0:0fdadbc3d852 46
embeddedartists 0:0fdadbc3d852 47 uint16_t* f = (_fb + x + y*_width);
embeddedartists 0:0fdadbc3d852 48 while(y <= y2) {
embeddedartists 0:0fdadbc3d852 49
embeddedartists 0:0fdadbc3d852 50 *f = color;
embeddedartists 0:0fdadbc3d852 51 f += _width;
embeddedartists 0:0fdadbc3d852 52 y++;
embeddedartists 0:0fdadbc3d852 53 }
embeddedartists 0:0fdadbc3d852 54
embeddedartists 0:0fdadbc3d852 55 }
embeddedartists 0:0fdadbc3d852 56
embeddedartists 0:0fdadbc3d852 57 void GFXFb::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) {
embeddedartists 0:0fdadbc3d852 58 int16_t x2 = x + w - 1;
embeddedartists 0:0fdadbc3d852 59
embeddedartists 0:0fdadbc3d852 60 if (x < 0) x = 0;
embeddedartists 0:0fdadbc3d852 61 if (x2 >= _width) x2 = _width-1;
embeddedartists 0:0fdadbc3d852 62
embeddedartists 0:0fdadbc3d852 63 if (_fb == 0) return;
embeddedartists 0:0fdadbc3d852 64 if (x >= _width || x2 < x || y < 0 || y >= _height) return;
embeddedartists 0:0fdadbc3d852 65
embeddedartists 0:0fdadbc3d852 66 uint16_t* f = (_fb + x + y*_width);
embeddedartists 0:0fdadbc3d852 67 while(x <= x2) {
embeddedartists 0:0fdadbc3d852 68
embeddedartists 0:0fdadbc3d852 69 *f++ = color;
embeddedartists 0:0fdadbc3d852 70 x++;
embeddedartists 0:0fdadbc3d852 71 }
embeddedartists 0:0fdadbc3d852 72
embeddedartists 0:0fdadbc3d852 73 }
embeddedartists 0:0fdadbc3d852 74
embeddedartists 0:0fdadbc3d852 75
embeddedartists 0:0fdadbc3d852 76 void GFXFb::fillScreen(uint16_t color) {
embeddedartists 0:0fdadbc3d852 77
embeddedartists 0:0fdadbc3d852 78 if (_fb == 0) return;
embeddedartists 0:0fdadbc3d852 79
embeddedartists 0:0fdadbc3d852 80 int len = _width*_height;
embeddedartists 0:0fdadbc3d852 81 for (int i = 0; i < len; i++) {
embeddedartists 0:0fdadbc3d852 82 *(_fb+i) = color;
embeddedartists 0:0fdadbc3d852 83 }
embeddedartists 0:0fdadbc3d852 84 }
embeddedartists 0:0fdadbc3d852 85
embeddedartists 0:0fdadbc3d852 86 void GFXFb::writeString(const char* s) {
embeddedartists 0:0fdadbc3d852 87 if (s == NULL) return;
embeddedartists 0:0fdadbc3d852 88
embeddedartists 0:0fdadbc3d852 89 while(*s != 0) {
embeddedartists 0:0fdadbc3d852 90 write(*s);
embeddedartists 0:0fdadbc3d852 91 s++;
embeddedartists 0:0fdadbc3d852 92 }
embeddedartists 0:0fdadbc3d852 93 }
embeddedartists 0:0fdadbc3d852 94
embeddedartists 0:0fdadbc3d852 95 int16_t GFXFb::getStringWidth(const char* s) {
embeddedartists 0:0fdadbc3d852 96 // the default font in GFX is 6 pixels in width
embeddedartists 0:0fdadbc3d852 97 int chWidth = 6*textsize;
embeddedartists 0:0fdadbc3d852 98 int sz = 0;
embeddedartists 0:0fdadbc3d852 99
embeddedartists 0:0fdadbc3d852 100 while(*s != 0) {
embeddedartists 0:0fdadbc3d852 101 sz += chWidth;
embeddedartists 0:0fdadbc3d852 102 s++;
embeddedartists 0:0fdadbc3d852 103 }
embeddedartists 0:0fdadbc3d852 104
embeddedartists 0:0fdadbc3d852 105 return sz;
embeddedartists 0:0fdadbc3d852 106 }
embeddedartists 0:0fdadbc3d852 107
embeddedartists 0:0fdadbc3d852 108 int16_t GFXFb::getStringHeight(const char* s) {
embeddedartists 0:0fdadbc3d852 109 (void)s;
embeddedartists 0:0fdadbc3d852 110 // the default font in GFX is 8 pixels in height
embeddedartists 0:0fdadbc3d852 111 return 8;
embeddedartists 0:0fdadbc3d852 112 }
embeddedartists 0:0fdadbc3d852 113
embeddedartists 0:0fdadbc3d852 114