The wait in mci_WaitForEvent will delay all card transactions.

Dependencies:   FATFileSystem

Fork of EALib by EmbeddedArtists AB

Committer:
embeddedartists
Date:
Thu Sep 26 06:37:02 2013 +0000
Revision:
0:0fdadbc3d852
Child:
4:b32cf4ef45c5
First version

Who changed what in which revision?

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