Rename SLCD geometry tructure to attributes; Move MAX contrast to attributes. Add attribute and ioctl commands to get and set SLCD brightness

This commit is contained in:
Gregory Nutt 2013-05-27 07:26:59 -06:00
parent d4e7f7fa94
commit 157789e373
7 changed files with 94 additions and 79 deletions

View File

@ -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).

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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"

View File

@ -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.

View File

@ -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
*
* argument: Pointer type int that will receive the maximum contrast
* setting
*/
#define SLCDIOC_MAXCONTRAST _SLCDIOC(0x0005)
/* SLCDIOC_SETCONTRAST: Set the contrast to a new value
*
* argument: The new contrast value
*/
#define SLCDIOC_SETCONTRAST _SLCDIOC(0x0006)
#define SLCDIOC_SETCONTRAST _SLCDIOC(0x0005)
/* SLCDIOC_GETBRIGHTNESS: Get the current brightness setting
*
* argument: Pointer type int that will receive the current brightness
* setting
*/
#define SLCDIOC_GETBRIGHTNESS _SLCDIOC(0x0006)
/* SLCDIOC_SETBRIGHTNESS: Set the brightness to a new value
*
* argument: The new brightness value
*/
#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 */