With your current setup it looks like you need to modify the drawbuffer() function to incorporate printing text. We did something similar in the FlappyBirdz game with a score variable needing printed after being converted to a string. Here's a snippet of the solution in FlappyBirdz, you will likely come up with something more optimizedfor your program:
void drawBuffer() {
uint8_t lineBuffer[96 * 64 * 2];
display.startData();
for (int y = 0; y < 64; y++) {
for (int b = 0; b < 96; b++) {
lineBuffer[b * 2] = TS_16b_Blue >> 8;
lineBuffer[b * 2 + 1] = TS_16b_Blue;
}
for (int spriteIndex = 0; spriteIndex < amtSprites; spriteIndex++) {
ts_sprite *cs = spriteList[spriteIndex];
if (y >= cs->y && y < cs->y + cs->height) {
int endX = cs->x + cs->width;
if (cs->x < 96 && endX > 0) {
int bitmapNumOffset = cs->bitmapNum * cs->width * cs->height;
int xBitmapOffset = 0;
int xStart = 0;
if (cs->x < 0)xBitmapOffset -= cs->x;
if (cs->x > 0)xStart = cs->x;
int yBitmapOffset = (y - cs->y) * cs->width;
for (int x = xStart; x < endX; x++) {
unsigned int color = cs->bitmap[bitmapNumOffset + xBitmapOffset + yBitmapOffset++];
if (color != ALPHA) {
lineBuffer[(x) * 2] = color >> 8;
lineBuffer[(x) * 2 + 1] = color;
}
}
}
}
}
putString(y, score.x, score.y, score.stringChars, lineBuffer, liberationSans_16ptFontInfo);
if (startScreen) {
putString(y, 1, 38, score.stringChars, lineBuffer, liberationSans_10ptFontInfo);
char hs[10];
sprintf(hs, "%d", highScore);
putString(y, 74, 38, hs, lineBuffer, liberationSans_10ptFontInfo);
}
display.writeBuffer(lineBuffer, 96 * 2);
}
display.endTransfer();
}
void putString(int y, int fontX, int fontY, char * string, uint8_t * buff, const FONT_INFO& fontInfo) {
const FONT_CHAR_INFO* fontDescriptor = fontInfo.charDesc;
int fontHeight = fontInfo.height;
if (y >= fontY && y < fontY + fontHeight) {
const unsigned char* fontBitmap = fontInfo.bitmap;
int fontFirstCh = fontInfo.startCh;
int fontLastCh = fontInfo.endCh;
//if(!_fontFirstCh)return 1;
//if(ch<_fontFirstCh || ch>_fontLastCh)return 1;
//if(_cursorX>xMax || _cursorY>yMax)return 1;
int stringChar = 0;
int ch = string[stringChar++];
while (ch) {
uint8_t chWidth = pgm_read_byte(&fontDescriptor[ch - fontFirstCh].width);
int bytesPerRow = chWidth / 8;
if (chWidth > bytesPerRow * 8)
bytesPerRow++;
unsigned int offset = pgm_read_word(&fontDescriptor[ch - fontFirstCh].offset) + (bytesPerRow * fontHeight) - 1;
for (uint8_t byte = 0; byte < bytesPerRow; byte++) {
uint8_t data = pgm_read_byte(fontBitmap + offset - (y - fontY) - ((bytesPerRow - byte - 1) * fontHeight));
uint8_t bits = byte * 8;
for (int i = 0; i < 8 && (bits + i) < chWidth; i++) {
if (data & (0x80 >> i)) {
buff[(fontX) * 2] = TS_16b_Yellow >> 8;
buff[(fontX) * 2 + 1] = TS_16b_Yellow;
// setPixelInBuff(y,16+fontX,0);
//lineBuffer[16+fontX]=0;
} else {
//SPDR=_fontBGcolor;
}
fontX++;
}
}
fontX += 2;
ch = string[stringChar++];
}
}
}