示例#1
0
/**************************************************************************//**
 * @brief Draw single character into frame buffer
 * @param[in] x Horizontal start position into frame buffer in pixels
 * @param[in] y Vertical start position into frame buffer in pixels
 * @param[in] str String to draw
 *****************************************************************************/
void TFT_DrawString(int x, int y, char *str)
{
  /* Draw string, no boundary checks are performed */
  while (*str)
  {
    TFT_DrawFont(x, y, *str++);
    x += 16;
  }
}
示例#2
0
/**************************************************************************//**
 * @brief EBI interrupt routine, configures new frame buffer offset
 *****************************************************************************/
void EBI_IRQHandler(void)
{
  uint32_t flags;
  uint32_t lineNumber;
  uint32_t prevMaskBlend;

  /* Get source for interrupt */
  flags = EBI_IntGet();

  /* Clear interrupt */
  EBI_IntClear(flags);

  /* Process vertical sync interrupt */
  if (flags & EBI_IF_VFPORCH)
  {
    /* Keep tracke of number of frames drawn */
    frameCtr++;

    /* Increase this increment to 2/4/8 to increase scroll speed */
    hzOffset += 1;

    /* Wrap around when a full screen has been displayed */
    if (hzOffset == (D_WIDTH + font16x28.c_width))
    {
      hzOffset = 0;
    }

    /* We only redraw when we need to */
    if (hzOffset != hPos)
    {
      hPos = hzOffset;
      /* We only redraw when we need a new character */
      if ((hPos % 16) == 0)
      {
        /* Update frame buffer - we do this in the interrupt routine to    */
        /* ensure a smooth scroller no matter what else is being done.     */
        /* However, drawing these fonts with low optimization will take    */
        /* more than one scan line, so this _can_ result in tearing at the */
        /* top of the screen for this example.                             */
        prevMaskBlend = EBI->TFTCTRL & _EBI_TFTCTRL_MASKBLEND_MASK;
        EBI_TFTMaskBlendMode(ebiTFTMBDisabled);
        TFT_DrawFont(D_WIDTH + hPos, D_HEIGHT - font16x28.height, *scrollptr);
        if (hPos > 0)
        {
          TFT_DrawFont(hPos - font16x28.c_width, D_HEIGHT - font16x28.height, *scrollptr);
        }
        EBI->TFTCTRL |= prevMaskBlend;
        /* Update pointer into text, reset if at last character */
        scrollptr++;
        if (*scrollptr == '\0')
        {
          scrollptr = scrolltext;
        }
      }
    }
  }

  /* Process horizontal sync interrupt */
  if (flags & EBI_IF_HSYNC)
  {
    lineNumber = EBI_TFTVCount();

    /* Adjust for porch size */
    if (lineNumber >= 3) lineNumber -= 3;
    if (lineNumber < (D_HEIGHT - font16x28.c_height))
    {
      EBI_TFTFrameBaseSet(lineNumber * V_WIDTH * 2);
    }
    else
    {
      EBI_TFTFrameBaseSet(lineNumber * V_WIDTH * 2 + hzOffset * 2);
    }
  }
}