diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-05-27 07:26:59 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-05-27 07:26:59 -0600 |
commit | bec3b36f727b4bccdf9900097ae8d76fb7faa1ab (patch) | |
tree | d437009bc570af3f132ee68cd68f002b2f76f4a2 | |
parent | 168976579a7a81d31112283b23ff9fe7b7d25166 (diff) | |
download | nuttx-bec3b36f727b4bccdf9900097ae8d76fb7faa1ab.tar.gz nuttx-bec3b36f727b4bccdf9900097ae8d76fb7faa1ab.tar.bz2 nuttx-bec3b36f727b4bccdf9900097ae8d76fb7faa1ab.zip |
Rename SLCD geometry tructure to attributes; Move MAX contrast to attributes. Add attribute and ioctl commands to get and set SLCD brightness
-rw-r--r-- | apps/examples/slcd/slcd_main.c | 20 | ||||
-rw-r--r-- | nuttx/ChangeLog | 4 | ||||
-rw-r--r-- | nuttx/configs/pcblogic-pic32mx/src/pic32mx_lcd1602.c | 29 | ||||
-rw-r--r-- | nuttx/configs/stm32ldiscovery/src/stm32_lcd.c | 43 | ||||
-rw-r--r-- | nuttx/configs/sure-pic32mx/src/pic32mx_lcd1602.c | 37 | ||||
-rw-r--r-- | nuttx/drivers/lcd/Kconfig | 14 | ||||
-rw-r--r-- | nuttx/drivers/lcd/README.txt | 5 | ||||
-rw-r--r-- | nuttx/include/nuttx/lcd/slcd_ioctl.h | 35 |
8 files changed, 101 insertions, 86 deletions
diff --git a/apps/examples/slcd/slcd_main.c b/apps/examples/slcd/slcd_main.c index 604ac6c28..e7f0ff00f 100644 --- a/apps/examples/slcd/slcd_main.c +++ b/apps/examples/slcd/slcd_main.c @@ -71,11 +71,11 @@ 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 */ + struct lib_outstream_s stream; /* Stream to use for all output */ + struct slcd_attributes_s attr; /* 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 */ @@ -287,17 +287,17 @@ int slcd_main(int argc, char *argv[]) priv->stream.flush = slcd_flush; #endif - /* Get the geometry of the SCLD device */ + /* Get the attributes of the SCLD device */ - ret = ioctl(fd, SLCDIOC_GEOMETRY, (unsigned long)&priv->geo); + ret = ioctl(fd, SLCDIOC_GETATTRIBUTES, (unsigned long)&priv->attr); if (ret < 0) { - printf("ioctl(SLCDIOC_GEOMETRY) failed: %d\n", errno); + printf("ioctl(SLCDIOC_GETATTRIBUTES) failed: %d\n", errno); goto errout_with_fd; } printf("Geometry rows: %d columns: %d nbars: %d\n", - priv->geo.nrows, priv->geo.ncolumns, priv->geo.nbars); + priv->attr.nrows, priv->attr.ncolumns, priv->attr.nbars); /* Home the cursor and clear the display */ @@ -322,7 +322,7 @@ int slcd_main(int argc, char *argv[]) /* Increment to the next row, wrapping back to first if necessary. */ - if (++priv->currow >= priv->geo.nrows) + if (++priv->currow >= priv->attr.nrows) { priv->currow = 0; } diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index a630f65a4..26c71b541 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -4811,4 +4811,6 @@ a segment LCD driver for the board. The initial checkin of the LCD driver is just a clone of configs/pcblogic-pic32mx/src/pic32mx_lcd1602 and it not yet expected to be functional (2013-5-26). - + * include/nuttx/lcd/slcd_ioctl.h and all SLCD drivers: Rename geometry + structure to attributes; Move MAX contrast to attributes. Add + attribute and ioctl commands to get and set LCD brightness (2013-5-27). diff --git a/nuttx/configs/pcblogic-pic32mx/src/pic32mx_lcd1602.c b/nuttx/configs/pcblogic-pic32mx/src/pic32mx_lcd1602.c index e2be0a243..d12c6bdab 100644 --- a/nuttx/configs/pcblogic-pic32mx/src/pic32mx_lcd1602.c +++ b/nuttx/configs/pcblogic-pic32mx/src/pic32mx_lcd1602.c @@ -786,26 +786,28 @@ static int lcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg) switch (cmd) { - /* SLCDIOC_GEOMETRY: Get the SLCD geometry (rows x characters) + /* SLCDIOC_GETATTRIBUTES: Get the attributes of the SLCD * - * argument: Pointer to struct slcd_geometry_s in which values will be + * argument: Pointer to struct slcd_attributes_s in which values will be * returned */ - case SLCDIOC_GEOMETRY: + case SLCDIOC_GETATTRIBUTES: { - FAR struct slcd_geometry_s *geo = (FAR struct slcd_geometry_s *)((uintptr_t)arg); + FAR struct slcd_attributes_s *attr = (FAR struct slcd_attributes_s *)((uintptr_t)arg); - lcdvdbg("SLCDIOC_GEOMETRY: nrows=%d ncolumns=%d\n", LCD_NROWS, LCD_NCOLUMNS); + lcdvdbg("SLCDIOC_GETATTRIBUTES:\n"); - if (!geo) + if (!attr) { return -EINVAL; } - geo->nrows = LCD_NROWS; - geo->ncolumns = LCD_NCOLUMNS; - geo->nbars = 0; + attr->nrows = LCD_NROWS; + attr->ncolumns = LCD_NCOLUMNS; + attr->nbars = 0; + attr->maxcontrast = 0; + attr->maxbrightness = 0 } break; @@ -832,10 +834,11 @@ static int lcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg) } break; - case SLCDIOC_SETBAR: /* SLCDIOC_SETBAR: Set bars on a bar display */ - case SLCDIOC_GETCONTRAST: /* SLCDIOC_GETCONTRAST: Get the current contrast setting */ - case SLCDIOC_MAXCONTRAST: /* SLCDIOC_MAXCONTRAST: Get the maximum contrast setting */ - case SLCDIOC_SETCONTRAST: /* SLCDIOC_SETCONTRAST: Set the contrast to a new value */ + case SLCDIOC_SETBAR: /* SLCDIOC_SETBAR: Set bars on a bar display */ + case SLCDIOC_GETCONTRAST: /* SLCDIOC_GETCONTRAST: Get the current contrast setting */ + case SLCDIOC_SETCONTRAST: /* SLCDIOC_SETCONTRAST: Set the contrast to a new value */ + case SLCDIOC_GETBRIGHTNESS: /* Get the current brightness setting */ + case SLCDIOC_SETBRIGHTNESS: /* Set the brightness to a new value */ default: return -ENOTTY; } diff --git a/nuttx/configs/stm32ldiscovery/src/stm32_lcd.c b/nuttx/configs/stm32ldiscovery/src/stm32_lcd.c index 789c2694a..ee8dd17a4 100644 --- a/nuttx/configs/stm32ldiscovery/src/stm32_lcd.c +++ b/nuttx/configs/stm32ldiscovery/src/stm32_lcd.c @@ -1310,26 +1310,28 @@ static int slcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg) switch (cmd) { - /* SLCDIOC_GEOMETRY: Get the SLCD geometry (rows x characters) + /* SLCDIOC_GETATTRIBUTES: Get the attributes of the SLCD * - * argument: Pointer to struct slcd_geometry_s in which values will be + * argument: Pointer to struct slcd_attributes_s in which values will be * returned */ - case SLCDIOC_GEOMETRY: + case SLCDIOC_GETATTRIBUTES: { - FAR struct slcd_geometry_s *geo = (FAR struct slcd_geometry_s *)((uintptr_t)arg); + FAR struct slcd_attributes_s *attr = (FAR struct slcd_attributes_s *)((uintptr_t)arg); - lcdvdbg("SLCDIOC_GEOMETRY: nrows=%d ncolumns=%d\n", SLCD_NROWS, SLCD_NCHARS); + lcdvdbg("SLCDIOC_GETATTRIBUTES:\n"); - if (!geo) + if (!attr) { return -EINVAL; } - geo->nrows = SLCD_NROWS; - geo->ncolumns = SLCD_NCHARS; - geo->nbars = SLCD_NBARS; + attr->nrows = SLCD_NROWS; + attr->ncolumns = SLCD_NCHARS; + attr->nbars = SLCD_NBARS; + attr->maxcontrast = SLCD_MAXCONTRAST; + attr->maxbrightness = 0; } break; @@ -1415,27 +1417,6 @@ static int slcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg) } break; - /* SLCDIOC_MAXCONTRAST: Get the maximum contrast setting - * - * argument: Pointer type int that will receive the maximum contrast - * setting - */ - - case SLCDIOC_MAXCONTRAST: - { - FAR int *contrast = (FAR int *)((uintptr_t)arg); - - lcdvdbg("SLCDIOC_MAXCONTRAST: contrast=%d\n", SLCD_MAXCONTRAST); - - if (!contrast) - { - return -EINVAL; - } - - *contrast = SLCD_MAXCONTRAST; - } - break; - /* SLCDIOC_SETCONTRAST: Set the contrast to a new value * * argument: The new contrast value @@ -1454,6 +1435,8 @@ static int slcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg) } break; + case SLCDIOC_GETBRIGHTNESS: /* Get the current brightness setting */ + case SLCDIOC_SETBRIGHTNESS: /* Set the brightness to a new value */ default: return -ENOTTY; } diff --git a/nuttx/configs/sure-pic32mx/src/pic32mx_lcd1602.c b/nuttx/configs/sure-pic32mx/src/pic32mx_lcd1602.c index 1c51bb7af..9d48452b5 100644 --- a/nuttx/configs/sure-pic32mx/src/pic32mx_lcd1602.c +++ b/nuttx/configs/sure-pic32mx/src/pic32mx_lcd1602.c @@ -103,6 +103,14 @@ # error "CONFIG_PIC32MX_PMP is required to use the LCD" #endif +#ifndef CONFIG_LCD_MAXCONTRAST +# define CONFIG_LCD_MAXCONTRAST 100 +#endif + +#ifndef CONFIG_LCD_MAXPOWER +# define CONFIG_LCD_MAXPOWER 100 +#endif + /* Define CONFIG_DEBUG_LCD to enable detailed LCD debug output. Verbose debug must * also be enabled. */ @@ -787,26 +795,28 @@ static int lcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg) switch (cmd) { - /* SLCDIOC_GEOMETRY: Get the SLCD geometry (rows x characters) + /* SLCDIOC_GETATTRIBUTES: Get the attributes of the SLCD * - * argument: Pointer to struct slcd_geometry_s in which values will be + * argument: Pointer to struct slcd_attributes_s in which values will be * returned */ - case SLCDIOC_GEOMETRY: + case SLCDIOC_GETATTRIBUTES: { - FAR struct slcd_geometry_s *geo = (FAR struct slcd_geometry_s *)((uintptr_t)arg); + FAR struct slcd_attributes_s *attr = (FAR struct slcd_attributes_s *)((uintptr_t)arg); - lcdvdbg("SLCDIOC_GEOMETRY: nrows=%d ncolumns=%d\n", LCD_NROWS, LCD_NCOLUMNS); + lcdvdbg("SLCDIOC_GETATTRIBUTES:\n"); - if (!geo) + if (!attr) { return -EINVAL; } - geo->nrows = LCD_NROWS; - geo->ncolumns = LCD_NCOLUMNS; - geo->nbars = 0; + attr->nrows = LCD_NROWS; + attr->ncolumns = LCD_NCOLUMNS; + attr->nbars = 0; + attr->maxcontrast = CONFIG_LCD_MAXCONTRAST; + attr->maxbrightness = CONFIG_LCD_MAXPOWER; } break; @@ -833,10 +843,11 @@ static int lcd_ioctl(FAR struct file *filp, int cmd, unsigned long arg) } break; - case SLCDIOC_SETBAR: /* SLCDIOC_SETBAR: Set bars on a bar display */ - case SLCDIOC_GETCONTRAST: /* SLCDIOC_GETCONTRAST: Get the current contrast setting */ - case SLCDIOC_MAXCONTRAST: /* SLCDIOC_MAXCONTRAST: Get the maximum contrast setting */ - case SLCDIOC_SETCONTRAST: /* SLCDIOC_SETCONTRAST: Set the contrast to a new value */ + case SLCDIOC_SETBAR: /* SLCDIOC_SETBAR: Set bars on a bar display */ + case SLCDIOC_GETCONTRAST: /* SLCDIOC_GETCONTRAST: Get the current contrast setting */ + case SLCDIOC_SETCONTRAST: /* SLCDIOC_SETCONTRAST: Set the contrast to a new value */ + case SLCDIOC_GETBRIGHTNESS: /* Get the current brightness setting */ + case SLCDIOC_SETBRIGHTNESS: /* Set the brightness to a new value */ default: return -ENOTTY; } diff --git a/nuttx/drivers/lcd/Kconfig b/nuttx/drivers/lcd/Kconfig index 29a79a068..7673ed5d1 100644 --- a/nuttx/drivers/lcd/Kconfig +++ b/nuttx/drivers/lcd/Kconfig @@ -23,8 +23,9 @@ config LCD_MAXCONTRAST int "LCD maximum contrast" default 63 if NOKIA6100_S1D15G10 default 127 if NOKIA6100_PCF8833 - default 255 if LCD_P14201 + default 255 if LCD_P14201 || LCD_LCD1602 default 63 + range 1 255 ---help--- must be 63 with the Epson controller and 127 with the Phillips controller. @@ -32,11 +33,14 @@ config LCD_MAXCONTRAST config LCD_MAXPOWER int "LCD maximum power" default 1 + range 1 255 ---help--- - Maximum value of backlight setting. The backlight - control is managed outside of the 6100 driver so this value has no - meaning to the driver. Board-specific logic may place restrictions on - this value. + Maximum value of LCD power setting. This normally equates to brightness: + The brighter the screen, the hight the power usage. + + On LCDs that have a backlight, this value corresponds directly to that + backlight setting. Board-specific logic may place restrictions on this + value. comment "Graphic LCD Devices" diff --git a/nuttx/drivers/lcd/README.txt b/nuttx/drivers/lcd/README.txt index ef19da15d..d91abcd37 100644 --- a/nuttx/drivers/lcd/README.txt +++ b/nuttx/drivers/lcd/README.txt @@ -199,7 +199,10 @@ that makes then less re-usable: configs/skp16c26/src/up_lcd.c. Untested alphanumeric LCD driver. configs/pcblogic-pic32mx/src/up_lcd1602.c. LCD1602 is based on the - Hitachi HD44780U LCD controller. See also include/nuttx/lcd/hd4478ou.h. + Hitachi HD44780U LCD controller (untested). See also + include/nuttx/lcd/hd4478ou.h. + configs/sure-pic32mx/src/up_lcd1602.c. Another LCD1602-like segment + LCD. configs/stm32ldiscovery/src/stm32_lcd.c. 1x6 segment LCD with bars using the segment LCD controller built-into the STM32L15X. diff --git a/nuttx/include/nuttx/lcd/slcd_ioctl.h b/nuttx/include/nuttx/lcd/slcd_ioctl.h index 1e668702e..723550e5f 100644 --- a/nuttx/include/nuttx/lcd/slcd_ioctl.h +++ b/nuttx/include/nuttx/lcd/slcd_ioctl.h @@ -49,13 +49,13 @@ ****************************************************************************/ /* IOCTL commands that may be supported by some SLCD drivers */ -/* SLCDIOC_GEOMETRY: Get the SLCD geometry (rows x characters) +/* SLCDIOC_GETATTRIBUTES: Get the attributes of the SLCD * - * argument: Pointer to struct slcd_geometry_s in which values will be + * argument: Pointer to struct slcd_attributes_s in which values will be * returned */ -#define SLCDIOC_GEOMETRY _SLCDIOC(0x0001) +#define SLCDIOC_GETATTRIBUTES _SLCDIOC(0x0001) /* SLCDIOC_CURPOS: Get the SLCD cursor positioni (rows x characters) * @@ -63,14 +63,14 @@ * returned */ -#define SLCDIOC_CURPOS _SLCDIOC(0x0002) +#define SLCDIOC_CURPOS _SLCDIOC(0x0002) /* SLCDIOC_SETBAR: Set bars on a bar display * * argument: 32-bit bitset, with each bit corresponding to one bar. */ -#define SLCDIOC_SETBAR _SLCDIOC(0x0003) +#define SLCDIOC_SETBAR _SLCDIOC(0x0003) /* SLCDIOC_GETCONTRAST: Get the current contrast setting * @@ -80,32 +80,41 @@ #define SLCDIOC_GETCONTRAST _SLCDIOC(0x0004) -/* SLCDIOC_MAXCONTRAST: Get the maximum contrast setting +/* SLCDIOC_SETCONTRAST: Set the contrast to a new value + * + * argument: The new contrast value + */ + +#define SLCDIOC_SETCONTRAST _SLCDIOC(0x0005) + +/* SLCDIOC_GETBRIGHTNESS: Get the current brightness setting * - * argument: Pointer type int that will receive the maximum contrast + * argument: Pointer type int that will receive the current brightness * setting */ -#define SLCDIOC_MAXCONTRAST _SLCDIOC(0x0005) +#define SLCDIOC_GETBRIGHTNESS _SLCDIOC(0x0006) -/* SLCDIOC_SETCONTRAST: Set the contrast to a new value +/* SLCDIOC_SETBRIGHTNESS: Set the brightness to a new value * - * argument: The new contrast value + * argument: The new brightness value */ -#define SLCDIOC_SETCONTRAST _SLCDIOC(0x0006) +#define SLCDIOC_SETBRIGHTNESS _SLCDIOC(0x0007) /**************************************************************************** * Public Types ****************************************************************************/ -/* Used with the SLCDIOC_GEOMETRY ioctl call */ +/* Used with the SLCDIOC_GETATTRIBUTES ioctl call */ -struct slcd_geometry_s +struct slcd_attributes_s { uint16_t nrows; /* Number of the rows on the SLCD */ uint16_t ncolumns; /* Number of characters in one row on the SLCD */ uint8_t nbars; /* Number of bars supported by the SLCD */ + uint8_t maxcontrast; /* Maximum contrast value */ + uint8_t maxbrightness; /* Maximum brightness value */ }; /* Used with the SLCDIOC_CURPOS ioctl call */ |