Extentions SCLD test; SCLD CODEC and LCD1602 driver bug fixes

This commit is contained in:
Gregory Nutt 2013-05-26 09:28:57 -06:00
parent 98908461f6
commit 892774bbff
2 changed files with 62 additions and 32 deletions

View File

@ -562,4 +562,5 @@
Book. Contributed by Max Holtberg (2013-5-22).
* apps/examples/slcd: Add an example for testing alphanumeric,
segment LCDs (2013-5-24).
* apps/examples/slcd: Extend SLCD test to handle multi-line displays
(2013-5-26).

View File

@ -54,8 +54,8 @@
* Pre-processor Definitions
****************************************************************************/
#ifndef EXAMPLES_SLCD_DEVNAME
# define EXAMPLES_SLCD_DEVNAME "/dev/slcd"
#ifndef CONFIG_EXAMPLES_SLCD_DEVNAME
# define CONFIG_EXAMPLES_SLCD_DEVNAME "/dev/slcd"
#endif
/****************************************************************************
@ -64,6 +64,9 @@
/* All state information for this test is kept within the following structure
* in order create a namespace and to minimize the possibility of name
* collisions.
*
* NOTE: stream must be the first element of struct slcd_test_s to support
* casting between these two types.
*/
struct slcd_test_s
@ -71,6 +74,8 @@ struct slcd_test_s
struct lib_outstream_s stream; /* Stream to use for all output */
struct slcd_geometry_s geo; /* Size of the SLCD (rows x columns) */
int fd; /* File descriptor or the open SLCD device */
bool initialized; /* TRUE: Initialized */
uint8_t currow; /* Next row to display */
/* The I/O buffer */
@ -102,7 +107,7 @@ void slcd_dumpbuffer(FAR const char *msg, FAR const uint8_t *buffer, unsigned in
int j;
int k;
printf("%s (%p):\n", msg, buffer);
printf("%s:\n", msg);
for (i = 0; i < buflen; i += 32)
{
printf("%04x: ", i);
@ -256,8 +261,12 @@ int slcd_main(int argc, char *argv[])
{
str = argv[1];
}
#endif
/* Are we already initialized? */
if (!priv->initialized)
#endif
{
/* Initialize the output stream */
memset(priv, 0, sizeof(struct slcd_test_s));
@ -268,12 +277,12 @@ int slcd_main(int argc, char *argv[])
/* Open the SLCD device */
printf("Opening %s for read/write access\n", EXAMPLES_SLCD_DEVNAME);
printf("Opening %s for read/write access\n", CONFIG_EXAMPLES_SLCD_DEVNAME);
priv->fd = open(EXAMPLES_SLCD_DEVNAME, O_RDWR);
priv->fd = open(CONFIG_EXAMPLES_SLCD_DEVNAME, O_RDWR);
if (priv->fd < 0)
{
printf("Failed to open %s: %d\n", EXAMPLES_SLCD_DEVNAME, errno);
printf("Failed to open %s: %d\n", CONFIG_EXAMPLES_SLCD_DEVNAME, errno);
goto errout;
}
@ -293,6 +302,25 @@ int slcd_main(int argc, char *argv[])
printf("Clear screen\n");
slcd_encode(SLCDCODE_CLEAR, 0, &priv->stream);
slcd_flush(&priv->stream);
priv->initialized = true;
}
/* Set the cursor to the beginning of the current row and erase to the end
* of the line.
*/
slcd_encode(SLCDCODE_HOME, 0, &priv->stream);
slcd_encode(SLCDCODE_DOWN, priv->currow, &priv->stream);
slcd_encode(SLCDCODE_ERASEEOL, 0, &priv->stream);
/* Increment to the next row, wrapping back to first if necessary. */
if (++priv->currow >= priv->geo.nrows)
{
priv->currow = 0;
}
/* Say hello */
@ -309,5 +337,6 @@ int slcd_main(int argc, char *argv[])
errout_with_fd:
close(priv->fd);
errout:
priv->initialized = false;
exit(EXIT_FAILURE);
}