Ср янв 20, 2021 21:11:19
void ST7789_DrawChar_7x11(uint16_t x, uint16_t y, uint16_t TextColor, uint16_t BgColor, uint8_t TransparentBg, unsigned char c)
{
uint8_t i,j;
uint8_t buffer[11];
if((x >= 240) || (y >= 240) || ((x + 4) < 0) || ((y + 7) < 0)) return;
if (c>143 && c<208) c=c+16;
//else if (c>=176 && c<=207) c=c-16;
//else c=c;
// Copy selected simbol to buffer
memcpy(buffer,&font7x11[((c-32)*11)],11);
for(j=0;j<11;j++)
{
for(i=0;i<7;i++)
{
if ((buffer[j] & (1<<i)) == 0)
{
if (!TransparentBg) ST7789_DrawPixel(x + i, y + j, BgColor);
}
else ST7789_DrawPixel(x + i, y + j, TextColor);
}
}
}
void ST7789_print_5x8(uint16_t x, uint16_t y, uint16_t TextColor, uint16_t BgColor, uint8_t TransparentBg, char *str)
{
unsigned char type = *str;
if (type>=128) x = x - 3;
while (*str)
{
ST7789_DrawChar_5x8(x, y, TextColor, BgColor, TransparentBg, *str++);
unsigned char type = *str;
if (type>=128) x=x+3;
else x=x+6;
}
}
void ST7789_print_7x11(uint16_t x, uint16_t y, uint16_t TextColor, uint16_t BgColor, uint8_t TransparentBg, char *str)
{
unsigned char type = *str;
if (type>=128) x = x - 3;
while (*str)
{
ST7789_DrawChar_7x11(x, y, TextColor, BgColor, TransparentBg, *str++);
unsigned char type = *str;
if (type>=128) x=x+8;
else x=x+8;
}
}