int PutChar(uint8_t c) { uint8_t x = Get_x_address(); uint8_t y = Get_y_address(); if(Font == 0) return 0; // no font selected /* * check for special character processing */ if(c < 0x20) { //SpecialChar(c); return 1; } uint8_t width = 0; uint8_t height = FontRead(Font+FONT_HEIGHT); uint8_t bytes = (height+7)/8; /* calculates height in rounded up bytes */ uint8_t firstChar = FontRead(Font+FONT_FIRST_CHAR); uint8_t charCount = FontRead(Font+FONT_CHAR_COUNT); uint16_t index = 0; uint8_t thielefont; if(c < firstChar || c >= (firstChar+charCount)) { return 0; // invalid char } c-= firstChar; if( isFixedWidthFont(Font) { thielefont = 0; width = FontRead(Font+FONT_FIXED_WIDTH); index = c*bytes*width+FONT_WIDTH_TABLE; } else{
/* -------------------------------------------------------------------------------------- * Name: GLCD_PutChar * Function: * Args: color=[WHITE/BLACK] * Status: OK * Comments: * Revisions: * 1) Initial Code * -------------------------------------------------------------------------------------- * */ int GLCD_PutChar(char c) { uint8_t width = 0; uint8_t height = FontRead(Font+FONT_HEIGHT); uint8_t bytes = (height+7)/GLCDLowLevel_DISPLAY_PAGE_SIZE; uint8_t firstChar = FontRead(Font+FONT_FIRST_CHAR); uint8_t charCount = FontRead(Font+FONT_CHAR_COUNT); uint16_t index = 0; uint8_t x = __GLCD_Coord.x, y = __GLCD_Coord.y/GLCDLowLevel_DISPLAY_PAGE_SIZE; if(c < firstChar || c >= (firstChar+charCount)) { return 1; } c-= firstChar; if( FontRead(Font+FONT_LENGTH) == 0 && FontRead(Font+FONT_LENGTH+1) == 0) { // zero length is flag indicating fixed width font (array does not contain width data entries) width = FontRead(Font+FONT_FIXED_WIDTH); index = c*bytes*width+FONT_WIDTH_TABLE; } else{ // variable width font, read width data, to get the index uint8_t i; for(i=0; i<c; i++) { index += FontRead(Font+FONT_WIDTH_TABLE+i); } index = index*bytes+charCount+FONT_WIDTH_TABLE; width = FontRead(Font+FONT_WIDTH_TABLE+c); } // Draw the character uint8_t i; uint8_t j; for( i=0; i<bytes; i++) { uint8_t page = i*width; for(j=0; j<width; j++) { uint8_t data = FontRead(Font+index+page+j); if(height > 8 && height < (i+1)*8) { data >>= (i+1)*8-height; } if(FontColor == BLACK) { GLCDLowLevel_VideoRAM[x+j][y+i]|=data; //__GLCD_WriteData(data); } else { GLCDLowLevel_VideoRAM[x+j][y+i]&=~data; //__GLCD_WriteData(~data); } } // 1px gap between chars if(FontColor == BLACK) { GLCDLowLevel_VideoRAM[x+j+1][y+i] = WHITE; } else { GLCDLowLevel_VideoRAM[x+j+1][y+i] = BLACK; } }