mctext.c library fix
This commit is contained in:
@@ -16,7 +16,7 @@ void (*mct_SetPixel)(uint8_t, uint8_t, uint8_t) = ST7565_SetPixel;
|
|||||||
|
|
||||||
|
|
||||||
// Draw a single character. Returns width of drawn character
|
// Draw a single character. Returns width of drawn character
|
||||||
uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font) {
|
uint8_t mct_CharT(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font, uint8_t transp) {
|
||||||
uint8_t pk = font[0]; // Is it a packed font?
|
uint8_t pk = font[0]; // Is it a packed font?
|
||||||
uint8_t w = font[1]; // Font char width
|
uint8_t w = font[1]; // Font char width
|
||||||
uint8_t h = font[2]; // Font char height
|
uint8_t h = font[2]; // Font char height
|
||||||
@@ -33,7 +33,7 @@ uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uin
|
|||||||
// Calc the offset for desired symbol
|
// Calc the offset for desired symbol
|
||||||
if (pk) { // The font is packed
|
if (pk) { // The font is packed
|
||||||
if (w) { // The font is monospaced
|
if (w) { // The font is monospaced
|
||||||
bps = w*h/8 + 1; // Bytes per symbol + width byte
|
bps = w*h/8; // Bytes per symbol
|
||||||
if ((w*h)%8 > 0) bps++; // Correction for the last byte
|
if ((w*h)%8 > 0) bps++; // Correction for the last byte
|
||||||
o = FONT_HEADER+(c-fc)*bps; // Offset for desired symbol
|
o = FONT_HEADER+(c-fc)*bps; // Offset for desired symbol
|
||||||
} else { // The font is not monospaced
|
} else { // The font is not monospaced
|
||||||
@@ -82,6 +82,7 @@ uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uin
|
|||||||
seg = font[o];
|
seg = font[o];
|
||||||
for (b=0; b<s; b++) { // Going through the byte and paint the pixel if the bit is 1
|
for (b=0; b<s; b++) { // Going through the byte and paint the pixel if the bit is 1
|
||||||
if ((seg>>b) & 1) mct_SetPixel(x+i, y+j*8+b, color);
|
if ((seg>>b) & 1) mct_SetPixel(x+i, y+j*8+b, color);
|
||||||
|
else if (!transp) mct_SetPixel(x+i, y+j*8+b, !color);
|
||||||
}
|
}
|
||||||
o++;
|
o++;
|
||||||
}
|
}
|
||||||
@@ -91,11 +92,16 @@ uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uin
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw a single character. Transparent background. Returns width of drawn character
|
||||||
|
uint8_t mct_Char(uint8_t x, uint8_t y, unsigned char c, uint8_t color, const uint8_t *font) {
|
||||||
|
mct_CharT(x, y, c, color, font, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Draw a string of characters
|
// Draw a string of characters
|
||||||
void mct_String(uint8_t x, uint8_t y, const char *c, uint8_t color, const uint8_t *font) {
|
void mct_String(uint8_t x, uint8_t y, const char *c, uint8_t color, const uint8_t *font) {
|
||||||
uint8_t w = font[0]; // Font char width
|
uint8_t w = font[1]; // Font char width
|
||||||
uint8_t h = font[1]; // Font char height
|
uint8_t h = font[2]; // Font char height
|
||||||
uint8_t s = font[2]; // Font space between characters
|
uint8_t s = font[3]; // Font space between characters
|
||||||
|
|
||||||
if (y+h > LCDHEIGHT) return;
|
if (y+h > LCDHEIGHT) return;
|
||||||
while (c[0] != 0) {
|
while (c[0] != 0) {
|
||||||
|
Reference in New Issue
Block a user