예제 #1
0
EMSTATUS GLIB_drawBitmap(GLIB_Context_t *pContext, int32_t x, int32_t y,
                         uint32_t width, uint32_t height, uint8_t *picData)
{
  EMSTATUS status;

  /* Set display clipping area for bitmap */
  status = DMD_setClippingArea(x, y, width, height);
  if (status != DMD_OK) return status;

  /* Write bitmap to display */
  status = DMD_writeData(0, 0, picData, width * height);
  if (status != DMD_OK) return status;

  /* Reset driver clipping area to GLIB clipping region */
  return DMD_setClippingArea(pContext->clippingRegion.xMin, 
                               pContext->clippingRegion.yMin, 
                               pContext->clippingRegion.xMin + pContext->clippingRegion.xMax + 1, 
                               pContext->clippingRegion.yMin + pContext->clippingRegion.yMax + 1);
}
예제 #2
0
EMSTATUS GLIB_drawBitmap(const GLIB_Context *pContext, uint16_t x, uint16_t y,
                         uint16_t width, uint16_t height, uint8_t *picData)
{
  EMSTATUS status;

  /* Set display clipping area for bitmap */
  status = DMD_setClippingArea(x, y, width, height);
  if (status != DMD_OK) return status;

  /* Write bitmap to display */
  status = DMD_writeData(0, 0, picData, width * height);
  if (status != DMD_OK) return status;

  /* Reset display clipping area to the whole display */
  GLIB_resetDisplayClippingArea(pContext);
  if (status != GLIB_OK) return status;

  return GLIB_OK;
}
예제 #3
0
/**************************************************************************//**
 * @brief Display framebuffer
 * @param[in] fullFrame
 *   If true, draw entire screen, if false, draw incremental update (faster)
 *****************************************************************************/
void RETARGET_TFTUpdate(bool fullFrame)
{
  int      x, y;
  uint32_t pixelX, pixelY;
  uint8_t  c, bitField;
  int      i;

  /* Draw a full screen */
  if (fullFrame)
  {
    for (y = 0; y < LINES; y++)
    {
      for (x = 0; x < CHARS; x++)
      {
        pixelX = x * 8;
        pixelY = y * 8;

        c = charBuffer[y][x];
        for (i = 0; i < 8; i++)
        {
          bitField = fontBits[c + 100 * i];
          if (bitField == 0)
          {
            DMD_writeData(pixelX, pixelY + i, (uint8_t *) "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 8);
            continue;
          }

          if (bitField & 0x01)
          {
            DMD_writeColor(pixelX + 0, pixelY + i, rgbColor[0], rgbColor[1], rgbColor[2], 1);
          }
          else
          {
            DMD_writeColor(pixelX + 0, pixelY + i, 0x00, 0x00, 0x00, 1);
          }
          if (bitField & 0x02)
          {
            DMD_writeColor(pixelX + 1, pixelY + i, rgbColor[0], rgbColor[1], rgbColor[2], 1);
          }
          else
          {
            DMD_writeColor(pixelX + 1, pixelY + i, 0x00, 0x00, 0x00, 1);
          }
          if (bitField & 0x04)
          {
            DMD_writeColor(pixelX + 2, pixelY + i, rgbColor[0], rgbColor[1], rgbColor[2], 1);
          }
          else
          {
            DMD_writeColor(pixelX + 2, pixelY + i, 0x00, 0x00, 0x00, 1);
          }
          if (bitField & 0x08)
          {
            DMD_writeColor(pixelX + 3, pixelY + i, rgbColor[0], rgbColor[1], rgbColor[2], 1);
          }
          else
          {
            DMD_writeColor(pixelX + 3, pixelY + i, 0x00, 0x00, 0x00, 1);
          }
          if (bitField & 0x10)
          {
            DMD_writeColor(pixelX + 4, pixelY + i, rgbColor[0], rgbColor[1], rgbColor[2], 1);
          }
          else
          {
            DMD_writeColor(pixelX + 4, pixelY + i, 0x00, 0x00, 0x00, 1);
          }
          if (bitField & 0x20)
          {
            DMD_writeColor(pixelX + 5, pixelY + i, rgbColor[0], rgbColor[1], rgbColor[2], 1);
          }
          else
          {
            DMD_writeColor(pixelX + 5, pixelY + i, 0x00, 0x00, 0x00, 1);
          }
          if (bitField & 0x40)
          {
            DMD_writeColor(pixelX + 6, pixelY + i, rgbColor[0], rgbColor[1], rgbColor[2], 1);
          }
          else
          {
            DMD_writeColor(pixelX + 6, pixelY + i, 0x00, 0x00, 0x00, 1);
          }
          if (bitField & 0x80)
          {
            DMD_writeColor(pixelX + 7, pixelY + i, rgbColor[0], rgbColor[1], rgbColor[2], 1);
          }
          else
          {
            DMD_writeColor(pixelX + 7, pixelY + i, 0x00, 0x00, 0x00, 1);
          }
        }
      }
    }
  }
  else
  {
    /* Draw xpos, ypos only */
    c      = charBuffer[ypos][xpos];
    pixelX = xpos * 8;
    pixelY = ypos * 8;
    for (i = 0; i < 8; i++)
    {
      bitField = fontBits[c + 100 * i];
      if (bitField == 0)
      {
        DMD_writeData(pixelX, pixelY + i, (uint8_t *) "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 8);
        continue;
      }

      if (bitField & 0x01)

      {
        DMD_writeColor(pixelX + 0, pixelY + i, rgbColor[0], rgbColor[1], rgbColor[2], 1);
      }
      else
      {
        DMD_writeColor(pixelX + 0, pixelY + i, 0x00, 0x00, 0x00, 1);
      }
      if (bitField & 0x02)
      {
        DMD_writeColor(pixelX + 1, pixelY + i, rgbColor[0], rgbColor[1], rgbColor[2], 1);
      }
      else
      {
        DMD_writeColor(pixelX + 1, pixelY + i, 0x00, 0x00, 0x00, 1);
      }
      if (bitField & 0x04)
      {
        DMD_writeColor(pixelX + 2, pixelY + i, rgbColor[0], rgbColor[1], rgbColor[2], 1);
      }
      else
      {
        DMD_writeColor(pixelX + 2, pixelY + i, 0x00, 0x00, 0x00, 1);
      }
      if (bitField & 0x08)
      {
        DMD_writeColor(pixelX + 3, pixelY + i, rgbColor[0], rgbColor[1], rgbColor[2], 1);
      }
      else
      {
        DMD_writeColor(pixelX + 3, pixelY + i, 0x00, 0x00, 0x00, 1);
      }
      if (bitField & 0x10)
      {
        DMD_writeColor(pixelX + 4, pixelY + i, rgbColor[0], rgbColor[1], rgbColor[2], 1);
      }
      else
      {
        DMD_writeColor(pixelX + 4, pixelY + i, 0x00, 0x00, 0x00, 1);
      }
      if (bitField & 0x20)
      {
        DMD_writeColor(pixelX + 5, pixelY + i, rgbColor[0], rgbColor[1], rgbColor[2], 1);
      }
      else
      {
        DMD_writeColor(pixelX + 5, pixelY + i, 0x00, 0x00, 0x00, 1);
      }
      if (bitField & 0x40)
      {
        DMD_writeColor(pixelX + 6, pixelY + i, rgbColor[0], rgbColor[1], rgbColor[2], 1);
      }
      else
      {
        DMD_writeColor(pixelX + 6, pixelY + i, 0x00, 0x00, 0x00, 1);
      }
      if (bitField & 0x80)
      {
        DMD_writeColor(pixelX + 7, pixelY + i, rgbColor[0], rgbColor[1], rgbColor[2], 1);
      }
      else
      {
        DMD_writeColor(pixelX + 7, pixelY + i, 0x00, 0x00, 0x00, 1);
      }
    }
  }
}
예제 #4
0
/**************************************************************************//**
 * @brief Clears/updates entire background ready to be drawn
 *****************************************************************************/
void SLIDES_showBMP(char *fileName)
{
  int32_t  xCursor;
  int32_t  yCursor;
  uint32_t pixelsRead;
  uint32_t nPixelsPerRow;
  uint32_t nRows;

  EMSTATUS status;

  /* Open file */
  if (f_open(&BMPfile, fileName, FA_READ) != FR_OK)
  {
    SLIDES_showError(true, "Fatal:\n  Failed to open file:\n  %s", fileName);
  }

  /* Initialize BMP decoder */
  if (BMP_init(palette, 1024, &SLIDES_readData) != BMP_OK)
  {
    SLIDES_showError(true, "Fatal:\n  Failed to init BMP library.");
  }

  /* Read headers */
  if ((status = BMP_reset()) != BMP_OK)
  {
    SLIDES_showError(false, "Info:\n  %s is not a BMP file", fileName);
    goto cleanup;
  }

  /* Get important BMP data */
  nPixelsPerRow = BMP_getWidth();
  nRows         = BMP_getHeight();
  yCursor       = nRows - 1;
  xCursor       = 0;

  /* Check size of BMP */
  if ((nPixelsPerRow > 320) || (nRows > 240))
  {
    SLIDES_showError(false, "Info:\n  %s is larger than 320x240.", fileName);
  }

   /* Set clipping region */
  DMD_setClippingArea(0, 0, nPixelsPerRow, nRows);

  /* Read in and draw row for row */
  while (yCursor >= 0)
  {
    /* Read in row buffer */
    status = BMP_readRgbData(rgbBuffer, RGB_BUFFER_SIZE, &pixelsRead);
    if (status != BMP_OK || pixelsRead == 0)
      break;

    /* Draw row buffer. Remember, BMP is stored bottom-up */
    status = DMD_writeData(xCursor, yCursor, rgbBuffer, pixelsRead);
    if (status != DMD_OK)
      break;

    /* Update cursor */
    xCursor += pixelsRead;
    if (xCursor >= (int)nPixelsPerRow)
    {
      yCursor -= xCursor / nPixelsPerRow;
      xCursor  = xCursor % nPixelsPerRow;
    }
  }
  /* Reset clipping area in DMD driver */
  status = GLIB_resetDisplayClippingArea(&gc);
  if (status != 0)
    return;

cleanup:
  /* Close the file */
  f_close(&BMPfile);
}