The wait in mci_WaitForEvent will delay all card transactions.

Dependencies:   FATFileSystem

Fork of EALib by EmbeddedArtists AB

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GFXFb.cpp Source File

GFXFb.cpp

00001 
00002 /******************************************************************************
00003  * Includes
00004  *****************************************************************************/
00005 
00006 #include "mbed.h"
00007 #include "GFXFb.h"
00008 
00009 
00010 GFXFb::GFXFb(uint16_t w, uint16_t h, uint16_t* fb) : Adafruit_GFX(w, h) {
00011     _fb = fb;
00012 }
00013 
00014 
00015 void GFXFb::drawPixel(int16_t x, int16_t y, uint16_t color) {
00016     if (_fb == 0) return;
00017 
00018     if (x < 0 || x >= width() || y < 0 || y >= height()) return;
00019 
00020     *(_fb + x + y*_width ) = color;
00021 }
00022 
00023 void GFXFb::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) {
00024     int16_t y2 = y + h - 1;
00025 
00026     if (y < 0) y = 0;
00027     if (y2 >= _height) y2 = _height-1;
00028 
00029     if (_fb == 0) return;
00030     if (x < 0 || x >= _width || y >= _height || y2 < y) return;
00031 
00032     uint16_t* f = (_fb + x + y*_width);
00033     while(y <= y2) {
00034 
00035         *f = color;
00036         f += _width;
00037         y++;
00038     }
00039 
00040 }
00041 
00042 void GFXFb::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) {
00043     int16_t x2 = x + w - 1;
00044 
00045     if (x < 0) x = 0;
00046     if (x2 >= _width) x2 = _width-1;
00047 
00048     if (_fb == 0) return;
00049     if (x >= _width || x2 < x || y < 0 || y >= _height) return;
00050 
00051     uint16_t* f = (_fb + x + y*_width);
00052     while(x <= x2) {
00053 
00054         *f++ = color;
00055         x++;
00056     }
00057 
00058 }
00059 
00060 
00061 void GFXFb::fillScreen(uint16_t color) {
00062 
00063     if (_fb == 0) return;
00064 
00065     int len = _width*_height;
00066     for (int i = 0; i < len; i++) {
00067         *(_fb+i) = color;
00068     }
00069 }
00070 
00071 void GFXFb::writeString(const char* s) {
00072     if (s == NULL) return;
00073 
00074     while(*s != 0) {
00075         write(*s);
00076         s++;
00077     }
00078 }
00079 
00080 int16_t GFXFb::getStringWidth(const char* s) {
00081     // the default font in GFX is 6 pixels in width
00082     int chWidth = 6*textsize;
00083     int sz = 0;
00084 
00085     while(*s != 0) {
00086         sz += chWidth;
00087         s++;
00088     }
00089 
00090     return sz;
00091 }
00092 
00093 int16_t GFXFb::getStringHeight(const char* s) {
00094     (void)s;
00095     // the default font in GFX is 8 pixels in height
00096     return 8;
00097 }
00098 
00099