Modified N5110 library with the ability to the print strings at exact pxiel locations, not just at each bank
Fork of N5110 by
Credit to C.Evans for the original library (https://developer.mbed.org/users/eencae/code/N5110/)
Revision 20:6550692c474f, committed 2016-05-06
- Comitter:
- el14j2h
- Date:
- Fri May 06 14:58:03 2016 +0000
- Parent:
- 19:ba8addc061ea
- Commit message:
- Added printStringExact;
Changed in this revision
N5110.cpp | Show annotated file Show diff for this revision Revisions of this file |
N5110.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r ba8addc061ea -r 6550692c474f N5110.cpp --- a/N5110.cpp Thu Apr 23 18:57:52 2015 +0000 +++ b/N5110.cpp Fri May 06 14:58:03 2016 +0000 @@ -234,7 +234,38 @@ refresh(); // this sends the buffer to the display and sets address (cursor) back to 0,0 } } +void N5110::printString_exact(const char * str,int x,int y) +{ + int n = 0 ; // counter for number of characters in string + int bankOffset = y%8; + int ybank0 = (y - bankOffset)/8; + int ybank1 = ybank0+1; + if (ybank0>=0 && ybank0<BANKS){ + // loop through string and print character + while(*str) { + + for (int i = 0; i < 5 ; i++ ) {//each charactor is 5 pixels wide 7 high + int pixel_x = x+i+n*6; + + if (pixel_x > WIDTH-1) // ensure pixel isn't outside the buffer size (0 - 83) + break; + + buffer[pixel_x][ybank0] |= font5x7[(*str - 32)*5 + i]<<bankOffset; + if (ybank1>=0 && ybank1<BANKS && bankOffset>0){ + buffer[pixel_x][ybank1] |= font5x7[(*str - 32)*5 + i]>>(8-bankOffset); + } + } + + str++; // go to next character in string + + n++; // increment index + + } + + // refresh(); // this sends the buffer to the display and sets address (cursor) back to 0,0 + } +} // function to print string at specified position void N5110::printString(const char * str,int x,int y) {
diff -r ba8addc061ea -r 6550692c474f N5110.h --- a/N5110.h Thu Apr 23 18:57:52 2015 +0000 +++ b/N5110.h Fri May 06 14:58:03 2016 +0000 @@ -219,7 +219,12 @@ * @param y - the row number (0 to 5) - the display is split into 6 banks - each bank can be considered a row */ void printString(const char * str,int x,int y); - + /** Print String + * + * Prints a string of characters to the display at the exact pixel location. String is cut-off horizontally after the 83rd pixel and vertically at the 48 pixel. + * @param x - the column number (0 to 83) + * @param y - the row number (0 to 48)*/ + void printString_exact(const char * str,int x,int y); /** Print Character * * Sends a character to the display. Printed at the specified location. Character is cut-off after the 83rd pixel.