コード例 #1
0
ファイル: nxcon_scroll.c プロジェクト: 1015472/PX4NuttX
static inline void nxcon_movedisplay(FAR struct nxcon_state_s *priv,
                                     int bottom, int scrollheight)
{
  FAR struct nxcon_bitmap_s *bm;
  struct nxgl_rect_s rect;
  nxgl_coord_t row;
  int ret;
  int i;

  /* Move each row, one at a time.  They could all be moved at once (by calling
   * nxcon_redraw), but the since the region is cleared, then re-written, the
   * effect would not be good.  Below the region is also cleared and re-written,
   * however, in much smaller chunks.
   */

  rect.pt1.x = 0;
  rect.pt2.x = priv->wndo.wsize.w - 1;

  for (row = CONFIG_NXCONSOLE_LINESEPARATION; row < bottom; row += scrollheight)
    {
      /* Create a bounding box the size of one row of characters */

      rect.pt1.y = row;
      rect.pt2.y = row + scrollheight - 1;

      /* Clear the region */

      ret = priv->ops->fill(priv, &rect, priv->wndo.wcolor);
      if (ret < 0)
        {
          gdbg("fill failed: %d\n", errno);
        }

      /* Fill each character that might lie within in the bounding box */

      for (i = 0; i < priv->nchars; i++)
        {
          bm = &priv->bm[i];
          if (bm->pos.y <= rect.pt2.y && bm->pos.y + priv->fheight >= rect.pt1.y)
            {
              nxcon_fillchar(priv, &rect, bm);
            }
        }
    }

  /* Finally, clear the bottom part of the display */

  rect.pt1.y = bottom;
  rect.pt2.y = priv->wndo.wsize.h- 1;

  ret = priv->ops->fill(priv, &rect, priv->wndo.wcolor);
  if (ret < 0)
    {
      gdbg("nxcon_movedisplay: fill failed: %d\n", errno);
    }
}
コード例 #2
0
ファイル: nxcon_redraw.c プロジェクト: nuttx/nuttx_ieee80211
void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect, bool more)
{
    FAR struct nxcon_state_s *priv;
    int ret;
    int i;

    DEBUGASSERT(handle && rect);
    gvdbg("rect={(%d,%d),(%d,%d)} more=%s\n",
          rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
          more ? "true" : "false");

    /* Recover our private state structure */

    priv = (FAR struct nxcon_state_s *)handle;

    /* Get exclusive access to the state structure */

    do
    {
        ret = nxcon_semwait(priv);

        /* Check for errors */

        if (ret < 0)
        {
            /* The only expected error is if the wait failed because of it
             * was interrupted by a signal.
             */

            DEBUGASSERT(errno == EINTR);
        }
    }
    while (ret < 0);

    /* Fill the rectangular region with the window background color */

    ret = priv->ops->fill(priv, rect, priv->wndo.wcolor);
    if (ret < 0)
    {
        gdbg("fill failed: %d\n", errno);
    }

    /* Then redraw each character on the display (Only the characters within
     * the rectangle will actually be redrawn).
     */

    for (i = 0; i < priv->nchars; i++)
    {
        nxcon_fillchar(priv, rect, &priv->bm[i]);
    }

    (void)nxcon_sempost(priv);
}