diff options
-rw-r--r-- | nuttx/ChangeLog | 3 | ||||
-rw-r--r-- | nuttx/Documentation/NXGraphicsSubsystem.html | 2 | ||||
-rw-r--r-- | nuttx/graphics/README.txt | 2 | ||||
-rwxr-xr-x | nuttx/graphics/nxconsole/nxcon_driver.c | 7 | ||||
-rw-r--r-- | nuttx/graphics/nxconsole/nxcon_font.c | 83 | ||||
-rw-r--r-- | nuttx/graphics/nxconsole/nxcon_internal.h | 9 | ||||
-rw-r--r-- | nuttx/graphics/nxconsole/nxcon_putc.c | 63 | ||||
-rw-r--r-- | nuttx/graphics/nxconsole/nxcon_register.c | 5 | ||||
-rw-r--r-- | nuttx/include/nuttx/nx/nxconsole.h | 8 | ||||
-rw-r--r--[-rwxr-xr-x] | nuttx/include/nuttx/vt100.h | 0 |
10 files changed, 181 insertions, 1 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 8dc081008..1a8a34b00 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -2612,3 +2612,6 @@ VT100 escape sequence definitions. * graphics/nxconsole/nxcon_vt100.c: Add add framework to support VT100 escape sequences in NxConsole. + * fs/fs_read.c: Fix read() return value for attempt to read from write-only + file or device. Was returning EBADF, should return EACCES. + * graphics/nxconsole.c: NxConsole now supports backspace and a cursor. diff --git a/nuttx/Documentation/NXGraphicsSubsystem.html b/nuttx/Documentation/NXGraphicsSubsystem.html index 38baf54ee..0eb18e54e 100644 --- a/nuttx/Documentation/NXGraphicsSubsystem.html +++ b/nuttx/Documentation/NXGraphicsSubsystem.html @@ -3360,6 +3360,8 @@ int nxf_convert_32bpp(FAR uint32_t *dest, uint16_t height, <dd>Currently, NxConsole supports only a single pixel depth. This configuration setting must be provided to support that single pixel depth. Default: The smallest enabled pixel depth. (see <code>CONFIG_NX_DISABLE_*BPP</code>) + <dt><code>CONFIG_NXCONSOLE_CURSORCHAR</code>: + <dd>The bitmap code to use as the cursor. Default '_' <dt><code>CONFIG_NXCONSOLE_NOGETRUN</code>: <dd>NxConsole needs to know if it can read from the LCD or not. If reading from the LCD is supported, then NxConsole can do more efficient scrolling. diff --git a/nuttx/graphics/README.txt b/nuttx/graphics/README.txt index a816cdb58..acecfe433 100644 --- a/nuttx/graphics/README.txt +++ b/nuttx/graphics/README.txt @@ -328,6 +328,8 @@ CONFIG_NXCONSOLE_BPP Currently, NxConsole supports only a single pixel depth. This configuration setting must be provided to support that single pixel depth. Default: The smallest enabled pixel depth. (see CONFIG_NX_DISABLE_*BPP) +CONFIG_NXCONSOLE_CURSORCHAR + The bitmap code to use as the cursor. Default '_' CONFIG_NXCONSOLE_NOGETRUN NxConsole needs to know if it can read from the LCD or not. If reading from the LCD is supported, then NxConsole can do more efficient diff --git a/nuttx/graphics/nxconsole/nxcon_driver.c b/nuttx/graphics/nxconsole/nxcon_driver.c index 646485146..f246070a5 100755 --- a/nuttx/graphics/nxconsole/nxcon_driver.c +++ b/nuttx/graphics/nxconsole/nxcon_driver.c @@ -142,6 +142,10 @@ static ssize_t nxcon_write(FAR struct file *filep, FAR const char *buffer, return ret; } + /* Hide the cursor while we update the display */ + + nxcon_hidecursor(priv); + /* Loop writing each character to the display */ for (remaining = (ssize_t)buflen; remaining > 0; remaining--) @@ -217,6 +221,9 @@ static ssize_t nxcon_write(FAR struct file *filep, FAR const char *buffer, while (state == VT100_ABORT); } + /* Show the cursor at its new position */ + + nxcon_showcursor(priv); nxcon_sempost(priv); return (ssize_t)buflen; } diff --git a/nuttx/graphics/nxconsole/nxcon_font.c b/nuttx/graphics/nxconsole/nxcon_font.c index 2677b9c15..2bdf21cf6 100644 --- a/nuttx/graphics/nxconsole/nxcon_font.c +++ b/nuttx/graphics/nxconsole/nxcon_font.c @@ -41,6 +41,7 @@ #include <string.h> #include <assert.h> +#include <errno.h> #include <debug.h> #include <nuttx/kmalloc.h> @@ -442,6 +443,88 @@ nxcon_addchar(NXHANDLE hfont, FAR struct nxcon_state_s *priv, uint8_t ch) } /**************************************************************************** + * Name: nxcon_hidechar + * + * Description: + * Erase a character from the window. + * + ****************************************************************************/ +int nxcon_hidechar(FAR struct nxcon_state_s *priv, + FAR const struct nxcon_bitmap_s *bm) +{ + struct nxgl_rect_s bounds; + struct nxgl_size_s fsize; + int ret; + + /* Get the size of the font glyph. If nxcon_fontsize, then the + * character will have been rendered as a space, and no display + * modification is required (not an error). + */ + + ret = nxcon_fontsize(priv->font, bm->code, &fsize); + if (ret < 0) + { + /* It was rendered as a space. */ + + return OK; + } + + /* Construct a bounding box for the glyph */ + + bounds.pt1.x = bm->pos.x; + bounds.pt1.y = bm->pos.y; + bounds.pt2.x = bm->pos.x + fsize.w - 1; + bounds.pt2.y = bm->pos.y + fsize.h - 1; + + /* Fill the bitmap region with the background color, erasing the + * character from the display. NOTE: This region might actually + * be obscured... NX will handle that case. + */ + + return priv->ops->fill(priv, &bounds, priv->wndo.wcolor); +} + +/**************************************************************************** + * Name: nxcon_backspace + * + * Description: + * Remove the last character from the window. + * + ****************************************************************************/ + +int nxcon_backspace(FAR struct nxcon_state_s *priv) +{ + FAR struct nxcon_bitmap_s *bm; + int ndx; + int ret = -ENOENT; + + /* Is there a character on the display? */ + + if (priv->nchars > 0) + { + /* Yes.. Get the index to the last bitmap on the display */ + + ndx = priv->nchars - 1; + bm = &priv->bm[ndx]; + + /* Erase the character from the display */ + + ret = nxcon_hidechar(priv, bm); + + /* The current position to the location where the last character was */ + + priv->fpos.x = bm->pos.x; + priv->fpos.y = bm->pos.y; + + /* Decrement nchars to discard this character */ + + priv->nchars = ndx; + } + + return ret; +} + +/**************************************************************************** * Name: nxcon_home * * Description: diff --git a/nuttx/graphics/nxconsole/nxcon_internal.h b/nuttx/graphics/nxconsole/nxcon_internal.h index ebcab909b..10341f0cf 100644 --- a/nuttx/graphics/nxconsole/nxcon_internal.h +++ b/nuttx/graphics/nxconsole/nxcon_internal.h @@ -162,6 +162,7 @@ struct nxcon_state_s /* Font cache data storage */ + struct nxcon_bitmap_s cursor; struct nxcon_bitmap_s bm[CONFIG_NXCONSOLE_MXCHARS]; /* Glyph cache data storage */ @@ -204,12 +205,18 @@ enum nxcon_vt100state_e nxcon_vt100(FAR struct nxcon_state_s *priv, char ch); void nxcon_home(FAR struct nxcon_state_s *priv); void nxcon_newline(FAR struct nxcon_state_s *priv); -void nxcon_putc(FAR struct nxcon_state_s *priv, uint8_t ch); FAR const struct nxcon_bitmap_s *nxcon_addchar(NXHANDLE hfont, FAR struct nxcon_state_s *priv, uint8_t ch); +int nxcon_hidechar(FAR struct nxcon_state_s *priv, + FAR const struct nxcon_bitmap_s *bm); +int nxcon_backspace(FAR struct nxcon_state_s *priv); void nxcon_fillchar(FAR struct nxcon_state_s *priv, FAR const struct nxgl_rect_s *rect, FAR const struct nxcon_bitmap_s *bm); +void nxcon_putc(FAR struct nxcon_state_s *priv, uint8_t ch); +void nxcon_showcursor(FAR struct nxcon_state_s *priv); +void nxcon_hidecursor(FAR struct nxcon_state_s *priv); + /* Scrolling support */ void nxcon_scroll(FAR struct nxcon_state_s *priv, int scrollheight); diff --git a/nuttx/graphics/nxconsole/nxcon_putc.c b/nuttx/graphics/nxconsole/nxcon_putc.c index 97e3314a6..d51d79c79 100644 --- a/nuttx/graphics/nxconsole/nxcon_putc.c +++ b/nuttx/graphics/nxconsole/nxcon_putc.c @@ -39,6 +39,8 @@ #include <nuttx/config.h> +#include <nuttx/ascii.h> + #include "nxcon_internal.h" /**************************************************************************** @@ -85,6 +87,14 @@ void nxcon_putc(FAR struct nxcon_state_s *priv, uint8_t ch) return; } + /* Handle backspace (treating both BS and DEL as backspace) */ + + if (ch == ASCII_BS || ch == ASCII_DEL) + { + nxcon_backspace(priv); + return; + } + /* Will another character fit on this line? */ if (priv->fpos.x + priv->fwidth > priv->wndo.wsize.w) @@ -138,3 +148,56 @@ void nxcon_putc(FAR struct nxcon_state_s *priv, uint8_t ch) nxcon_fillchar(priv, NULL, bm); } } + +/**************************************************************************** + * Name: nxcon_showcursor + * + * Description: + * Render the cursor character at the current display position. + * + ****************************************************************************/ + +void nxcon_showcursor(FAR struct nxcon_state_s *priv) +{ + int lineheight; + + /* Will another character fit on this line? */ + + if (priv->fpos.x + priv->fwidth > priv->wndo.wsize.w) + { +#ifndef CONFIG_NXCONSOLE_NOWRAP + /* No.. move to the next line */ + + nxcon_newline(priv); +#else + return; +#endif + } + + /* Check if we need to scroll up */ + + lineheight = (priv->fheight + CONFIG_NXCONSOLE_LINESEPARATION); + while (priv->fpos.y >= priv->wndo.wsize.h - lineheight) + { + nxcon_scroll(priv, lineheight); + } + + /* Render the cursor glyph onto the display. */ + + priv->cursor.pos.x = priv->fpos.x; + priv->cursor.pos.y = priv->fpos.y; + nxcon_fillchar(priv, NULL, &priv->cursor); +} + +/**************************************************************************** + * Name: nxcon_hidecursor + * + * Description: + * Render the cursor cursor character from the display. + * + ****************************************************************************/ + +void nxcon_hidecursor(FAR struct nxcon_state_s *priv) +{ + (void)nxcon_hidechar(priv, &priv->cursor); +} diff --git a/nuttx/graphics/nxconsole/nxcon_register.c b/nuttx/graphics/nxconsole/nxcon_register.c index 663764dce..bb041ca7b 100644 --- a/nuttx/graphics/nxconsole/nxcon_register.c +++ b/nuttx/graphics/nxconsole/nxcon_register.c @@ -132,6 +132,11 @@ FAR struct nxcon_state_s * nxcon_home(priv); + /* Show the cursor */ + + priv->cursor.code = CONFIG_NXCONSOLE_CURSORCHAR; + nxcon_showcursor(priv); + /* Register the driver */ snprintf(devname, NX_DEVNAME_SIZE, NX_DEVNAME_FORMAT, minor); diff --git a/nuttx/include/nuttx/nx/nxconsole.h b/nuttx/include/nuttx/nx/nxconsole.h index 4a9e43ea5..48ac3eacd 100644 --- a/nuttx/include/nuttx/nx/nxconsole.h +++ b/nuttx/include/nuttx/nx/nxconsole.h @@ -69,6 +69,8 @@ * Currently, NxConsole supports only a single pixel depth. This * configuration setting must be provided to support that single pixel depth. * Default: The smallest enabled pixel depth. (see CONFIG_NX_DISABLE_*BPP) + * CONFIG_NXCONSOLE_CURSORCHAR + * The bitmap code to use as the cursor. Default '_' * CONFIG_NXCONSOLE_NOGETRUN * NxConsole needs to know if it can read from the LCD or not. If reading * from the LCD is supported, then NxConsole can do more efficient @@ -95,6 +97,12 @@ * that the text is simply truncated until a new line is encountered. */ +/* Cursor character */ + +#ifndef CONFIG_NXCONSOLE_CURSORCHAR +# define CONFIG_NXCONSOLE_CURSORCHAR '_' +#endif + /* The maximum number of characters that can be remembered */ #ifndef CONFIG_NXCONSOLE_MXCHARS diff --git a/nuttx/include/nuttx/vt100.h b/nuttx/include/nuttx/vt100.h index a0254e88a..a0254e88a 100755..100644 --- a/nuttx/include/nuttx/vt100.h +++ b/nuttx/include/nuttx/vt100.h |