Страница 1 из 1

Криво выводит текст

Добавлено: Ср янв 20, 2021 21:11:19
cargo29
Добрый день, только взялся за STM32f103c8t6 и st7789 нашел небольшую библиотеку, при выводе текста пишет рПрРрИрпс ри, а должно вывести ПРИпри
Спойлер

Код: Выделить всё

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;
  }
}
Если выводить отдельно символ один то нормально отображается.

Добавлено after 2 minutes:
Это если выводить функцией 7*11, функция 5*8 выводит нормально (у нее другая база символов)