-
-
Save smiler/6009255 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void lcd_font_char_xy(int xPos, int yPos, char character, FONT_INFO* fontInfo, uint16_t fgColor, uint16_t bgColor) | |
{ | |
unsigned short i = 0; | |
unsigned short j = 0; | |
unsigned short height = fontInfo->heightPages * 8; | |
unsigned short width; | |
unsigned short tableOffset = character - fontInfo->startChar;//32; | |
FONT_CHAR_INFO fontCharInfo = fontInfo->charInfo[(tableOffset)]; | |
uint16_t offset = fontCharInfo.offset; | |
uint16_t lineOffset; | |
unsigned short bitOffset; | |
unsigned short byteOffset; | |
width = fontCharInfo.widthBits; | |
unsigned char *buffer = &fontInfo->data[offset]; | |
//const unsigned char *buffer = //AsciiLib[(c - 32)] ; | |
unsigned char tmp_char = 0; | |
// TODO handle space character. | |
if (character == 32) | |
{ | |
return; | |
} | |
printf("char: '%c'; ascii: %d; table offset: %d; offset: %d; width: %d\n", character, (int)character, tableOffset, offset, width); | |
for (i = 0; i < height; i++) | |
{ | |
lineOffset = i * width; | |
tmp_char=buffer[lineOffset]; | |
for (j = 0; j < width; j++) | |
{ | |
// iterate over each horiz bit | |
byteOffset = j / 8; | |
bitOffset = j % 8; | |
tmp_char = fontInfo->data[offset + lineOffset + byteOffset]; //*(buffer + lineOffset + byteOffset); | |
if ( (tmp_char >> 7 - bitOffset) & 0x01) | |
{ | |
lcd_set_cursor(xPos + j, yPos + i); | |
lcd_write_ram_prepare(); | |
write_data(fgColor); | |
} | |
//uint16_t col = ( (tmp_char >> 7-j) & 0x01) ? charColor : bkColor; | |
//write_data(col); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment