diff --git a/ssd1306.c b/ssd1306.c --- a/ssd1306.c +++ b/ssd1306.c @@ -259,7 +259,7 @@ void ssd1306_drawlogo() /* Print a single character from font.cpp */ void ssd1306_DrawChar(char ascii, unsigned char row, unsigned char xPos) { - char *srcPointer = 0; + char *srcPointer = -1; unsigned char i; srcPointer = &fontData[(ascii-32)][0]; @@ -275,6 +275,69 @@ void ssd1306_DrawChar(char ascii, unsign WriteData(0x00); } +void ssd1306_DrawCharBig(char ascii, unsigned char row, unsigned char xPos) +{ + char *srcPointer = -1; + unsigned char i; + + srcPointer = &fontData[(ascii-32)][0]; + + setStartPage(row-1); + setStartColumn(xPos); + + // Write first row + for(i=0;i<5;i++) + { + uint8_t data = 0; + data |= ((*srcPointer) & 0b1000) << 4; // get top 4 bits + data |= ((*srcPointer) & 0b1000) << 3; // get top 4 bits + + data |= ((*srcPointer) & 0b0100) << 3; // get top 4 bits + data |= ((*srcPointer) & 0b0100) << 2; // get top 4 bits + + data |= ((*srcPointer) & 0b0010) << 2; // get top 4 bits + data |= ((*srcPointer) & 0b0010) << 1; // get top 4 bits + + data |= ((*srcPointer) & 0b0001) << 1; // get top 4 bits + data |= ((*srcPointer) & 0b0001); // get top 4 bits + + WriteData(data); + WriteData(data); + + srcPointer++; + } + WriteData(0x00); + + srcPointer -= 5; + + setStartPage(row); + setStartColumn(xPos); + + // Write second row + for(i=0;i<5;i++) + { + uint8_t data = 0; + data |= (*srcPointer) & 0b10000000; // get top 4 bits + data |= ((*srcPointer) & 0b10000000) >> 1; // get top 4 bits + + data |= ((*srcPointer) & 0b01000000) >> 1; // get top 4 bits + data |= ((*srcPointer) & 0b01000000) >> 2; // get top 4 bits + + data |= ((*srcPointer) & 0b00100000) >> 2; // get top 4 bits + data |= ((*srcPointer) & 0b00100000) >> 3; // get top 4 bits + + data |= ((*srcPointer) & 0b00010000) >> 3; // get top 4 bits + data |= ((*srcPointer) & 0b00010000) >> 4; // get top 4 bits + + WriteData(data); + WriteData(data); + + srcPointer++; + } + WriteData(0x00); + +} + void ssd1306_DrawString(const char *dataPtr, unsigned char row, unsigned char xPos) { char *srcPointer; @@ -291,4 +354,22 @@ void ssd1306_DrawString(const char *data } } + +void ssd1306_DrawStringBig(const char *dataPtr, unsigned char row, unsigned char xPos) +{ + char *srcPointer; + + srcPointer = (char*)dataPtr; + ssd1306_DrawCharBig(' ',row,xPos); // NBSP must be written first before the string start + + while(1) + { + ssd1306_DrawCharBig(*srcPointer,row,xPos); + srcPointer++; + xPos+=12; + if(*srcPointer == 0) break; + } +} + + // vim:softtabstop=4 shiftwidth=4 expandtab