Exemplo n.º 1
0
uint32_t lcd_drawtext(uint32_t x, uint32_t y, char *s, uint32_t size, uint32_t fgcolor, uint32_t bgcolor, uint32_t clear_bg)
{
  size = (size==0)?1:size;

  if(x == LCD_CENTER) //x center
  {
    x = (width/2)-((FONT_WIDTH*size*strlen(s))/2);
    if(x >= width){ x = 0; }
  }
  if(y == LCD_CENTER) //y center
  {
    y = (height/2)-((FONT_HEIGHT*size)/2);
    if(y >= height){ y = 0; }
  }

  while(*s != 0)
  {
    x = lcd_drawchar(x, y, *s++, size, fgcolor, bgcolor, clear_bg);
    if(x > width)
    {
      break;
    }
  }

  return x;
}
Exemplo n.º 2
0
void cmd_lcd_terminal(uint_least16_t fgcolor, uint_least16_t bgcolor, uint_least8_t size)
{
  uint_least16_t x=2, y=2;
  uint_least8_t c;

  lcd_clear(bgcolor);

  do
  {
    if(if_available() == 0)
    {
      continue;
    }

    c = if_read8();
    switch(c)
    {
      case '\n':
      case '\r':
        if(x > 0)
        {
          x  = 2;
          y += FONT_HEIGHT*size;
        }
        break;
      case '\t':
        c = ' ';
      default:
        x = lcd_drawchar(x, y, c, size, fgcolor, bgcolor, 1);
        break;
    }
    if(x >= lcd_getwidth())
    {
      x = 2;
      y += FONT_HEIGHT*size;
    }
    if((y+FONT_HEIGHT*size) >= lcd_getheight())
    {
      y = 2;
      lcd_clear(bgcolor);
    }
  }while(c != 0);

  lcd_clear(bgcolor);

  return;
}