The NX console appears to be fully functional

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4536 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-03-28 19:29:30 +00:00
parent 9e5d37dcdd
commit 61c5ec1bc7
18 changed files with 164 additions and 92 deletions

View File

@ -2598,3 +2598,7 @@
DAC. Contriburted by by Lzzy. DAC. Contriburted by by Lzzy.
* graphics/nxconsole: Add a character driver that can be used as a console output * graphics/nxconsole: Add a character driver that can be used as a console output
device for text output (still under development on initial check-in). device for text output (still under development on initial check-in).
* graphics/nxmu: Fix several compilation errors that have crept into the multi-
user NX server because of lack of use.
* graphics/nxconsole: The NX text console is basically function (in multi-
user NX mode only).

View File

@ -387,6 +387,8 @@ nx11
-#CONFIGURED_APPS += examples/nxconsole -#CONFIGURED_APPS += examples/nxconsole
+CONFIGURED_APPS += examples/nxconsole +CONFIGURED_APPS += examples/nxconsole
See apps/examples/README.txt for further details.
ostest ostest
Description Description

View File

@ -457,7 +457,7 @@ CONFIG_NX_MXCLIENTMSGS=16
CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE=n
CONFIG_NXCONSOLE_BPP=8 CONFIG_NXCONSOLE_BPP=8
# CONFIG_NXCONSOLE_NOGETRUN # CONFIG_NXCONSOLE_NOGETRUN
# CONFIG_NXCONSOLE_MXCHARS CONFIG_NXCONSOLE_MXCHARS=256
# CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_FONTCACHE
# CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_CACHESIZE
# CONFIG_NXCONSOLE_LINESEPARATION # CONFIG_NXCONSOLE_LINESEPARATION

View File

@ -458,7 +458,7 @@ CONFIG_NX_MXCLIENTMSGS=16
CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE=n
CONFIG_NXCONSOLE_BPP=32 CONFIG_NXCONSOLE_BPP=32
# CONFIG_NXCONSOLE_NOGETRUN # CONFIG_NXCONSOLE_NOGETRUN
# CONFIG_NXCONSOLE_MXCHARS CONFIG_NXCONSOLE_MXCHARS=256
# CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_FONTCACHE
# CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_CACHESIZE
# CONFIG_NXCONSOLE_LINESEPARATION # CONFIG_NXCONSOLE_LINESEPARATION

View File

@ -17,6 +17,7 @@ Contents
- Temperature Sensor - Temperature Sensor
- RTC - RTC
- STM3210E-EVAL-specific Configuration Options - STM3210E-EVAL-specific Configuration Options
- NxConsole
- Configurations - Configurations
Development Environment Development Environment
@ -350,6 +351,28 @@ RTC
overflow interrupt may be lost even if the STM32 is powered down only momentarily. overflow interrupt may be lost even if the STM32 is powered down only momentarily.
Therefore hi-res solution is only useful in systems where the power is always on. Therefore hi-res solution is only useful in systems where the power is always on.
NxConsole
=========
Several of the graphic-releted configurations are set to use the
examples/nxconsole test. To enable this configuration,
First, select NX Multi-User mode:
CONFG_NX_MULTIUSER=y
CONFIG_DISABLE_MQUEUE=n
Then add the following definition to the defconfig file to enable
the NxConsole driver:
CONFIG_NXCONSOLE=y
Make sure the that following is in place the appconfig file (perhaps
eliminating other examples):
CONFIGURED_APPS += examples/nxconsole
See apps/examples/README.txt for further details.
STM3210E-EVAL-specific Configuration Options STM3210E-EVAL-specific Configuration Options
============================================ ============================================

View File

@ -1076,7 +1076,7 @@ CONFIG_NX_MXCLIENTMSGS=16
CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE=n
CONFIG_NXCONSOLE_BPP=16 CONFIG_NXCONSOLE_BPP=16
# CONFIG_NXCONSOLE_NOGETRUN # CONFIG_NXCONSOLE_NOGETRUN
# CONFIG_NXCONSOLE_MXCHARS CONFIG_NXCONSOLE_MXCHARS=256
# CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_FONTCACHE
# CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_CACHESIZE
# CONFIG_NXCONSOLE_LINESEPARATION # CONFIG_NXCONSOLE_LINESEPARATION

View File

@ -926,7 +926,7 @@ CONFIG_NX_MXCLIENTMSGS=16
CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE=n
CONFIG_NXCONSOLE_BPP=16 CONFIG_NXCONSOLE_BPP=16
# CONFIG_NXCONSOLE_NOGETRUN # CONFIG_NXCONSOLE_NOGETRUN
# CONFIG_NXCONSOLE_MXCHARS CONFIG_NXCONSOLE_MXCHARS=256
# CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_FONTCACHE
# CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_CACHESIZE
# CONFIG_NXCONSOLE_LINESEPARATION # CONFIG_NXCONSOLE_LINESEPARATION

View File

@ -925,7 +925,7 @@ CONFIG_NX_MXCLIENTMSGS=16
CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE=n
CONFIG_NXCONSOLE_BPP=16 CONFIG_NXCONSOLE_BPP=16
# CONFIG_NXCONSOLE_NOGETRUN # CONFIG_NXCONSOLE_NOGETRUN
# CONFIG_NXCONSOLE_MXCHARS CONFIG_NXCONSOLE_MXCHARS=256
# CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_FONTCACHE
# CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_CACHESIZE
# CONFIG_NXCONSOLE_LINESEPARATION # CONFIG_NXCONSOLE_LINESEPARATION

View File

@ -925,7 +925,7 @@ CONFIG_NX_MXCLIENTMSGS=16
CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE=n
CONFIG_NXCONSOLE_BPP=16 CONFIG_NXCONSOLE_BPP=16
# CONFIG_NXCONSOLE_NOGETRUN # CONFIG_NXCONSOLE_NOGETRUN
# CONFIG_NXCONSOLE_MXCHARS CONFIG_NXCONSOLE_MXCHARS=256
# CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_FONTCACHE
# CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_CACHESIZE
# CONFIG_NXCONSOLE_LINESEPARATION # CONFIG_NXCONSOLE_LINESEPARATION

View File

@ -47,6 +47,8 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/nx/nx.h> #include <nuttx/nx/nx.h>
#include <nuttx/nx/nxtk.h> #include <nuttx/nx/nxtk.h>
#include <nuttx/nx/nxfonts.h> #include <nuttx/nx/nxfonts.h>
@ -103,14 +105,16 @@
* Name: nxcon_freeglyph * Name: nxcon_freeglyph
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_NXCONSOLE_FONTCACHE
static void nxcon_freeglyph(FAR struct nxcon_glyph_s *glyph) static void nxcon_freeglyph(FAR struct nxcon_glyph_s *glyph)
{ {
if (glyph->bitmap) if (glyph->bitmap)
{ {
free(glyph->bitmap); kfree(glyph->bitmap);
} }
memset(glyph, 0, sizeof(struct nxcon_glyph_s)); memset(glyph, 0, sizeof(struct nxcon_glyph_s));
} }
#endif
/**************************************************************************** /****************************************************************************
* Name: nxcon_allocglyph * Name: nxcon_allocglyph
@ -183,9 +187,6 @@ nxcon_allocglyph(FAR struct nxcon_state_s *priv)
luglyph->usecnt = 1; luglyph->usecnt = 1;
return luglyph; return luglyph;
#else #else
/* TODO: Instead allocating an freeing, just allocate the max glyph once */
nxcon_freeglyph(&priv->glyph);
return &priv->glyph; return &priv->glyph;
#endif #endif
} }
@ -236,7 +237,6 @@ nxcon_renderglyph(FAR struct nxcon_state_s *priv,
#if CONFIG_NXCONSOLE_BPP < 8 #if CONFIG_NXCONSOLE_BPP < 8
nxgl_mxpixel_t pixel; nxgl_mxpixel_t pixel;
#endif #endif
int bmsize;
int row; int row;
int col; int col;
int ret; int ret;
@ -255,29 +255,50 @@ nxcon_renderglyph(FAR struct nxcon_state_s *priv,
glyph->width = fbm->metric.width + fbm->metric.xoffset; glyph->width = fbm->metric.width + fbm->metric.xoffset;
glyph->height = fbm->metric.height + fbm->metric.yoffset; glyph->height = fbm->metric.height + fbm->metric.yoffset;
/* Allocate memory to hold the glyph with its offsets */ /* Get the physical width of the glyph in bytes */
glyph->stride = (glyph->width * CONFIG_NXCONSOLE_BPP + 7) / 8; glyph->stride = (glyph->width * CONFIG_NXCONSOLE_BPP + 7) / 8;
bmsize = glyph->stride * glyph->height;
glyph->bitmap = (FAR uint8_t *)malloc(bmsize); /* Allocate memory to hold the glyph with its offsets */
#ifdef CONFIG_NXCONSOLE_FONTCACHE
{
DEBUGASSERT(glyph->bitmap == NULL);
int bmsize = glyph->stride * glyph->height;
glyph->bitmap = (FAR uint8_t *)kmalloc(bmsize);
}
#else
DEBUGASSERT(glyph->bitmap != NULL);
#endif
if (glyph->bitmap) if (glyph->bitmap)
{ {
/* Initialize the glyph memory to the background color */ /* Initialize the glyph memory to the background color using the
* hard-coded bits-per-pixel (BPP).
*
* TODO: The rest of NX is configured to support multiple devices
* with differing BPP. They logic should be extended to support
* differing BPP's as well.
*/
#if CONFIG_NXCONSOLE_BPP < 8 #if CONFIG_NXCONSOLE_BPP < 8
pixel = priv->wcolor[0]; pixel = priv->wcolor[0];
# if CONFIG_NXCONSOLE_BPP == 1 # if CONFIG_NXCONSOLE_BPP == 1
/* Pack 1-bit pixels into a 2-bits */ /* Pack 1-bit pixels into a 2-bits */
pixel &= 0x01; pixel &= 0x01;
pixel = (pixel) << 1 |pixel; pixel = (pixel) << 1 | pixel;
# endif # endif
# if CONFIG_NXCONSOLE_BPP < 4 # if CONFIG_NXCONSOLE_BPP < 4
/* Pack 2-bit pixels into a nibble */ /* Pack 2-bit pixels into a nibble */
pixel &= 0x03; pixel &= 0x03;
pixel = (pixel) << 2 |pixel; pixel = (pixel) << 2 | pixel;
# endif # endif
/* Pack 4-bit nibbles into a byte */ /* Pack 4-bit nibbles into a byte */
@ -323,7 +344,9 @@ nxcon_renderglyph(FAR struct nxcon_state_s *priv,
/* Actually, the RENDERER never returns a failure */ /* Actually, the RENDERER never returns a failure */
gdbg("nxcon_renderglyph: RENDERER failed\n"); gdbg("nxcon_renderglyph: RENDERER failed\n");
#ifdef CONFIG_NXCONSOLE_FONTCACHE
nxcon_freeglyph(glyph); nxcon_freeglyph(glyph);
#endif
glyph = NULL; glyph = NULL;
} }
} }

View File

@ -55,53 +55,6 @@
/**************************************************************************** /****************************************************************************
* Definitions * Definitions
****************************************************************************/ ****************************************************************************/
/* Configuration ************************************************************/
/* The maximum number of characters that can be remembered */
#ifndef CONFIG_NXCONSOLE_MXCHARS
# define CONFIG_NXCONSOLE_MXCHARS 128
#endif
/* Font cache -- this is the number or pre-rendered font glyphs that can be
* remembered.
*/
#ifdef CONFIG_NXCONSOLE_FONTCACHE
# ifndef CONFIG_NXCONSOLE_CACHESIZE
# define CONFIG_NXCONSOLE_CACHESIZE 16
# endif
#else
# undef CONFIG_NXCONSOLE_CACHESIZE
#endif
/* Pixel depth */
#ifndef CONFIG_NXCONSOLE_BPP
# if !defined(CONFIG_NX_DISABLE_1BPP)
# define CONFIG_NXCONSOLE_BPP 1
# elif !defined(CONFIG_NX_DISABLE_2BPP)
# define CONFIG_NXCONSOLE_BPP 2
# elif !defined(CONFIG_NX_DISABLE_4BPP)
# define CONFIG_NXCONSOLE_BPP 4
# elif !defined(CONFIG_NX_DISABLE_8BPP)
# define CONFIG_NXCONSOLE_BPP 8
# elif !defined(CONFIG_NX_DISABLE_16BPP)
# define CONFIG_NXCONSOLE_BPP 16
//#elif !defined(CONFIG_NX_DISABLE_24BPP)
//# define CONFIG_NXCONSOLE_BPP 24
# elif !defined(CONFIG_NX_DISABLE_32BPP)
# define CONFIG_NXCONSOLE_BPP 32
# else
# error "No pixel depth provided"
# endif
#endif
/* Space (in rows) between lines */
#ifndef CONFIG_NXCONSOLE_LINESEPARATION
# define CONFIG_NXCONSOLE_LINESEPARATION 2
#endif
/* NxConsole Definitions ****************************************************/ /* NxConsole Definitions ****************************************************/
/* Bitmap flags */ /* Bitmap flags */

View File

@ -41,6 +41,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <semaphore.h>
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
@ -112,6 +113,25 @@ void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect, bool mor
priv = (FAR struct nxcon_state_s *)handle; priv = (FAR struct nxcon_state_s *)handle;
/* Get exclusive access to the state structure */
do
{
ret = sem_wait(&priv->exclsem);
/* 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 */ /* Fill the rectangular region with the window background color */
ret = priv->ops->fill(priv, rect, priv->wndo.wcolor); ret = priv->ops->fill(priv, rect, priv->wndo.wcolor);
@ -128,4 +148,5 @@ void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect, bool mor
{ {
nxcon_fillchar(priv, rect, &priv->bm[i]); nxcon_fillchar(priv, rect, &priv->bm[i]);
} }
ret = sem_post(&priv->exclsem);
} }

View File

@ -120,13 +120,32 @@ FAR struct nxcon_state_s *
priv->fwidth = fontset->mxwidth; priv->fwidth = fontset->mxwidth;
priv->spwidth = fontset->spwidth; priv->spwidth = fontset->spwidth;
/* Set up the text caches */ /* Set up the text cache */
priv->maxchars = CONFIG_NXCONSOLE_MXCHARS; priv->maxchars = CONFIG_NXCONSOLE_MXCHARS;
/* Set up the font glyph bitmap cache (if enabled) */
#ifdef CONFIG_NXCONSOLE_FONTCACHE #ifdef CONFIG_NXCONSOLE_FONTCACHE
priv->maxglyphs = CONFIG_NXCONSOLE_CACHESIZE; priv->maxglyphs = CONFIG_NXCONSOLE_CACHESIZE;
#endif #endif
/* Pre-allocate maximal sized glyph bitmap memory (only if we are not
* using the glyph cache.
*/
#ifndef CONFIG_NXCONSOLE_FONTCACHE
{
int allocsize = (priv->fheight * priv->fwidth * CONFIG_NXCONSOLE_BPP + 7) >> 3;
priv->glyph.bitmap = (FAR uint8_t *)kmalloc(allocsize);
if (!priv->glyph.bitmap)
{
gdbg("Failed to allocate glyph memory\n");
goto errout;
}
}
#endif
/* Set the initial display position */ /* Set the initial display position */
nxcon_home(priv); nxcon_home(priv);

View File

@ -97,6 +97,12 @@ void nxcon_unregister(NXCONSOLE handle)
priv = (FAR struct nxcon_state_s *)handle; priv = (FAR struct nxcon_state_s *)handle;
sem_destroy(&priv->exclsem); sem_destroy(&priv->exclsem);
/* Free the pre-allocated glyph bitmap */
#ifndef CONFIG_NXCONSOLE_FONTCACHE
kfree(priv->glyph.bitmap);
#endif
/* Unregister the driver */ /* Unregister the driver */
snprintf(devname, NX_DEVNAME_SIZE, NX_DEVNAME_FORMAT, priv->minor); snprintf(devname, NX_DEVNAME_SIZE, NX_DEVNAME_FORMAT, priv->minor);

View File

@ -94,7 +94,7 @@ void nx_disconnect(NXHANDLE handle)
/* Inform the server that this client no longer exists */ /* Inform the server that this client no longer exists */
msg.msgid = NX_SVRMSG_CONNECT; msg.msgid = NX_SVRMSG_DISCONNECT;
msg.conn = conn; msg.conn = conn;
ret = mq_send(conn->cwrmq, &msg, sizeof(struct nxsvrmsg_s), NX_SVRMSG_PRIO); ret = mq_send(conn->cwrmq, &msg, sizeof(struct nxsvrmsg_s), NX_SVRMSG_PRIO);

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* graphics/nxmu/nx_releasebkgd.c * graphics/nxmu/nx_releasebkgd.c
* *
* Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -129,31 +129,6 @@ static inline void nxmu_connect(FAR struct nxfe_conn_s *conn)
} }
} }
/****************************************************************************
* Name: nxmu_release
****************************************************************************/
static int nxmu_release(FAR struct nxfe_state_s *fe)
{
FAR struct nxbe_window_s *wnd;
struct nxclimsg_s outmsg;
int ret;
/* Don't want windows to close while we do this */
for (wnd = fe->be.topwnd; wnd; wnd = wnd->below)
{
outmsg.msgid = NX_CLIMSG_DISCONNECTED;
ret = mq_send(wnd->conn->swrmq, &outmsg, sizeof(struct nxclimsg_s), NX_CLIMSG_PRIO);
if (ret < 0)
{
gdbg("mq_send failed: %d\n", errno);
}
}
return OK;
}
/**************************************************************************** /****************************************************************************
* Name: nxmu_shutdown * Name: nxmu_shutdown
****************************************************************************/ ****************************************************************************/

View File

@ -94,6 +94,52 @@
* that the text is simply truncated until a new line is encountered. * that the text is simply truncated until a new line is encountered.
*/ */
/* The maximum number of characters that can be remembered */
#ifndef CONFIG_NXCONSOLE_MXCHARS
# define CONFIG_NXCONSOLE_MXCHARS 128
#endif
/* Font cache -- this is the number or pre-rendered font glyphs that can be
* remembered.
*/
#ifdef CONFIG_NXCONSOLE_FONTCACHE
# ifndef CONFIG_NXCONSOLE_CACHESIZE
# define CONFIG_NXCONSOLE_CACHESIZE 16
# endif
#else
# undef CONFIG_NXCONSOLE_CACHESIZE
#endif
/* Pixel depth */
#ifndef CONFIG_NXCONSOLE_BPP
# if !defined(CONFIG_NX_DISABLE_1BPP)
# define CONFIG_NXCONSOLE_BPP 1
# elif !defined(CONFIG_NX_DISABLE_2BPP)
# define CONFIG_NXCONSOLE_BPP 2
# elif !defined(CONFIG_NX_DISABLE_4BPP)
# define CONFIG_NXCONSOLE_BPP 4
# elif !defined(CONFIG_NX_DISABLE_8BPP)
# define CONFIG_NXCONSOLE_BPP 8
# elif !defined(CONFIG_NX_DISABLE_16BPP)
# define CONFIG_NXCONSOLE_BPP 16
//#elif !defined(CONFIG_NX_DISABLE_24BPP)
//# define CONFIG_NXCONSOLE_BPP 24
# elif !defined(CONFIG_NX_DISABLE_32BPP)
# define CONFIG_NXCONSOLE_BPP 32
# else
# error "No pixel depth provided"
# endif
#endif
/* Space (in rows) between lines */
#ifndef CONFIG_NXCONSOLE_LINESEPARATION
# define CONFIG_NXCONSOLE_LINESEPARATION 2
#endif
/**************************************************************************** /****************************************************************************
* Public Types * Public Types
****************************************************************************/ ****************************************************************************/