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/)
Diff: N5110.cpp
- Revision:
- 20:6550692c474f
- Parent:
- 19:ba8addc061ea
--- 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) {